Skip to content

Commit f3c856e

Browse files
committed
Copier update
1 parent 32b494b commit f3c856e

18 files changed

+112
-21
lines changed

.copier-answers.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2-
_commit: afbe5c7
2+
_commit: 2f9f107
33
_src_path: gh:scipp/copier_template
44
description: 'Spectroscopy data reduction for the European Spallation Source '
55
max_python: '3.12'

.github/workflows/ci.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- uses: pre-commit/action@v3.0.1
2828
with:
2929
extra_args: --all-files
30-
- uses: pre-commit-ci/lite-action@v1.0.2
30+
- uses: pre-commit-ci/lite-action@v1.0.3
3131
if: always()
3232
with:
3333
msg: Apply automatic formatting
@@ -46,6 +46,7 @@ jobs:
4646
os-variant: ${{ matrix.os }}
4747
python-version: ${{ matrix.python.version }}
4848
tox-env: ${{ matrix.python.tox-env }}
49+
secrets: inherit
4950

5051
docs:
5152
needs: tests
@@ -54,3 +55,4 @@ jobs:
5455
publish: false
5556
linkcheck: ${{ contains(matrix.variant.os, 'ubuntu') && github.ref == 'refs/heads/main' }}
5657
branch: ${{ github.head_ref == '' && github.ref_name || github.head_ref }}
58+
secrets: inherit

.github/workflows/docs.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ jobs:
4242
docs:
4343
name: Build documentation
4444
runs-on: 'ubuntu-22.04'
45+
env:
46+
ESS_PROTECTED_FILESTORE_USERNAME: ${{ secrets.ESS_PROTECTED_FILESTORE_USERNAME }}
47+
ESS_PROTECTED_FILESTORE_PASSWORD: ${{ secrets.ESS_PROTECTED_FILESTORE_PASSWORD }}
48+
4549
steps:
4650
- run: sudo apt install --yes graphviz pandoc
4751
- uses: actions/checkout@v4
@@ -65,7 +69,7 @@ jobs:
6569
name: docs_html
6670
path: html/
6771

68-
- uses: JamesIves/github-pages-deploy-action@v4.6.0
72+
- uses: JamesIves/github-pages-deploy-action@v4.6.4
6973
if: ${{ inputs.publish }}
7074
with:
7175
branch: gh-pages

.github/workflows/nightly_at_main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ jobs:
3131
os-variant: ${{ matrix.os }}
3232
python-version: ${{ matrix.python.version }}
3333
tox-env: ${{ matrix.python.tox-env }}
34+
secrets: inherit

.github/workflows/nightly_at_release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ jobs:
3838
python-version: ${{ matrix.python.version }}
3939
tox-env: ${{ matrix.python.tox-env }}
4040
checkout_ref: ${{ needs.setup.outputs.release_tag }}
41+
secrets: inherit

.github/workflows/test.yml

+18
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,26 @@ on:
4141
type: string
4242

4343
jobs:
44+
package-test:
45+
runs-on: ${{ inputs.os-variant }}
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
ref: ${{ inputs.checkout_ref }}
51+
- uses: actions/setup-python@v5
52+
with:
53+
python-version: ${{ inputs.python-version }}
54+
- run: python -m pip install --upgrade pip
55+
- run: python -m pip install .
56+
- run: python tests/package_test.py
57+
name: Run package tests
58+
4459
test:
4560
runs-on: ${{ inputs.os-variant }}
61+
env:
62+
ESS_PROTECTED_FILESTORE_USERNAME: ${{ secrets.ESS_PROTECTED_FILESTORE_USERNAME }}
63+
ESS_PROTECTED_FILESTORE_PASSWORD: ${{ secrets.ESS_PROTECTED_FILESTORE_PASSWORD }}
4664

4765
steps:
4866
- uses: actions/checkout@v4

.github/workflows/unpinned.yml

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ jobs:
3838
python-version: ${{ matrix.python.version }}
3939
tox-env: ${{ matrix.python.tox-env }}
4040
checkout_ref: ${{ needs.setup.outputs.release_tag }}
41+
secrets: inherit

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ html
99

1010
# Environments
1111
venv
12+
.venv
1213

1314
# Caches
1415
.clangd/
@@ -20,6 +21,7 @@ __pycache__/
2021
.pytest_cache
2122
.mypy_cache
2223
docs/generated/
24+
.ruff_cache
2325

