Skip to content

Commit 8540b72

Browse files
authored
Migrate project to a uv workspace (#733)
Signed-off-by: Casper Beyer <[email protected]>
1 parent 172f3f9 commit 8540b72

File tree

111 files changed

+1491
-819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1491
-819
lines changed

.github/workflows/check.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
name: Check
22
on:
3-
push:
4-
branches:
5-
- "*"
6-
pull_request:
7-
branches:
8-
- "*"
3+
push:
4+
branches:
5+
- "*"
6+
pull_request:
7+
branches:
8+
- "*"
99
jobs:
10-
format:
11-
runs-on: ubuntu-latest
12-
name: Format
13-
steps:
14-
- name: Check out repository
15-
uses: actions/checkout@v3
10+
format:
11+
runs-on: ubuntu-latest
12+
name: Format
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v5
1616

17-
- name: Set up Python
18-
uses: actions/setup-python@v4
19-
with:
20-
python-version: "3.8"
17+
- name: Set up Python
18+
uses: actions/setup-python@v6
19+
with:
20+
python-version: "3.8"
2121

22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install pipenv
26-
pipenv install --dev
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v6
2724

28-
- name: Run format check
29-
run: |
30-
pipenv run yapf --diff --recursive .
25+
- name: Install the project
26+
run: uv sync --dev
3127

32-
- name: Run isort check
33-
run: pipenv run isort --check-only --diff .
28+
- name: Run format check
29+
run: |
30+
uv run yapf --diff --recursive nats/
31+
32+
- name: Run isort check
33+
run: uv run isort --check-only --diff nats/src

.github/workflows/test.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,25 @@ jobs:
2525

2626
steps:
2727
- name: Check out repository
28-
uses: actions/checkout@v2
28+
uses: actions/checkout@v5
2929

3030
- name: Set up Python ${{ matrix.python-version }}
31-
uses: actions/setup-python@v2
31+
uses: actions/setup-python@v6
3232
with:
3333
python-version: ${{ matrix.python-version }}
3434

35-
- name: Install dependencies
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@v6
37+
38+
- name: Install dependencies and project
3639
run: |
37-
pip install pipenv
38-
pip install certifi
39-
pipenv install --dev
40-
bash ./scripts/install_nats.sh
40+
uv sync --dev
41+
./nats/scripts/install_nats.sh
4142
4243
- name: Run tests
4344
run: |
44-
pipenv run flake8 --ignore="W391, W503, W504" ./nats/js/
45-
pipenv run pytest -x -vv -s --continue-on-collection-errors ./tests
45+
uv run flake8 --ignore="W391, W503, W504, E501" ./nats/src/nats/js/
46+
uv run pytest -x -vv -s --continue-on-collection-errors ./nats/tests
4647
env:
4748
PATH: $HOME/nats-server:$PATH
4849

.isort.cfg

Lines changed: 0 additions & 5 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 88 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,107 @@
1-
# Contributing
1+
# Contributing to NATS.py
22

3-
Thanks for your interest in contributing! This document contains `nats-io/nats.py` specific contributing details. If you are a first-time contributor, please refer to the general [NATS Contributor Guide](https://nats.io/contributing/) to get a comprehensive overview of contributing to the NATS project.
3+
Thank you for your interest in contributing to NATS.py!
44

5-
## Getting started
5+
## Development Setup
66

7-
There are three general ways you can contribute to this repo:
7+
This is a [uv workspace](https://docs.astral.sh/uv/concepts/workspaces/) containing multiple packages.
88

9-
- Proposing an enhancement or new feature
10-
- Reporting a bug or regression
11-
- Contributing changes to the source code
9+
### Prerequisites
1210

13-
For the first two, refer to the [GitHub Issues](https://github.com/nats-io/nats.py/issues/new/choose) which guides you through the available options along with the needed information to collect.
11+
1. [Install uv](https://docs.astral.sh/uv/getting-started/installation/)
12+
2. [Install nats-server](https://docs.nats.io/running-a-nats-service/introduction/installation) and ensure it's in your PATH: `nats-server -v`
1413

15-
## Contributing changes
14+
### Installation
1615

17-
_Prior to opening a pull request, it is recommended to open an issue first to ensure the maintainers can review intended changes. Exceptions to this rule include fixing non-functional source such as code comments, documentation or other supporting files._
16+
```bash
17+
# Clone the repository
18+
git clone https://github.com/nats-io/nats.py
19+
cd nats.py
1820

19-
Proposing source code changes is done through GitHub's standard pull request workflow.
21+
# Install dependencies
22+
uv sync
23+
```
2024

21-
If your branch is a work-in-progress then please start by creating your pull requests as draft, by clicking the down-arrow next to the `Create pull request` button and instead selecting `Create draft pull request`.
25+
## Running Tests
2226

23-
This will defer the automatic process of requesting a review from the NATS team and significantly reduces noise until you are ready. Once you are happy, you can click the `Ready for review` button.
27+
```bash
28+
# Run all tests
29+
uv run pytest
2430

25-
### Guidelines
31+
# Run tests for specific package
32+
uv run pytest nats/tests
33+
uv run pytest nats-server/tests
2634

27-
A good pull request includes:
35+
# Run tests in parallel
36+
uv run pytest -n auto
2837

29-
- A high-level description of the changes, including links to any issues that are related by adding comments like `Resolves #NNN` to your description. See [Linking a Pull Request to an Issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) for more information.
30-
- An up-to-date parent commit. Please make sure you are pulling in the latest `main` branch and rebasing your work on top of it, i.e. `git rebase main`.
31-
- Unit tests where appropriate. Bug fixes will benefit from the addition of regression tests. New features will not be accepted without suitable test coverage!
32-
- No more commits than necessary. Sometimes having multiple commits is useful for telling a story or isolating changes from one another, but please squash down any unnecessary commits that may just be for clean-up, comments or small changes.
33-
- No additional external dependencies that aren't absolutely essential. Please do everything you can to avoid pulling in additional libraries/dependencies into `go.mod` as we will be very critical of these.
38+
# Run with coverage
39+
uv run pytest --cov
40+
```
3441

35-
### Sign-off
42+
## Code Quality
3643

37-
In order to accept a contribution, you will first need to certify that the contribution is your original work and that you license the work to the project under the [Apache-2.0 license](https://github.com/nats-io/nats.py/blob/main/LICENSE).
44+
### Type Checking
3845

39-
This is done by using `Signed-off-by` statements, which should appear in **both** your commit messages and your PR description. Please note that we can only accept sign-offs under a legal name. Nicknames and aliases are not permitted.
46+
```bash
47+
uv run mypy nats/src
48+
```
4049

41-
To perform a sign-off with `git`, use `git commit -s` (or `--signoff`).
50+
### Formatting
4251

43-
## Get help
52+
```bash
53+
# Format code
54+
uv run yapf -i -r nats/src nats-server/src
4455

45-
If you have questions about the contribution process, please start a [GitHub discussion](https://github.com/nats-io/nats.py/discussions), join the [NATS Slack](https://slack.nats.io/), or send your question to the [NATS Google Group](https://groups.google.com/forum/#!forum/natsio).
56+
# Check formatting
57+
uv run yapf -d -r nats/src nats-server/src
58+
```
59+
60+
### Linting
61+
62+
```bash
63+
# Run ruff
64+
uv run ruff check nats/src nats-server/src
65+
66+
# Run flake8 (for nats-py)
67+
uv run flake8 nats/src/nats/js/
68+
69+
# Run isort
70+
uv run isort nats/src nats-server/src
71+
```
72+
73+
## Updating Documentation
74+
75+
To update the docs, first checkout the `docs` branch under a local copy of the `nats.py` repo:
76+
77+
```sh
78+
git clone https://github.com/nats-io/nats.py
79+
cd nats.py
80+
git clone https://github.com/nats-io/nats.py --branch docs --single-branch docs
81+
cd docs
82+
uv venv
83+
source .venv/bin/activate # or `.venv\Scripts\activate` on Windows
84+
uv pip install sphinx sphinx_autodoc_typehints myst_parser furo pygments
85+
make html
86+
# preview the changes:
87+
make serve
88+
```
89+
90+
If you are happy with the changes, make a PR on the docs branch:
91+
```
92+
make publish
93+
git add docs
94+
```
95+
96+
## Pull Request Guidelines
97+
98+
1. Fork the repository and create your branch from `main`
99+
2. Make sure all tests pass
100+
3. Update documentation if needed
101+
4. Follow the existing code style
102+
5. Write clear commit messages
103+
6. Create a pull request with a clear description of the changes
104+
105+
## License
106+
107+
By contributing to NATS.py, you agree that your contributions will be licensed under the Apache License 2.0.

Makefile

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
REPO_OWNER=nats-io
22
PROJECT_NAME=nats.py
3-
SOURCE_CODE=nats
3+
SOURCE_CODE=nats/src/nats
44

55

66
help:
@@ -13,32 +13,29 @@ help:
1313

1414
clean:
1515
find . -name "*.py[co]" -delete
16+
find . -name "__pycache__" -type d -delete
1617

1718

1819
deps:
19-
pip install pipenv --upgrade
20-
pipenv install --dev
20+
uv sync
2121

2222

2323
format:
24-
yapf -i --recursive $(SOURCE_CODE)
25-
yapf -i --recursive tests
24+
uv run yapf -i --recursive $(SOURCE_CODE)
25+
uv run yapf -i --recursive nats/tests
2626

2727

2828
test:
29-
yapf --recursive --diff $(SOURCE_CODE)
30-
yapf --recursive --diff tests
31-
mypy
32-
flake8 ./nats/js/
33-
pytest
29+
uv run yapf --recursive --diff $(SOURCE_CODE)
30+
uv run yapf --recursive --diff nats/tests
31+
uv run mypy
32+
uv run ruff check $(SOURCE_CODE)
33+
uv run pytest
3434

3535

3636
ci: deps
37-
# pipenv run yapf --recursive --diff $(SOURCE_CODE)
38-
# pipenv run yapf --recursive --diff tests
39-
# pipenv run mypy
40-
pipenv run flake8 --ignore="W391, W503, W504" ./nats/js/
41-
pipenv run pytest -x -vv -s --continue-on-collection-errors
37+
uv run ruff check $(SOURCE_CODE)
38+
uv run pytest -x -vv -s --continue-on-collection-errors
4239

4340
watch:
44-
while true; do pipenv run pytest -v -s -x; sleep 10; done
41+
while true; do uv run pytest -v -s -x; sleep 10; done

Pipfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)