Skip to content

Commit

Permalink
Use uv lockfile and dependencies in pyproject.toml (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles authored Jan 16, 2025
1 parent 686a1aa commit 8183e1b
Show file tree
Hide file tree
Showing 6 changed files with 988 additions and 31 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5

- name: Install artisatomic
run: |
python3 -m pip install uv
python3 -m uv pip install --editable .
uv sync --frozen
source .venv/bin/activate
uv pip install --compile-bytecode --editable .[dev]
- name: Run Ruff
if: always()
Expand All @@ -42,7 +46,18 @@ jobs:

- name: Lint with mypy
run: |
mypy --install-types --non-interactive
uv run --frozen mypy --install-types --non-interactive
- name: Cache pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: |
source .venv/bin/activate
uv run --frozen -- pre-commit run --all-files --show-diff-on-failure --color=always
pytest:
runs-on: macos-15
Expand All @@ -55,10 +70,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5

- name: Install artisatomic
run: |
python3 -m pip install uv
python3 -m uv pip install --compile-bytecode --editable .
uv sync --frozen
uv pip install --compile-bytecode --editable .[dev]
- name: Cache CMFGEN atomic data
uses: actions/cache@v4
Expand All @@ -72,7 +90,7 @@ jobs:
run: source ./setup_cmfgen_data.sh

- name: Test with pytest
run: pytest
run: uv run --frozen python3 -m pytest

tests:
strategy:
Expand All @@ -93,10 +111,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5

- name: Install artisatomic
run: |
python3 -m pip install uv
python3 -m uv pip install --compile-bytecode --editable .
uv sync --frozen
uv pip install --compile-bytecode --editable .[dev]
- name: Cache CMFGEN atomic data
uses: actions/cache@v4
Expand Down Expand Up @@ -130,7 +151,7 @@ jobs:
- name: Generate artis atomic data files
run: |
cp tests/${{ matrix.testname }}/artisatomicionhandlers.json .
makeartisatomicfiles -output_folder tests/${{ matrix.testname }}/output
uv run --frozen makeartisatomicfiles -output_folder tests/${{ matrix.testname }}/output
- name: Checksum output files
working-directory: tests/${{ matrix.testname }}/output
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
hooks:
- id: yamlfmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.3
rev: v0.9.1
hooks:
- id: ruff
args: [--fix]
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@
First clone the repository, for example:
```sh
git clone https://github.com/artis-mcrt/artisatomic.git
cd artistatomic
```
Then from within the repository directory run:

To use a uv project virtual environment with locked dependency versions run:
```sh
python3 -m pip install -e .
uv sync --frozen
source .venv/bin/activate
uv pip install -e .[dev]
```

Tip: if you get an error on macOS >= 11 when installing the dependency 'tables', first run brew install hdf5 c-blosc
Or to install into the system environment with pip:
```sh
python3 -m pip install -e .[dev]
```

## Usage
Run "makeartisatomicfiles" at the command-line to create adata.txt, compositiondata.txt, phixsdata_v2.txt, and transitiondata.txt. This code is not user friendly at all are requires manual editing of the Python scripts to change ions and data sources.
Run "makeartisatomicfiles" at the command-line to create adata.txt, compositiondata.txt, phixsdata_v2.txt, and transitiondata.txt. This code is not user friendly and requires manual editing of the Python scripts to change ions and data sources.

[![Build and test](https://github.com/artis-mcrt/artisatomic/actions/workflows/pythonapp.yml/badge.svg)](https://github.com/artis-mcrt/artisatomic/actions/workflows/pythonapp.yml)
25 changes: 21 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,29 @@ classifiers = [
"Programming Language :: Python :: 3.13",
]
license = { text = "MIT" }
dynamic = ["version", "dependencies"]
dynamic = ["version"]
requires-python = ">=3.10"
readme = { file = "README.md", content-type = 'text/markdown' }
dependencies = [
"argcomplete>=3.5.1",
"chiantipy>=0.15.1",
"h5py>=3.10.0",
"numpy>=1.26.1",
"pandas>=2.2.3",
"polars>=1.12.0",
"pyarrow>=18.1.0",
"scipy>=1.11.3",
"xopen[zstd]>=2.0.2",
]

[project.optional-dependencies]
dev = [
"mypy>=1.13.0",
"pre-commit>=4.0.1",
"pytest>=8.3.3",
"ruff>=0.8.3",
"types-requests>=2.32.0.20241016",
]

[project.urls]
Repository = "https://www.github.com/artis-mcrt/artisatomic"
Expand Down Expand Up @@ -159,9 +179,6 @@ where = ["."]
include = ["*", "**/matplotlibrc", "**/data"]
exclude = ["tests", "**/dist", "**/lib", "**/build", "*.egg-info", "**/.*"]

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }

[tool.setuptools_scm]
write_to = "_version.py"
local_scheme = "no-local-version"
13 changes: 0 additions & 13 deletions requirements.txt

This file was deleted.

Loading

0 comments on commit 8183e1b

Please sign in to comment.