Skip to content

Commit 513d70d

Browse files
authored
Merge pull request #164 from mraspaud/hatch
Switch to hatchling
2 parents ada9fe2 + a9cbe70 commit 513d70d

9 files changed

Lines changed: 156 additions & 3102 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast: true
1313
matrix:
1414
os: ["ubuntu-latest"]
15-
python-version: ["3.10", "3.11", "3.12"]
15+
python-version: ["3.11", "3.12", "3.13"]
1616
experimental: [false]
1717
include:
1818
- python-version: "3.12"
@@ -29,15 +29,16 @@ jobs:
2929
- name: Checkout source
3030
uses: actions/checkout@v5
3131

32-
- name: Setup Conda Environment
33-
uses: conda-incubator/setup-miniconda@v3
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v5
3434
with:
35-
miniconda-version: "latest"
3635
python-version: ${{ matrix.python-version }}
37-
mamba-version: "*"
38-
channels: conda-forge,defaults
39-
environment-file: continuous_integration/environment.yaml
40-
activate-environment: test-environment
36+
37+
- name: Install dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
python -m pip install --group test
41+
python -m pip install -e .[all]
4142
4243
- name: Install unstable dependencies
4344
if: matrix.experimental == true
@@ -52,10 +53,6 @@ jobs:
5253
git+https://github.com/pytroll/pytroll-schedule \
5354
git+https://github.com/pytroll/trollsift;
5455
55-
- name: Install pytroll-collectors
56-
run: |
57-
pip install --no-deps -e .
58-
5956
- name: Run unit tests
6057
shell: bash -l {0}
6158
run: |
@@ -65,7 +62,7 @@ jobs:
6562
uses: codecov/codecov-action@v5
6663
with:
6764
flags: unittests
68-
file: ./coverage.xml
65+
files: ./coverage.xml
6966
env_vars: OS,PYTHON_VERSION,UNSTABLE
7067
fail_ci_if_error: false
7168

.github/workflows/deploy.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy sdist and wheel
2+
3+
on:
4+
push:
5+
pull_request:
6+
release:
7+
types:
8+
- published
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout source
16+
uses: actions/checkout@v5
17+
18+
- name: Create sdist and wheel
19+
shell: bash -l {0}
20+
run: |
21+
python -m pip install -q build
22+
python -m build
23+
24+
- name: Publish package to PyPI
25+
if: github.event.action == 'published'
26+
uses: pypa/gh-action-pypi-publish@v1.13.0
27+
with:
28+
user: __token__
29+
password: ${{ secrets.pypi_password }}

.pre-commit-config.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
exclude: '^$'
1+
exclude: "^$"
22
fail_fast: false
33
repos:
4-
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v2.2.3
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
# Ruff version.
6+
rev: "v0.12.11"
67
hooks:
7-
- id: flake8
8-
additional_dependencies: [flake8-docstrings, flake8-debugger, flake8-bugbear]
8+
- id: ruff
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v6.0.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer

pyproject.toml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
[build-system]
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "pytroll-collectors"
7+
dynamic = ["version"]
8+
description = "Pytroll data collectors"
9+
readme = "README.md"
10+
license = "GPL-3.0-or-later"
11+
license-files = ["LICENSE"]
12+
requires-python = ">=3.11"
13+
authors = [
14+
{ name = "Martin Raspaud", email = "martin.raspaud@smhi.se" },
15+
]
16+
classifiers = [
17+
"Development Status :: 3 - Alpha",
18+
"Intended Audience :: Science/Research",
19+
"Operating System :: OS Independent",
20+
"Programming Language :: Python",
21+
"Topic :: Scientific/Engineering",
22+
]
23+
dependencies = [
24+
"posttroll>=1.3.0",
25+
"pyyaml",
26+
"trollsift",
27+
]
28+
29+
[project.optional-dependencies]
30+
all = [
31+
"fsspec",
32+
"netifaces",
33+
"pyresample",
34+
"python-dateutil",
35+
"pytroll-schedule",
36+
"s3fs",
37+
"watchdog!=4.0.0",
38+
]
39+
geographic_gatherer = [
40+
"pyresample",
41+
"pytroll-schedule",
42+
"watchdog!=4.0.0",
43+
]
44+
s3_segment_gatherer = [
45+
"fsspec",
46+
]
47+
s3stalker = [
48+
"python-dateutil",
49+
"s3fs",
50+
]
51+
scisys_receiver = [
52+
"netifaces",
53+
]
54+
trollstalker = [
55+
"watchdog!=4.0.0",
56+
]
57+
58+
[project.urls]
59+
Homepage = "https://github.com/pytroll/pytroll-collectors"
60+
61+
[dependency-groups]
62+
test = [
63+
"freezegun>=1.5.5",
64+
"paramiko>=4.0.0",
65+
"pytest>=8.4.2",
66+
"pytest-cov>=7.0.0",
67+
]
68+
69+
[tool.hatch.build.targets.sdist]
70+
include = [
71+
"/pytroll_collectors",
72+
]
73+
74+
[tool.hatch.version]
75+
source = "vcs"
76+
77+
[tool.hatch.build.hooks.vcs]
78+
version-file = "pytroll_collectors/version.py"
79+
80+
[tool.coverage.run]
81+
relative_files = true
82+
omit = ["pytroll_collectors/version.py"]
83+
84+
[tool.ruff]
85+
line-length = 120
86+
87+
[tool.ruff.lint]
88+
# See https://docs.astral.sh/ruff/rules/
89+
select = ["A", "E", "W", "TID", "T10"]
90+
# to add in the future: "Q", "I", "N", "PT", "S", "T20", "C90", "F", "B", "D"
91+
92+
[tool.ruff.lint.per-file-ignores]
93+
"pytroll_collectors/tests/*" = ["S101"] # assert allowed in tests
94+
"doc/source/conf.py" = ["D100", "A001"] # sphinx misbihaving
95+
"pytroll_collectors/version.py" = ["D100", "Q000"] # automatically generated by hatch-vcs
96+
97+
[tool.ruff.lint.pydocstyle]
98+
convention = "google"
99+
100+
[tool.ruff.lint.mccabe]
101+
max-complexity = 10

pytroll_collectors/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@
2121
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2222

2323
"""The place where everything starts :)."""
24-
from . import _version
25-
__version__ = _version.get_versions()['version']
24+
try:
25+
from pytroll_collectors.version import version # noqa
26+
except ModuleNotFoundError as err: # pragma: no cover
27+
err.add_note("This could mean you didn't install 'pytroll_collectors' properly.")
28+
err.add_note("Try reinstalling ('pip install').")
29+
raise

0 commit comments

Comments
 (0)