Skip to content

Commit fed070d

Browse files
authored
Modernize Python packaging: migrate from setup.cfg to pyproject.toml (#275)
* Bring data_workflow in line with current standards - replace setup.cfg * Fix warnings * Fix setuptools deprecation warnings * Address more comments * Address more comments * Address coderabbit's review comments
1 parent af8264a commit fed070d

File tree

7 files changed

+118
-102
lines changed

7 files changed

+118
-102
lines changed

docs/developer/instruction/build.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,36 @@ After installing pre-commit the checks can be run using
5050
5151
pre-commit run --all-files
5252
53+
Python package configuration
54+
-----------------------------
55+
56+
This project contains three separate Python packages (dasmon_app, webmon_app, and workflow_app),
57+
each with its own ``pyproject.toml`` file following modern Python packaging standards (PEP 518 and PEP 621).
58+
The configuration includes:
59+
60+
* Package metadata (name, version, description, authors, license)
61+
* Console script entry points for command-line tools
62+
* Package data specifications (SQL files, templates, static assets)
63+
* Build system configuration using setuptools
64+
* Test dependencies
65+
66+
Each package can be built independently using:
67+
68+
.. code-block:: shell
69+
70+
make wheel/dasmon # Build dasmon package
71+
make wheel/webmon # Build webmon package
72+
make wheel/workflow # Build workflow package
73+
make wheel/all # Build all three packages
74+
75+
The built wheels are stored in each package's ``dist/`` directory and are used by the Docker containers
76+
to install the applications.
77+
5378
Running unit tests
5479
------------------
5580

5681
The unit tests exist next to the code it is testing.
57-
They are run inside a pixi environment and pointing at the correct directory with the configuration inside the root-level ``setup.cfg``.
82+
They are run inside a pixi environment with configuration defined in the root-level ``pyproject.toml``.
5883
This is based on what is run in `.github/workflow/ci.yml <https://github.com/neutrons/data_workflow/blob/next/.github/workflows/ci.yml>`_
5984

6085
.. code-block:: shell

src/dasmon_app/pyproject.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@
22
requires = ["setuptools >= 42", "wheel", "toml", "versioningit"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "django-nscd-dasmon"
7+
description = "SNS DASMON listener"
8+
dynamic = ["version"]
9+
requires-python = ">=3.10"
10+
license = "LGPL-3.0-or-later"
11+
classifiers = [
12+
"Programming Language :: Python :: 3",
13+
"Programming Language :: Python :: 3.10",
14+
"Programming Language :: Python :: 3.11",
15+
"Topic :: Software Development :: Libraries :: Python Modules",
16+
"Topic :: System :: Distributed Computing",
17+
"Topic :: System :: Networking",
18+
]
19+
20+
[project.scripts]
21+
dasmon_listener = "dasmon_listener.dasmon_listener:run"
22+
# Note: reduction_update entry point commented out - module dasmon_listener.reduction_script_update does not exist
23+
# Uncomment when module is implemented:
24+
# reduction_update = "dasmon_listener.reduction_script_update:run"
25+
26+
[project.optional-dependencies]
27+
tests = ["pytest"]
28+
29+
[tool.setuptools]
30+
include-package-data = false
31+
32+
[tool.setuptools.packages.find]
33+
exclude = ["dasmon_listener.tests*"]
34+
535
[tool.versioningit.vcs]
636
method = "git"
737
default-tag = "1.0.0"

src/dasmon_app/setup.cfg

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/webmon_app/pyproject.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,40 @@
22
requires = ["setuptools >= 42", "wheel", "toml", "versioningit"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "django-nscd-webmon"
7+
description = "Common models for nscd web monitor"
8+
dynamic = ["version"]
9+
requires-python = ">=3.10"
10+
license = "LGPL-3.0-or-later"
11+
classifiers = [
12+
"Programming Language :: Python :: 3",
13+
"Programming Language :: Python :: 3.10",
14+
"Programming Language :: Python :: 3.11",
15+
"Topic :: Software Development :: Libraries :: Python Modules",
16+
"Topic :: System :: Distributed Computing",
17+
"Topic :: System :: Networking",
18+
]
19+
20+
[project.optional-dependencies]
21+
tests = ["pytest"]
22+
23+
[tool.setuptools]
24+
include-package-data = true
25+
26+
[tool.setuptools.packages.find]
27+
exclude = ["tests*"]
28+
29+
[tool.setuptools.package-data]
30+
reporting = [
31+
"dasmon/sql/*.sql",
32+
"pvmon/sql/*.sql",
33+
"report/sql/*.sql",
34+
"fixtures/db_init.json",
35+
"static/**/*",
36+
"templates/**/*",
37+
]
38+
539
[tool.check-wheel-contents]
640
ignore = ["W002", "W004"] # duplicate files and can't import django migrations
741

src/webmon_app/setup.cfg

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/workflow_app/pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22
requires = ["setuptools >= 42", "wheel", "toml", "versioningit"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "django-nscd-workflow"
7+
description = "SNS data workflow manager"
8+
dynamic = ["version"]
9+
requires-python = ">=3.10"
10+
license = "LGPL-3.0-or-later"
11+
classifiers = [
12+
"Programming Language :: Python :: 3",
13+
"Programming Language :: Python :: 3.10",
14+
"Programming Language :: Python :: 3.11",
15+
"Topic :: Software Development :: Libraries :: Python Modules",
16+
"Topic :: System :: Distributed Computing",
17+
"Topic :: System :: Networking",
18+
]
19+
20+
[project.scripts]
21+
workflowmgr = "workflow.sns_post_processing:run"
22+
23+
[project.optional-dependencies]
24+
tests = ["pytest"]
25+
26+
[tool.setuptools]
27+
include-package-data = false
28+
29+
[tool.setuptools.packages.find]
30+
where = ["."]
31+
exclude = ["workflow.tests*"]
32+
533
[tool.versioningit.vcs]
634
method = "git"
735
default-tag = "1.0.0"

src/workflow_app/setup.cfg

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)