Skip to content
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
7 changes: 3 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN DEBIAN_FRONTEND=noninteractive \
libffi-dev \
liblzma-dev

# Python and poetry installation
# Python and uv installation
USER $USER
ARG HOME="/home/$USER"
ARG PYTHON_VERSION=3.11
Expand All @@ -41,6 +41,5 @@ RUN echo "linux installed" \
&& pyenv install ${PYTHON_VERSION} \
&& echo "python installed" \
&& pyenv global ${PYTHON_VERSION} \
&& curl -sSL https://install.python-poetry.org | python3 - \
&& echo "poetry installed" \
&& poetry config virtualenvs.in-project true
&& curl -LsSf https://astral.sh/uv/install.sh | sh \
&& echo "uv installed"
8 changes: 1 addition & 7 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"features": {
"ghcr.io/devcontainers-extra/features/poetry:2": {
"version": "2.0.18",
"resolved": "ghcr.io/devcontainers-extra/features/poetry@sha256:7b5f2c66d25d8b3cc5d601af6b81b720c77dd315f24d5e6f84b342cccc3c9228",
"integrity": "sha256:7b5f2c66d25d8b3cc5d601af6b81b720c77dd315f24d5e6f84b342cccc3c9228"
}
}
"features": {}
}
8 changes: 3 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "poetry3-poetry-pyenv-mdopt",
"name": "mdopt",
"build": {
"dockerfile": "Dockerfile"
},
Expand All @@ -11,7 +11,7 @@
// "forwardPorts": [],

// 👇 Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "poetry install --with dev,test,docs",
"postCreateCommand": "uv sync --group dev --group test --group docs",

// 👇 Configure tool-specific properties.
"customizations": {
Expand All @@ -23,9 +23,7 @@
]
}
},
"features": {
"ghcr.io/devcontainers-extra/features/poetry:2": {}
}
"features": {}

// 👇 Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
Expand Down
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Additionally, make sure any new code is properly accompanied by working through
- [ ] All other tests still pass (when running ``pytest`` in the root directory)
- [ ] Any functions added have [``numpy`` style docstrings](http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html)
- [ ] If suitable, funtionality is documented in ``docs`` or an example added in ``examples``
- [ ] The code is linted with ``black``.
- [ ] The code is formatted with ``ruff format``.


# Contributor Covenant Code of Conduct
Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ updates:
schedule:
interval: "daily"

# Maintain dependencies for Poetry
- package-ecosystem: "pip"
# Maintain dependencies in pyproject.toml and uv.lock
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "daily"
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ jobs:
uses: actions/checkout@v7
- name: 'Dependency Review'
uses: actions/dependency-review-action@v5
with:
# diskcache <= 5.6.3 unpickles cache files, so anyone who can write
# to the cache directory can run code (CVE-2025-69872). No fixed
# release exists. qldpc imports it at module level (qldpc.cache,
# loaded by qldpc.codes), so it cannot be dropped. Remove this entry
# once diskcache ships a fix or qldpc stops requiring it.
allow-ghsas: GHSA-w8v5-vhqr-4h9v
13 changes: 5 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: Set up Python 3.11
uses: actions/setup-python@v7
- name: Set up uv and Python 3.11
uses: astral-sh/setup-uv@v10.1.0
with:
python-version: '3.11'

- name: Set up Poetry
run: pip install poetry
python-version: '3.11'

- name: Install dependencies
run: poetry install --with dev
run: uv sync --locked --group dev

- name: Run linter
run: poetry run pylint mdopt --fail-under=9
run: uv run pylint mdopt --fail-under=9
13 changes: 5 additions & 8 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: Set up Python 3.11
uses: actions/setup-python@v7
- name: Set up uv and Python 3.11
uses: astral-sh/setup-uv@v10.1.0
with:
python-version: '3.11'

- name: Set up Poetry
run: pip install poetry
python-version: '3.11'

- name: Install dependencies
run: poetry install --with dev
run: uv sync --locked --group dev

- name: Run mypy
run: poetry run mypy mdopt
run: uv run mypy mdopt
14 changes: 6 additions & 8 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ on:
- "mdopt/**"
- "scripts/run_notebooks.py"
- "pyproject.toml"
- "poetry.lock"
- "uv.lock"
- ".github/workflows/notebooks.yml"
pull_request:
paths:
- "examples/**/*.ipynb"
- "mdopt/**"
- "scripts/run_notebooks.py"
- "pyproject.toml"
- "poetry.lock"
- "uv.lock"
- ".github/workflows/notebooks.yml"
workflow_dispatch:

Expand All @@ -51,7 +51,8 @@ jobs:
steps:
- uses: actions/checkout@v7

- uses: actions/setup-python@v7
- name: Set up uv and Python 3.11
uses: astral-sh/setup-uv@v10.1.0
with:
python-version: "3.11"

Expand All @@ -65,15 +66,12 @@ jobs:
texlive-latex-base texlive-latex-extra texlive-fonts-recommended \
cm-super dvipng ghostscript

- name: Set up Poetry
run: pip install poetry

# The dev group carries ipykernel, nbclient, nbformat and matplotlib.
- name: Install package and notebook dependencies
run: poetry install --with dev
run: uv sync --locked --group dev