2426
# Editor settings
2527
.idea/
@@ -38,3 +40,4 @@ docs/generated/
3840
*.cif
3941
*.rcif
4042
*.ort
43+
*.zip

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
3+
rev: v4.6.0
44
hooks:
55
- id: check-added-large-files
66
- id: check-json
@@ -14,22 +14,22 @@ repos:
1414
args: [ --markdown-linebreak-ext=md ]
1515
exclude: '\.svg'
1616
- repo: https://github.com/kynan/nbstripout
17-
rev: 0.6.0
17+
rev: 0.7.1
1818
hooks:
1919
- id: nbstripout
2020
types: [ "jupyter" ]
2121
args: [ "--drop-empty-cells",
2222
"--extra-keys 'metadata.language_info.version cell.metadata.jp-MarkdownHeadingCollapsed cell.metadata.pycharm'" ]
2323
- repo: https://github.com/astral-sh/ruff-pre-commit
24-
rev: v0.4.1
24+
rev: v0.6.2
2525
hooks:
2626
- id: ruff
2727
args: [ --fix ]
2828
types_or: [ python, pyi, jupyter ]
2929
- id: ruff-format
3030
types_or: [ python, pyi ]
3131
- repo: https://github.com/codespell-project/codespell
32-
rev: v2.2.6
32+
rev: v2.3.0
3333
hooks:
3434
- id: codespell
3535
additional_dependencies:

.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

conda/meta.yaml

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ source:
99

1010
{% set pyproject = load_file_data('pyproject.toml') %}
1111
{% set dependencies = pyproject.get('project', {}).get('dependencies', {}) %}
12+
{% set test_dependencies = pyproject.get('project', {}).get('optional-dependencies', {}).get('test', {}) %}
1213

1314

1415
requirements:
@@ -18,16 +19,23 @@ requirements:
1819
run:
1920
- python>=3.10
2021

