diff --git a/.copier-answers.yml b/.copier-answers.yml index e2acb8e..4857cf8 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: 101e594 +_commit: 75b9a8f _src_path: gh:scipp/copier_template description: Reflectometry data reduction for the European Spallation Source max_python: '3.12' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8234bc9..356700a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - uses: pre-commit/action@v3.0.1 with: extra_args: --all-files - - uses: pre-commit-ci/lite-action@v1.0.2 + - uses: pre-commit-ci/lite-action@v1.0.3 if: always() with: msg: Apply automatic formatting diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a5ea2b0..c6a413e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -69,7 +69,7 @@ jobs: name: docs_html path: html/ - - uses: JamesIves/github-pages-deploy-action@v4.6.3 + - uses: JamesIves/github-pages-deploy-action@v4.6.4 if: ${{ inputs.publish }} with: branch: gh-pages diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 373ea4a..e98ed7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,6 +41,21 @@ on: type: string jobs: + package-test: + runs-on: ${{ inputs.os-variant }} + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.checkout_ref }} + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + - run: python -m pip install --upgrade pip + - run: python -m pip install . + - run: python tests/package_test.py + name: Run package tests + test: runs-on: ${{ inputs.os-variant }} env: diff --git a/.gitignore b/.gitignore index 46c5ae8..cc2a0f8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,11 +4,13 @@ dist html .tox *.egg-info +uv.lock # we lock dependencies with pip-compile, not uv *.sw? # Environments venv +.venv # Caches .clangd/ @@ -39,3 +41,4 @@ docs/generated/ *.cif *.rcif *.ort +*.zip diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4442b1b..e0c499e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-added-large-files - id: check-json @@ -14,14 +14,14 @@ repos: args: [ --markdown-linebreak-ext=md ] exclude: '\.svg' - repo: https://github.com/kynan/nbstripout - rev: 0.6.0 + rev: 0.7.1 hooks: - id: nbstripout types: [ "jupyter" ] args: [ "--drop-empty-cells", "--extra-keys 'metadata.language_info.version cell.metadata.jp-MarkdownHeadingCollapsed cell.metadata.pycharm'" ] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.3 + rev: v0.6.2 hooks: - id: ruff args: [ --fix ] @@ -29,7 +29,7 @@ repos: - id: ruff-format types_or: [ python, pyi ] - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell additional_dependencies: diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..c8cfe39 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.10 diff --git a/conda/meta.yaml b/conda/meta.yaml index e0aa9f3..77f5ef8 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -9,6 +9,7 @@ source: {% set pyproject = load_file_data('pyproject.toml') %} {% set dependencies = pyproject.get('project', {}).get('dependencies', {}) %} +{% set test_dependencies = pyproject.get('project', {}).get('optional-dependencies', {}).get('test', {}) %} requirements: @@ -31,6 +32,13 @@ test: requires: - pytest - pooch + + {# Conda does not allow spaces between package name and version, so remove them #} + {% for package in test_dependencies %} + - {% if package == "graphviz" %}python-graphviz{% else %}{{ package|replace(" ", "") }}{% endif %} + {% endfor %} + + source_files: - pyproject.toml - tests/ diff --git a/docs/conf.py b/docs/conf.py index 87f9a76..ea46cb5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2024 Scipp contributors (https://github.com/scipp) + import doctest import os import sys diff --git a/pyproject.toml b/pyproject.toml index 97a504b..4c8504c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,12 @@ dependencies = [ dynamic = ["version"] +[project.optional-dependencies] +test = [ + "pytest", + "pooch", +] + [project.urls] "Bug Tracker" = "https://github.com/scipp/essreflectometry/issues" "Documentation" = "https://scipp.github.io/essreflectometry" @@ -82,8 +88,8 @@ ignore = [ # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules "COM812", "COM819", "D206", "D300", "E111", "E114", "E117", "ISC001", "ISC002", "Q000", "Q001", "Q002", "Q003", "W191", ] -fixable = ["I001", "B010"] -isort.known-first-party = ["essreflectometry"] +fixable = ["B010", "I001", "PT001"] +isort.known-first-party = ["ess.reflectometry"] pydocstyle.convention = "numpy" [tool.ruff.lint.per-file-ignores] @@ -114,3 +120,11 @@ enable_error_code = [ "truthy-bool", ] warn_unreachable = true + +[tool.codespell] +ignore-words-list = [ + # Codespell wants "socioeconomic" which seems to be the standard spelling. + # But we use the word in our code of conduct which is the contributor covenant. + # Let's not modify it if we don't have to. + "socio-economic", +] diff --git a/requirements/base.txt b/requirements/base.txt index 547161f..3f6d2a5 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -19,11 +19,11 @@ cyclebane==24.6.0 # via sciline cycler==0.12.1 # via matplotlib -dask==2024.8.2 +dask==2024.9.0 # via -r base.in decorator==5.1.1 # via ipython -essreduce==24.9.0 +essreduce==24.9.1 # via -r base.in exceptiongroup==1.2.2 # via ipython @@ -31,7 +31,7 @@ executing==2.1.0 # via stack-data fonttools==4.53.1 # via matplotlib -fsspec==2024.6.1 +fsspec==2024.9.0 # via dask graphviz==0.20.3 # via -r base.in @@ -39,7 +39,7 @@ h5py==3.11.0 # via # scippneutron # scippnexus -importlib-metadata==8.4.0 +importlib-metadata==8.5.0 # via dask ipydatawidgets==4.3.5 # via pythreejs @@ -53,7 +53,7 @@ jedi==0.19.1 # via ipython jupyterlab-widgets==3.0.13 # via ipywidgets -kiwisolver==1.4.6 +kiwisolver==1.4.7 # via matplotlib locket==1.0.0 # via partd @@ -92,7 +92,7 @@ pexpect==4.9.0 # via ipython pillow==10.4.0 # via matplotlib -plopp==24.6.0 +plopp==24.9.1 # via # -r base.in # scippneutron @@ -127,9 +127,9 @@ scipp==24.9.1 # essreduce # scippneutron # scippnexus -scippneutron==24.8.0 +scippneutron==24.9.0 # via -r base.in -scippnexus==24.8.1 +scippnexus==24.9.0 # via # essreduce # scippneutron @@ -163,5 +163,5 @@ wcwidth==0.2.13 # via prompt-toolkit widgetsnbextension==4.0.13 # via ipywidgets -zipp==3.20.1 +zipp==3.20.2 # via importlib-metadata diff --git a/requirements/basetest.in b/requirements/basetest.in index 86467f4..763960e 100644 --- a/requirements/basetest.in +++ b/requirements/basetest.in @@ -1,5 +1,11 @@ # Dependencies that are only used by tests. # Do not make an environment from this file, use test.txt instead! +# Add more dependencies in the ``test`` list +# under ``[project.optional-dependencies]`` section, in ``pyproject.toml`` +# Anything above "--- END OF CUSTOM SECTION ---" +# will not be touched by ``make_base.py`` +# --- END OF CUSTOM SECTION --- +# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY! pytest pooch diff --git a/requirements/basetest.txt b/requirements/basetest.txt index 5259d8e..6b41e80 100644 --- a/requirements/basetest.txt +++ b/requirements/basetest.txt @@ -11,7 +11,7 @@ charset-normalizer==3.3.2 # via requests exceptiongroup==1.2.2 # via pytest -idna==3.8 +idna==3.10 # via requests iniconfig==2.0.0 # via pytest @@ -19,17 +19,17 @@ packaging==24.1 # via # pooch # pytest -platformdirs==4.2.2 +platformdirs==4.3.6 # via pooch pluggy==1.5.0 # via pytest pooch==1.8.2 # via -r basetest.in -pytest==8.3.2 +pytest==8.3.3 # via -r basetest.in requests==2.32.3 # via pooch tomli==2.0.1 # via pytest -urllib3==2.2.2 +urllib3==2.2.3 # via requests diff --git a/requirements/ci.txt b/requirements/ci.txt index 07ac45f..28ed239 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -17,7 +17,7 @@ colorama==0.4.6 # via tox distlib==0.3.8 # via virtualenv -filelock==3.15.4 +filelock==3.16.1 # via # tox # virtualenv @@ -25,20 +25,20 @@ gitdb==4.0.11 # via gitpython gitpython==3.1.43 # via -r ci.in -idna==3.8 +idna==3.10 # via requests packaging==24.1 # via # -r ci.in # pyproject-api # tox -platformdirs==4.2.2 +platformdirs==4.3.6 # via # tox # virtualenv pluggy==1.5.0 # via tox -pyproject-api==1.7.1 +pyproject-api==1.7.2 # via tox requests==2.32.3 # via -r ci.in @@ -48,9 +48,9 @@ tomli==2.0.1 # via # pyproject-api # tox -tox==4.18.0 +tox==4.19.0 # via -r ci.in -urllib3==2.2.2 +urllib3==2.2.3 # via requests -virtualenv==20.26.3 +virtualenv==20.26.5 # via tox diff --git a/requirements/dev.txt b/requirements/dev.txt index 5aad6e7..3c90233 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -26,7 +26,7 @@ arrow==1.3.0 # via isoduration async-lru==2.0.4 # via jupyterlab -cffi==1.17.0 +cffi==1.17.1 # via argon2-cffi-bindings copier==9.3.1 # via -r dev.in @@ -87,9 +87,9 @@ prometheus-client==0.20.0 # via jupyter-server pycparser==2.22 # via cffi -pydantic==2.8.2 +pydantic==2.9.2 # via copier -pydantic-core==2.20.1 +pydantic-core==2.23.4 # via pydantic python-json-logger==2.0.7 # via jupyter-events @@ -115,7 +115,7 @@ terminado==0.18.1 # jupyter-server-terminals toposort==1.10 # via pip-compile-multi -types-python-dateutil==2.9.0.20240821 +types-python-dateutil==2.9.0.20240906 # via arrow uri-template==1.3.0 # via jsonschema diff --git a/requirements/docs.txt b/requirements/docs.txt index 266054f..058beb0 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -10,6 +10,8 @@ accessible-pygments==0.0.5 # via pydata-sphinx-theme alabaster==1.0.0 # via sphinx +appnope==0.1.4 + # via ipykernel attrs==24.2.0 # via # jsonschema @@ -40,7 +42,7 @@ docutils==0.21.2 # sphinx fastjsonschema==2.20.0 # via nbformat -idna==3.8 +idna==3.10 # via requests imagesize==1.4.1 # via sphinx @@ -56,7 +58,7 @@ jsonschema==4.23.0 # via nbformat jsonschema-specifications==2023.12.1 # via jsonschema -jupyter-client==8.6.2 +jupyter-client==8.6.3 # via # ipykernel # nbclient @@ -77,7 +79,7 @@ markupsafe==2.1.5 # via # jinja2 # nbconvert -mdit-py-plugins==0.4.1 +mdit-py-plugins==0.4.2 # via myst-parser mdurl==0.1.2 # via markdown-it-py @@ -100,7 +102,7 @@ nest-asyncio==1.6.0 # via ipykernel pandocfilters==1.5.1 # via nbconvert -platformdirs==4.2.2 +platformdirs==4.3.6 # via # jupyter-core # pooch @@ -139,7 +141,7 @@ sphinx==8.0.2 # sphinx-autodoc-typehints # sphinx-copybutton # sphinx-design -sphinx-autodoc-typehints==2.3.0 +sphinx-autodoc-typehints==2.4.3 # via -r docs.in sphinx-copybutton==0.5.2 # via -r docs.in @@ -165,7 +167,7 @@ tornado==6.4.1 # via # ipykernel # jupyter-client -urllib3==2.2.2 +urllib3==2.2.3 # via requests webencodings==0.5.1 # via diff --git a/requirements/make_base.py b/requirements/make_base.py index 493ede1..7e8f2d1 100644 --- a/requirements/make_base.py +++ b/requirements/make_base.py @@ -42,8 +42,14 @@ def write_dependencies(dependency_name: str, dependencies: list[str]) -> None: if dependencies is None: raise RuntimeError("No dependencies found in pyproject.toml") dependencies = [dep.strip().strip('"') for dep in dependencies] + test_dependencies = ( + pyproject["project"].get("optional-dependencies", {}).get("test", []) + ) + test_dependencies = [dep.strip().strip('"') for dep in test_dependencies] + write_dependencies("base", dependencies) +write_dependencies("basetest", test_dependencies) def as_nightly(repo: str) -> str: @@ -54,7 +60,7 @@ def as_nightly(repo: str) -> str: if repo == "scipp": version = f"cp{sys.version_info.major}{sys.version_info.minor}" base = "https://github.com/scipp/scipp/releases/download/nightly/scipp-nightly" - suffix = "manylinux_2_17_x86_64.manylinux2014_x86_64.whl" + suffix = "macosx_11_0_arm64.whl" prefix = "scipp @ " return prefix + "-".join([base, version, version, suffix]) return f"{repo} @ git+https://github.com/{org}/{repo}@main" diff --git a/requirements/nightly.txt b/requirements/nightly.txt index 7d114d1..5d7d372 100644 --- a/requirements/nightly.txt +++ b/requirements/nightly.txt @@ -1,4 +1,4 @@ -# SHA1:e9966047ff7ccde31021cec89e7c13d1677ca1b4 +# SHA1:0af7fc51570a096d3691f8d20dbe33dfd8fd396f # # This file is autogenerated by pip-compile-multi # To update, run: @@ -20,17 +20,17 @@ cyclebane==24.6.0 # via sciline cycler==0.12.1 # via matplotlib -dask==2024.8.2 +dask==2024.9.0 # via -r nightly.in decorator==5.1.1 # via ipython -essreduce==24.9.0 +essreduce==24.9.1 # via -r nightly.in executing==2.1.0 # via stack-data fonttools==4.53.1 # via matplotlib -fsspec==2024.6.1 +fsspec==2024.9.0 # via dask graphviz==0.20.3 # via -r nightly.in @@ -38,7 +38,7 @@ h5py==3.11.0 # via # scippneutron # scippnexus -importlib-metadata==8.4.0 +importlib-metadata==8.5.0 # via dask ipydatawidgets==4.3.5 # via pythreejs @@ -52,7 +52,7 @@ jedi==0.19.1 # via ipython jupyterlab-widgets==3.0.13 # via ipywidgets -kiwisolver==1.4.6 +kiwisolver==1.4.7 # via matplotlib locket==1.0.0 # via partd @@ -159,5 +159,5 @@ wcwidth==0.2.13 # via prompt-toolkit widgetsnbextension==4.0.13 # via ipywidgets -zipp==3.20.1 +zipp==3.20.2 # via importlib-metadata diff --git a/requirements/static.txt b/requirements/static.txt index 85da246..d7f3ca4 100644 --- a/requirements/static.txt +++ b/requirements/static.txt @@ -9,17 +9,17 @@ cfgv==3.4.0 # via pre-commit distlib==0.3.8 # via virtualenv -filelock==3.15.4 +filelock==3.16.1 # via virtualenv -identify==2.6.0 +identify==2.6.1 # via pre-commit nodeenv==1.9.1 # via pre-commit -platformdirs==4.2.2 +platformdirs==4.3.6 # via virtualenv pre-commit==3.8.0 # via -r static.in pyyaml==6.0.2 # via pre-commit -virtualenv==20.26.3 +virtualenv==20.26.5 # via pre-commit diff --git a/requirements/wheels.txt b/requirements/wheels.txt index a1fa46e..2444744 100644 --- a/requirements/wheels.txt +++ b/requirements/wheels.txt @@ -5,7 +5,7 @@ # # pip-compile-multi # -build==1.2.1 +build==1.2.2 # via -r wheels.in packaging==24.1 # via build diff --git a/src/ess/reflectometry/__init__.py b/src/ess/reflectometry/__init__.py index 10ed1b8..d0ec032 100644 --- a/src/ess/reflectometry/__init__.py +++ b/src/ess/reflectometry/__init__.py @@ -8,7 +8,7 @@ from .load import load_reference, save_reference try: - __version__ = importlib.metadata.version(__package__ or __name__) + __version__ = importlib.metadata.version("essreflectometry") except importlib.metadata.PackageNotFoundError: __version__ = "0.0.0" diff --git a/tests/package_test.py b/tests/package_test.py index 6490b19..693ce86 100644 --- a/tests/package_test.py +++ b/tests/package_test.py @@ -1,7 +1,20 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2024 Scipp contributors (https://github.com/scipp) + +"""Tests of package integrity. + +Note that addidional imports need to be added for repositories that +contain multiple packages. +""" + from ess import reflectometry as pkg def test_has_version(): assert hasattr(pkg, '__version__') + + +# This is for CI package tests. They need to run tests with minimal dependencies, +# that is, without installing pytest. This code does not affect pytest. +if __name__ == '__main__': + test_has_version()