- name: Execute notebooks
env:
MDOPT_NB_FAST: "1"
MPLBACKEND: Agg
run: poetry run python scripts/run_notebooks.py
run: uv run python scripts/run_notebooks.py
11 changes: 4 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: Set up Python 3.11
uses: actions/setup-python@v7
- name: Set up uv and Python 3.11
uses: astral-sh/setup-uv@v10.1.0
with:
python-version: '3.11'

- name: Set up Poetry
run: pip install poetry

- name: Install dependencies
run: poetry install --with test
run: uv sync --locked --group test

- name: Generate report
run: |
poetry run pytest --cov=./ --cov-report=xml -W ignore::DeprecationWarning
uv run pytest --cov=./ --cov-report=xml -W ignore::DeprecationWarning

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v7
Expand Down
19 changes: 12 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ repos:
rev: v6.0.0
hooks:
- id: check-added-large-files
# uv.lock is generated and larger than the 500 KB default.
exclude: ^uv\.lock$
- id: check-docstring-first
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: detect-private-key
- id: trailing-whitespace

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.5.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.7
hooks:
- id: black
entry: black .
- id: ruff-format

- repo: local
hooks:
Expand All @@ -38,7 +39,11 @@ repos:
- id: mypy
exclude: '(^examples|^docs|^mdopt/examples)/.*'

- repo: https://github.com/python-poetry/poetry
rev: 2.4.1
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.12.13
hooks:
- id: poetry-check
# Fails when uv.lock is out of date with pyproject.toml.
- id: uv-lock
# Keeps requirements.txt (read by readthedocs) in step with uv.lock.
- id: uv-export
args: ["--frozen", "--no-default-groups", "--no-emit-project", "--output-file=requirements.txt", "--quiet"]
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ To install the current release, use the package manager [pip](https://pip.pypa.i
pip install mdopt
```

Otherwise, you can clone the repository and use [poetry](https://python-poetry.org/).
Otherwise, you can clone the repository and use [uv](https://docs.astral.sh/uv/).

```bash
poetry install
uv sync
```

`uv sync --group dev --group test` also installs the development and test tools.

### A note on NumPy's BLAS on Apple silicon

On Apple silicon running macOS 14 or later, pip installs the NumPy and
Expand Down Expand Up @@ -61,6 +63,16 @@ pip download "scipy==$(python -c 'import scipy; print(scipy.__version__)')" \
pip install --force-reinstall --no-deps /tmp/openblas-wheels/*.whl
```

In a uv checkout, a reinstall like this lasts only until the next `uv run`
or `uv sync`, which put the locked Accelerate wheels back. Sync against a
macOS 13 target instead (adding your usual `--group` flags). It selects the
same OpenBLAS wheels, and later `uv run` and `uv sync` calls keep them. Run
it again whenever the lock moves NumPy or SciPy to a new version:

```bash
uv sync --python-platform aarch64-apple-darwin
```

Set `MDOPT_ALLOW_ACCELERATE=1` to silence the warning if you must keep
Accelerate. Use `OMP_NUM_THREADS=1` (or `OPENBLAS_NUM_THREADS=1`) for the
per-process BLAS of worker pools.
Expand Down Expand Up @@ -190,11 +202,11 @@ Developers may find the following guidelines useful:
```

- **Coding style.**
The project follows the [Black](https://black.readthedocs.io/en/stable/) code style.
Please run Black before submitting a pull request:
The code is formatted with [Ruff](https://docs.astral.sh/ruff/formatter/), whose style matches Black's.
Please run the formatter before submitting a pull request:

```bash
black .
uv run --group dev ruff format .
```

- **Pre-commit hooks.**
Expand Down
14 changes: 8 additions & 6 deletions docs/source/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ To install the current release, use the package manager
pip install mdopt

Otherwise, you can clone the repository and use
`poetry <https://python-poetry.org/>`__.
`uv <https://docs.astral.sh/uv/>`__.

.. code:: bash

poetry install
uv sync

``uv sync --group dev --group test`` also installs the development and test tools.

Minimal example
---------------
Expand Down Expand Up @@ -199,13 +201,13 @@ Developers may find the following guidelines useful:

./generate_docs.sh

- **Coding style.** The project follows the
`Black <https://black.readthedocs.io/en/stable/>`__ code style. Please
run Black before submitting a pull request:
- **Coding style.** The code is formatted with
`Ruff <https://docs.astral.sh/ruff/formatter/>`__, whose style matches
Black's. Please run the formatter before submitting a pull request:

.. code:: bash

black .
uv run --group dev ruff format .

- **Pre-commit hooks.** `Pre-commit <https://pre-commit.com/>`__ hooks
are configured to enforce consistent style automatically. To enable
Expand Down
4 changes: 2 additions & 2 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Contributing
We welcome contributions of all sizes! Before opening a pull request, please:

1. Run the test suite (see :doc:`testing`).
2. Follow the **Black** code style:
2. Format the code with **Ruff**:

.. code-block:: bash

black .
uv run --group dev ruff format .

3. Install pre-commit hooks:

Expand Down
4 changes: 2 additions & 2 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ You can install the package from PyPI:

pip install mdopt

Or, alternatively, from source using Poetry:
Or, alternatively, from source using uv:

.. code-block:: bash

git clone https://github.com/quicophy/mdopt.git
cd mdopt
poetry install
uv sync

Minimal example
---------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ We use ``pytest`` for tests. From the project root:
.. code-block:: bash

pytest
# or, if installed with poetry:
poetry run pytest
# or, from a uv checkout:
uv run --group test pytest

Tips
----
Expand Down
Loading
Loading