7.3. Packaging¶
The release.yml workflow
creates a .tar.gz
archive that can be installed with pip.
Releases are located here.
The compressed package should only include the library itself and metadata, while documentation and testing should be excluded. Unfortunately, tests are included by default and need to be explicitly excluded with a MANIFEST.in.
Requirements and metadata for the library are defined in the
pyproject.toml file.
This is a more modern successor to a setup.py
file.
Content of pyproject.toml
1[project]
2name = "optrace"
3dynamic = ["version"]
4authors = [{name = "Damian Mendroch", email = "damian.mendroch@th-koeln.de"}]
5maintainers = [{name = "Damian Mendroch", email = "damian.mendroch@th-koeln.de"}]
6description = "An optics simulation package with sequential raytracing, image rendering and a GUI frontend"
7keywords = ["simulation", "optics", "raytracing"]
8readme = "ReadMe.md"
9license = {text = "MIT License"}
10requires-python = ">=3.11,<3.14"
11dependencies = ["numpy>2", "chardet", "scipy", "opencv-python-headless", "pyqtdarktheme-fork", "pyside6",
12"matplotlib", "tqdm", "mayavi @ git+https://github.com/drocheam/mayavi.git@merged-fixes", "vtk < 9.5"]
13classifiers = [
14 "Development Status :: 4 - Beta",
15 "Intended Audience :: Developers",
16 "Intended Audience :: Education",
17 "Intended Audience :: Science/Research",
18 "License :: OSI Approved :: MIT License",
19 "Natural Language :: English",
20 "Operating System :: OS Independent",
21 "Operating System :: Microsoft :: Windows",
22 "Operating System :: POSIX",
23 "Operating System :: Unix",
24 "Operating System :: MacOS",
25 "Programming Language :: Python :: 3.11",
26 "Programming Language :: Python :: 3.12",
27 "Programming Language :: Python :: 3.13",
28 "Topic :: Scientific/Engineering",
29 "Topic :: Scientific/Engineering :: Physics",
30 "Topic :: Scientific/Engineering :: Visualization",
31 "Topic :: Software Development",
32 "Topic :: Software Development :: Libraries"
33]
34
35[project.urls]
36Homepage = "https://drocheam.github.io/optrace"
37Repository = "https://www.github.com/drocheam/optrace"
38Documentation = "https://drocheam.github.io/optrace"
39Changelog = "https://drocheam.github.io/optrace/development/changelog.html"
40
41[project.optional-dependencies]
42tests = ["pyautogui", "pytest", "coverage", "colour-science", "pytest-timeout", "pytest-random-order", "pytest-xvfb"]
43docs = ["sphinx", "sphinxcontrib-bibtex", "shibuya", "sphinx-sitemap", "sphinx-mathjax-offline"]
44
45[build-system]
46requires = ["setuptools >= 61.0", "numpy>2"]
47build-backend = "setuptools.build_meta"
48
49[tool.setuptools]
50packages.find.include = ["optrace*"]
51include-package-data = false
52dynamic = {version = {attr = "optrace.metadata.version"}}
53package-data = {optrace = ["resources/*", "resources/images/*"]}
54
55[tool.pytest.ini_options]
56testpaths = ["tests"]
57timeout = 360
58timeout_method = "thread"
59filterwarnings = ["ignore::UserWarning"]
60addopts = "--random-order"
61markers = [
62 "slow: tests slower than 10 seconds on my machine",
63 "os: marks test relevant for testing of different operating systems",
64 "install: marks package installation tests. Should include tests and docs dependencies.",
65 "gui1: only first batch of GUI tests (separated for lower RAM usage)",
66 "gui2: only second batch of GUI tests (separated for lower RAM usage)",
67 "gui3: only third batch of GUI tests (separated for lower RAM usage)"
68]
69
70[tool.gh_actions]
71python = { "3.11" = "py311", "3.12" = "py312", "3.13" = "py313" }
Notes
mayavi git version needed as PyPi version rarely gets updated see https://stackoverflow.com/questions/68073819/pypi-install-requires-direct-links and https://stackoverflow.com/questions/40065321/how-to-include-git-dependencies-in-setup-py-for-pip-installation#comment115929654_65527149 or https://stackoverflow.com/a/54894359
MANIFEST.in with content
recursive-exclude tests *
required, so tests directory gets excluded from dist. See https://stackoverflow.com/a/72821651 and https://stackoverflow.com/a/48912748 at comment from bogeymin