Skip to content

uv improvements #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Check lockfile
run: uv lock --check
Expand All @@ -31,9 +33,9 @@ jobs:
uses: ts-graphviz/setup-graphviz@v1

- name: Run mypy
run: uv run --python ${{ matrix.python-version }} mypy automata/**/*.py tests/*.py
run: uv run mypy automata/**/*.py tests/*.py

- name: Run ruff
run: |
uv run --python ${{ matrix.python-version }} ruff check .
uv run --python ${{ matrix.python-version }} ruff format --check .
uv run ruff check .
uv run ruff format --check .
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Check lockfile
run: uv lock --check
Expand All @@ -32,8 +34,8 @@ jobs:

- name: Test with nose2
run: |
uv run --python ${{ matrix.python-version }} coverage run -m nose2 tests
uv run --python ${{ matrix.python-version }} coverage lcov -o cover/coverage.lcov
uv run coverage run -m nose2 tests
uv run coverage lcov -o cover/coverage.lcov

- name: Run Coveralls
uses: coverallsapp/github-action@master
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ coverage.xml
nosetests.xml

# Required packages
.venv
.virtualenv
.spyproject

Expand Down
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"python.analysis.extraPaths": [
".virtualenv"
],
"python.analysis.extraPaths": [".virtualenv"],
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
Expand Down
53 changes: 26 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ observe the following guidelines when submitting pull requests for new fixes or
features:

1. All new code must comply with the enabled ruff lint rules.
If you install Automata with `virtualenv`, the `ruff`
If you install Automata dependencies with [`uv`](https://github.com/astral-sh/uv), the `ruff`
package should be available to you for this purpose with the config in `pyproject.toml`.
The included VSCode configuration is set to run this formatting on save.

Expand All @@ -41,7 +41,7 @@ In addition, new code must include type annotations and pass typechecking run wi
2. Whether you are introducing a bug fix or a new feature, you *must* add tests
to verify that your code additions function correctly and break nothing else.

3. Please run `coverage run -m nose2 && coverage report` and ensure that your
3. Please run `uv run coverage run -m nose2 && uv run coverage report` and ensure that your
changes are covered.

4. If you are adding a new feature or changing behavior, please
Expand All @@ -52,30 +52,35 @@ run the documentation site locally, install the documentation dependencies
with:

```sh
pip install -r requirements.dev.txt
uv sync --group docs
```

Then, start the local server with the following command:

```sh
mkdocs serve
uv run mkdocs serve
```


### Configuring a virtualenv
### Setting up your environment

The dependencies for the project and best run inside a `virtualenv`. For
instructions on how to configure virtual environments in Python, please see the
[Virtual Environments](https://docs.python-guide.org/dev/virtualenvs/)
section of the Hitchhiker's Guide to Python.
The dependencies for the project are best managed with [`uv`][uv]. For
instructions on how to install `uv`, see the [uv documentation][installation].

### Installing project dependencies
[uv]: https://github.com/astral-sh/uv
[installation]: https://github.com/astral-sh/uv#installation

You can install all project dependencies via `pip` (assuming your project
virtualenv is active):
To create a virtual environment and install all project dependencies (including
dev dependencies), run:

```sh
pip install -r requirements.txt
uv sync
```

To install all dependencies related to the documentation site, run:

```sh
uv sync --group docs
```

#### Troubleshooting pygraphviz
Expand All @@ -85,23 +90,17 @@ installing dependencies, try running:

```sh
brew install graphviz
python3 -m pip install -U --no-cache-dir \
--config-settings="--global-option=build_ext" \
--config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \
--config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \
pygraphviz==1.10
# Proceed to install other dependencies
pip install -r requirements.txt
# Proceed to install dependencies
uv sync
```

### Running unit tests

The project's unit tests are written using [unittest][unittest] and run using
the [nose2][nose2] Python package. You can run all unit tests via the `nose2`
command.
the [nose2][nose2] Python package. You can run all unit tests via the following command:

```sh
nose2
uv run nose2
```

[unittest]: https://docs.python.org/3/library/unittest.html
Expand All @@ -111,17 +110,17 @@ nose2

The project currently boasts high code coverage across all source files. New
contributions are expected to maintain this high standard. You can view the
current coverage report via the `coverage` command:
current coverage report via the following commands:

```sh
coverage run -m nose2
coverage report
uv run coverage run -m nose2
uv run coverage report
```

If the coverage ever decreases, you can generate and open a detailed HTML view
of the coverage report like so:

```sh
coverage html
uv run coverage html
open htmlcov/index.html
```
14 changes: 4 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ keywords = [
]
license = "MIT"
license-files = ["LICENSE.txt"]
authors = [{ name = 'Caleb Evans', email = '[email protected]' }]
authors = [{ name = "Caleb Evans", email = "[email protected]" }]
maintainers = [
{ name = 'Caleb Evans', email = '[email protected]' },
{ name = 'Eliot W. Robson', email = '[email protected]' },
{ name = "Caleb Evans", email = "[email protected]" },
{ name = "Eliot W. Robson", email = "[email protected]" },
]
dependencies = [
"networkx>=2.6.2",
Expand All @@ -41,11 +41,7 @@ classifiers = [

# Per https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies
[project.optional-dependencies]
visual = [
"coloraide>=1.8.2",
"manim>=0.19.0",
"pygraphviz>=1.10",
]
visual = ["coloraide>=1.8.2", "manim>=0.19.0", "pygraphviz>=1.10"]

[tool.setuptools.package-data]
"automata" = ["py.typed"]
Expand Down Expand Up @@ -119,8 +115,6 @@ select = [
"I",
# Perflint
"PERF",
# flake8-executable
"EXE",
]


Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading