Skip to content

Commit 687f6a1

Browse files
authored
Develop with rye (#50)
* chore: fmt, add facet nominal_resolution * feat(dev): switch pdm for rye * feat(dev): uv in the CI * fix(rye): remove uv, not yet compatible with rye dev deps * fix(ci): pin python version for rye * fix: wrong config file * fix(ci): python >= 3.10
1 parent 873d668 commit 687f6a1

File tree

6 files changed

+66
-90
lines changed

6 files changed

+66
-90
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,28 @@ on:
2020

2121
jobs:
2222
tests:
23+
strategy:
24+
matrix:
25+
python-version:
26+
- "3.10"
27+
- "3.11"
28+
- "3.12"
2329
runs-on: ubuntu-latest
2430
steps:
25-
- uses: actions/checkout@v3
31+
- name: Checkout the repository
32+
uses: actions/checkout@v4
2633

27-
- uses: pdm-project/setup-pdm@v3
28-
name: setup pdm
34+
- name: Install the latest version of rye
35+
uses: eifinger/setup-rye@v4
2936
with:
30-
python-version: "3.11" # Version range or exact version of a Python version to use, the same as actions/setup-python
31-
architecture: x64 # The target architecture (x86, x64) of the Python interpreter. the same as actions/setup-python
32-
prerelease: false # Allow prerelease versions to be installed
33-
enable-pep582: true # Enable PEP 582 package loading globally
37+
enable-cache: true
38+
cache-prefix: ${{ matrix.python-version }}
3439

35-
- name: install dependencies
36-
run: pdm install -G test
40+
- name: Pin python-version ${{ matrix.python-version }}
41+
run: rye pin ${{ matrix.python-version }}
3742

38-
- name: run tests
39-
run: pdm run test_coverage
43+
- name: Sync dependencies
44+
run: rye sync
45+
46+
- name: Run tests
47+
run: rye test

.github/workflows/doc.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,18 @@ jobs:
1313
documentation:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717

18-
- uses: pdm-project/setup-pdm@main
19-
name: setup pdm
18+
- name: Install the latest version of rye
19+
uses: eifinger/setup-rye@v4
2020
with:
21-
python-version: "3.10" # Version range or exact version of a Python version to use, the same as actions/setup-python
22-
architecture: x64 # The target architecture (x86, x64) of the Python interpreter. the same as actions/setup-python
23-
version: 2.1.5 # The version of PDM to install. Leave it as empty to use the latest version from PyPI
24-
prerelease: false # Allow prerelease versions to be installed
25-
enable-pep582: true # Enable PEP 582 package loading globally
21+
enable-cache: true
2622

27-
- name: install dependencies
28-
run: pdm install --no-default -dG doc
23+
- name: Sync dependencies
24+
run: rye sync
2925

3026
- name: build
31-
run: pdm run mkdocs build -f docs/mkdocs.yml
27+
run: rye run mkdocs build -f docs/mkdocs.yml
3228

3329
- name: deploy
3430
uses: peaceiris/actions-gh-pages@v3

esgpull/database.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ def _update(self) -> None:
6666
opts = {"version_table": "version"}
6767
ctx = MigrationContext.configure(conn, opts=opts)
6868
self.version = ctx.get_current_revision()
69-
if self.version != head:
70-
alembic.command.upgrade(alembic_config, __version__)
69+
if head is not None and self.version != head:
70+
alembic.command.upgrade(alembic_config, head)
7171
self.version = head
72-
if self.version != __version__:
72+
if "+dev" not in __version__ and self.version != __version__:
7373
alembic.command.revision(
7474
alembic_config,
7575
message="update tables",

esgpull/models/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def has_files(self) -> bool:
235235
return nb_files is not None and nb_files > 0
236236

237237
def files_count_size(self, *status: FileStatus) -> tuple[int, int]:
238-
stmt: sa.Select[tuple[int, int | None]] = (
238+
stmt: sa.Select[tuple[int, int]] = (
239239
sa.select(sa.func.count("*"), sa.func.sum(File.size))
240240
.join_from(query_file_proxy, File)
241241
.where(query_file_proxy.c.query_sha == self.sha)

esgpull/version.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
__version__ = "0.6.5"
1+
import importlib.metadata
2+
3+
__version__ = importlib.metadata.version(__package__ or __name__)

pyproject.toml

Lines changed: 33 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["pdm-backend"]
3-
build-backend = "pdm.backend"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "esgpull"
7-
dynamic = ["version"]
7+
version = "0.6.5"
88
classifiers = [
99
"License :: OSI Approved :: BSD License",
1010
"Programming Language :: Python :: 3",
@@ -45,75 +45,31 @@ esgpull = "esgpull.cli:main"
4545
Repository = "https://github.com/ESGF/esgf-download"
4646
Documentation = "https://esgf.github.io/esgf-download/"
4747

48+
[tool.black]
49+
line-length = 79
50+
extend-exclude = "setup.py"
51+
4852
[tool.coverage.run]
4953
branch = true
5054
source = ["esgpull/"]
5155

52-
[tool.mypy]
53-
ignore_missing_imports = true
56+
[tool.hatch.build.targets.wheel]
57+
packages = ["src/esgpull"]
5458

55-
[tool.pdm.build]
56-
includes = ["esgpull/"]
57-
excludes = [
58-
"**/.mypy_cache/",
59-
"**/.ruff_cache/"
60-
]
59+
[tool.hatch.metadata]
60+
allow-direct-references = true
6161

62-
[tool.pdm.dev-dependencies]
63-
doc = [
64-
"mkdocs-material>=8.5.6"
65-
]
66-
test = [
67-
"pytest>=7.1.3",
68-
"pytest-cov>=5.0.0",
69-
"pytest-xdist>=3.0.2"
70-
]
71-
lint = [
72-
"black>=22.8.0",
73-
"isort>=5.10.1",
74-
"flake8>=5.0.4",
75-
"mypy>=0.982,<1.1.1",
76-
"types-pyopenssl>=22.1.0.1",
77-
"types-aiofiles>=22.1.0",
78-
"types-python-dateutil>=2.8.19.2",
79-
"types-pymysql>=1.0.19.1",
80-
"types-pyyaml>=6.0.12",
81-
"types-cryptography>=3.3.23.1",
82-
"types-setuptools>=65.5.0.1"
83-
]
84-
profile = [
85-
"snakeviz>=2.1.1",
86-
"vprof>=0.38",
87-
"memray>=1.13.3",
88-
"line-profiler>=4.1.3"
89-
]
90-
dev = [
91-
"jupyter-console>=6.6.3"
92-
]
62+
[tool.isort]
63+
profile = "black"
64+
line_length = 79
65+
src_paths = ["esgpull", "tests", "migrations", "examples"]
66+
67+
[tool.mypy]
68+
ignore_missing_imports = true
9369

9470
[tool.pdm.scripts]
95-
echo_gap = "echo"
96-
echo_ruff = "echo [ruff]"
97-
format_ruff = "ruff format"
98-
fix_ruff = "ruff check --fix"
99-
echo_mypy = "echo [mypy]"
100-
lint_mypy = "mypy --disable-recursive-aliases esgpull tests"
101-
lint = {composite = [
102-
"echo_ruff",
103-
"format_ruff",
104-
"fix_ruff",
105-
"echo_gap",
106-
"echo_mypy",
107-
"lint_mypy"
108-
]}
109-
test = "pytest"
110-
test_coverage = "pytest -n auto --cov=esgpull --cov-report term-missing:skip-covered"
11171
doc = {shell = "cd docs && mkdocs serve", help = "Start doc server"}
11272

113-
[tool.pdm.version]
114-
source = "file"
115-
path = "esgpull/version.py"
116-
11773
[tool.pytest.ini_options]
11874
minversion = "6.2.4"
11975
filterwarnings = [
@@ -122,7 +78,7 @@ filterwarnings = [
12278
markers = [
12379
"slow: mark test as slow to run"
12480
]
125-
addopts = "-r aR"
81+
addopts = "-r aR -n auto --cov=esgpull --cov-config=pyproject.toml --cov-report term-missing:skip-covered --mypy"
12682
testpaths = [
12783
"tests/"
12884
]
@@ -133,3 +89,17 @@ extend-exclude = ["output/*", "esgpull/migrations/*"]
13389

13490
[tool.ruff.lint]
13591
extend-select = ["I"]
92+
93+
[tool.rye]
94+
dev-dependencies = [
95+
"jupyter-console>=6.6.3",
96+
"typing-extensions>=4.12.2",
97+
"pytest>=8.3.3",
98+
"pytest-cov>=5.0.0",
99+
"mkdocs-material>=9.5.34",
100+
"mypy>=1.11.2",
101+
"types-pyyaml>=6.0.12.20240808",
102+
"types-aiofiles>=24.1.0.20240626",
103+
"pytest-mypy>=0.10.3",
104+
"pytest-xdist>=3.6.1"
105+
]

0 commit comments

Comments
 (0)