22+
{# Conda does not allow spaces between package name and version, so remove them #}
2123
{% for package in dependencies %}
22-
- {% if package == "graphviz" %}python-graphviz{% else %}{{ package }}{% endif %}
24+
- {% if package == "graphviz" %}python-graphviz{% else %}{{ package|replace(" ", "") }}{% endif %}
2325
{% endfor %}
2426

2527

2628
test:
2729
imports:
2830
- ess.spectroscopy
2931
requires:
30-
- pytest
32+
33+
{# Conda does not allow spaces between package name and version, so remove them #}
34+
{% for package in test_dependencies %}
35+
- {% if package == "graphviz" %}python-graphviz{% else %}{{ package|replace(" ", "") }}{% endif %}
36+
{% endfor %}
37+
38+
3139
source_files:
3240
- pyproject.toml
3341
- tests/

docs/_templates/doc_version.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<!-- This will display the version of the docs -->
2-
Current {{ project }} version: {{ version }} (<a href="https://github.com/{{orgname}}/{{ project|lower }}/releases">older versions</a>).
2+
Current ESSspectroscopy version: {{ version }} (<a href="https://github.com/scipp/essspectroscopy/releases">older versions</a>).

docs/conf.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
# -*- coding: utf-8 -*-
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
23

34
import doctest
45
import os
56
import sys
7+
from importlib.metadata import PackageNotFoundError
68
from importlib.metadata import version as get_version
79

10+
from sphinx.util import logging
11+
812
sys.path.insert(0, os.path.abspath('.'))
913

14+
logger = logging.getLogger(__name__)
15+
1016
# General information about the project.
1117
project = 'ESSspectroscopy'
1218
copyright = '2024 Scipp contributors'
@@ -34,6 +40,8 @@
3440
import sciline.sphinxext.domain_types # noqa: F401
3541

3642
extensions.append('sciline.sphinxext.domain_types')
43+
# See https://github.com/tox-dev/sphinx-autodoc-typehints/issues/457
44+
suppress_warnings = ["config.cache"]
3745
except ModuleNotFoundError:
3846
pass
3947

@@ -111,8 +119,15 @@
111119
# built documents.
112120
#
113121

114-
release = get_version("essspectroscopy")
115-
version = ".".join(release.split('.')[:3]) # CalVer
122+
try:
123+
release = get_version("essspectroscopy")
124+
version = ".".join(release.split('.')[:3]) # CalVer
125+
except PackageNotFoundError:
126+
logger.info(
127+
"Warning: determining version from package metadata failed, falling back to "
128+
"a dummy version number."
129+
)
130+
release = version = "0.0.0-dev"
116131

117132
warning_is_error = True
118133

pyproject.toml

+16-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ dependencies = [
4141

4242
dynamic = ["version"]
4343

44+
[project.optional-dependencies]
45+
test = [
46+
"pytest",
47+
]
48+
4449
[project.urls]
4550
"Bug Tracker" = "https://github.com/scipp/essspectroscopy/issues"
4651
"Documentation" = "https://scipp.github.io/essspectroscopy"
@@ -71,14 +76,14 @@ extend-exclude = [
7176

7277
[tool.ruff.lint]
7378
# See https://docs.astral.sh/ruff/rules/
74-
select = ["B", "C4", "DTZ", "E", "F", "G", "I", "PERF", "PGH", "PT", "PYI", "RUF", "S", "T20", "W"]
79+
select = ["B", "C4", "DTZ", "E", "F", "G", "I", "PERF", "PGH", "PT", "PYI", "RUF", "S", "T20", "UP", "W"]
7580
ignore = [
7681
# Conflict with ruff format, see
7782
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
7883
"COM812", "COM819", "D206", "D300", "E111", "E114", "E117", "ISC001", "ISC002", "Q000", "Q001", "Q002", "Q003", "W191",
7984
]
80-
fixable = ["I001", "B010"]
81-
isort.known-first-party = ["essspectroscopy"]
85+
fixable = ["B010", "I001", "PT001"]
86+
isort.known-first-party = ["ess.spectroscopy"]
8287
pydocstyle.convention = "numpy"
8388

8489
[tool.ruff.lint.per-file-ignores]
@@ -109,3 +114,11 @@ enable_error_code = [
109114
"truthy-bool",
110115
]
111116
warn_unreachable = true
117+
118+
[tool.codespell]
119+
ignore-words-list = [
120+
# Codespell wants "socioeconomic" which seems to be the standard spelling.
121+
# But we use the word in our code of conduct which is the contributor covenant.
122+
# Let's not modify it if we don't have to.
123+
"socio-economic",
124+
]

requirements/basetest.in

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Dependencies that are only used by tests.
22
# Do not make an environment from this file, use test.txt instead!
3+
# Add more dependencies in the ``test`` list
4+
# under ``[project.optional-dependencies]`` section, in ``pyproject.toml``
35

4-
pytest
6+
# Anything above "--- END OF CUSTOM SECTION ---"
7+
# will not be touched by ``make_base.py``
8+
# --- END OF CUSTOM SECTION ---
9+
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!

requirements/make_base.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import sys
22
from argparse import ArgumentParser
33
from pathlib import Path
4-
from typing import List
54

65
import tomli
76

@@ -20,7 +19,7 @@
2019
"""
2120

2221

23-
def write_dependencies(dependency_name: str, dependencies: List[str]) -> None:
22+
def write_dependencies(dependency_name: str, dependencies: list[str]) -> None:
2423
path = Path(f"{dependency_name}.in")
2524
if path.exists():
2625
sections = path.read_text().split(CUSTOM_AUTO_SEPARATOR)
@@ -43,8 +42,14 @@ def write_dependencies(dependency_name: str, dependencies: List[str]) -> None:
4342
if dependencies is None:
4443
raise RuntimeError("No dependencies found in pyproject.toml")
4544
dependencies = [dep.strip().strip('"') for dep in dependencies]
45+
test_dependencies = (
46+
pyproject["project"].get("optional-dependencies", {}).get("test", [])
47+
)
48+
test_dependencies = [dep.strip().strip('"') for dep in test_dependencies]
49+
4650

4751
write_dependencies("base", dependencies)
52+
write_dependencies("basetest", test_dependencies)
4853

4954

5055
def as_nightly(repo: str) -> str:
@@ -56,7 +61,8 @@ def as_nightly(repo: str) -> str:
5661
version = f"cp{sys.version_info.major}{sys.version_info.minor}"
5762
base = "https://github.com/scipp/scipp/releases/download/nightly/scipp-nightly"
5863
suffix = "manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
59-
return "-".join([base, version, version, suffix])
64+
prefix = "scipp @ "
65+
return prefix + "-".join([base, version, version, suffix])
6066
return f"{repo} @ git+https://github.com/{org}/{repo}@main"
6167

6268

src/ess/spectroscopy/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import importlib.metadata
66

77
try:
8-
__version__ = importlib.metadata.version(__package__ or __name__)
8+
__version__ = importlib.metadata.version("essspectroscopy")
99
except importlib.metadata.PackageNotFoundError:
1010
__version__ = "0.0.0"
1111

tests/package_test.py

+13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
3+
4+
"""Tests of package integrity.
5+
6+
Note that addidional imports need to be added for repositories that
7+
contain multiple packages.
8+
"""
9+
310
from ess import spectroscopy as pkg
411

512

613
def test_has_version():
714
assert hasattr(pkg, '__version__')
15+
16+
17+
# This is for CI package tests. They need to run tests with minimal dependencies,
18+
# that is, without installing pytest. This code does not affect pytest.
19+
if __name__ == '__main__':
20+
test_has_version()

0 commit comments

Comments
 (0)