Skip to content

Commit

Permalink
Simplify the project management using uv
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekker1 committed Dec 2, 2024
1 parent 8849c95 commit 37086ac
Show file tree
Hide file tree
Showing 23 changed files with 923 additions and 2,370 deletions.
56 changes: 39 additions & 17 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
python-version: ["3.8", "3.11", "pypy3.10"]
minizinc-version: ["2.8.0", "2.6.0"]
minizinc-version: ["2.8.7", "2.6.0"]

env:
MINIZINC_URL: https://github.com/MiniZinc/MiniZincIDE/releases/download/${{ matrix.minizinc-version }}/MiniZincIDE-${{ matrix.minizinc-version }}-x86_64.AppImage
Expand Down Expand Up @@ -40,34 +40,56 @@ jobs:
sudo curl -o ${{ github.workspace }}/bin/minizinc -L $MINIZINC_URL
sudo chmod +x ${{ github.workspace }}/bin/minizinc
minizinc --version
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --with ci
- name: Test with tox
run: poetry run tox
- name: Install the project
run: uv sync --dev
- name: Run Pytest
run: uv run pytest
- name: Install numpy
run: uv pip install numpy
- name: Run Pytest with numpy
run: uv run pytest

docs:
lints:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install the project
run: uv sync --dev
- name: Check Ruff linter
run: uv run ruff check
- name: Check Ruff formatter
run: uv run ruff format --check
- name: Check MyPy type checker
run: uv run mypy .

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --with ci
- name: Test with tox
run: poetry run tox -e docs
python-version-file: ".python-version"
- name: Install the project
run: uv sync --group docs
- name: Generate the documentation
run: uv run sphinx-build -b html docs dist/docs
- name: Check the documentation doesn't have broken links
run: uv run sphinx-build -b linkcheck docs dist/docs
- uses: actions/upload-artifact@v4
with:
name: documentation
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ profile_default/
ipython_config.py

# pyenv
.python-version
#.python-version

# celery beat schedule file
celerybeat-schedule
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,35 @@ _For more examples, please refer to the
<!-- TESTING INSTRUCTIONS -->
## Testing

MiniZinc Python uses [Tox](https://pypi.org/project/tox/) environments to test
its coding style and functionality. The code style tests are executed using
[Black](https://pypi.org/project/black/),
[Flake8](https://pypi.org/project/flake8/), and
[isort](https://pypi.org/project/isort/). The functionality tests are
constructed using the [PyTest](https://pypi.org/project/pytest/) unit testing framework.

* To install test-suite dependencies, run `poetry install --with dev` (requires installation of [Poetry](https://python-poetry.org))
* To run all tests, simply execute `poetry run tox` in the repository directory.
* Individual environments can be triggered using the `-e` flag.
* To test the coding style of the repository run `poetry run tox -e check`
* The `py3x` environments are used to test a specific Python version; for
example, to test using Python version 3.7 run `poetry run tox -e py37`

Tox can also be used to generate the documentation, `poetry run tox -e docs`, and to
typeset the Python code, `poetry run tox -e format`.
MiniZinc Python uses [uv](https://docs.astral.sh/uv/) to manage its
dependencies. To install the development dependencies run `uv sync --dev`.

Although continuous integration will test any code, it can be convenient to run
the tests locally. The following commands can be used to test the MiniZinc
Python package.

- We use [PyTest](https://docs.pytest.org/en/stable/) to run a suite of unit
tests. You can run these tests by executing:
```bash
uv run pytest
```
- We use [Ruff](https://docs.astral.sh/ruff/) to test against a range of Python
style and performance guidelines. You can run the general linting using:
```bash
uv run ruff check
```
You can format the codebase to be compatible using:
```bash
uv run ruff format
```
(The continous integration will test that the code is correctly formatted using
the `--check` flag.)
- We use [Mypy](https://mypy.readthedocs.io/en/stable/) to check the type
correctness of the codebase (for as far as possible). You can run the type
checking using:
```bash
uv run mypy .
```

<!-- ROADMAP -->
## Roadmap
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@
# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
175 changes: 0 additions & 175 deletions flake.lock

This file was deleted.

35 changes: 0 additions & 35 deletions flake.nix

This file was deleted.

Loading

0 comments on commit 37086ac

Please sign in to comment.