Skip to content

Commit 7a0aa86

Browse files
committed
Update MANIFEST.in to include additional file types and LICENSE; modify pyproject.toml for package data and publishing settings; refactor version retrieval in flika/version.py to use importlib.metadata.
1 parent a2c21e8 commit 7a0aa86

File tree

4 files changed

+13
-48
lines changed

4 files changed

+13
-48
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ jobs:
77
publish:
88
name: publish
99
runs-on: ubuntu-latest
10+
environment:
11+
name: pypi
12+
url: https://pypi.org/p/flika
1013
permissions:
1114
id-token: write
1215
steps:
@@ -21,4 +24,4 @@ jobs:
2124
python -m pip install -U pip build
2225
python -m build
2326
- name : Publish Flika to PyPI
24-
uses: pypa/gh-action-pypi-publish@v1.8.11
27+
uses: pypa/gh-action-pypi-publish@v1.12.4

MANIFEST.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
recursive-include flika *.ui *.png *.ico
1+
recursive-include flika *.ui *.png *.ico *.tif *.txt *.py
22
include README.md
3+
include LICENSE
4+
include pyproject.toml
5+
include py.typed
36
include flika.desktop
47
recursive-include examples *.py

flika/version.py

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,7 @@
11
"""
2-
Module providing the flika version, extracted from pyproject.toml.
2+
Module providing the flika version, extracted from package metadata.
33
"""
44

5-
import tomllib
6-
from pathlib import Path
5+
import importlib.metadata
76

8-
9-
def _get_version() -> str:
10-
"""
11-
Parse pyproject.toml to extract the flika version.
12-
13-
Returns:
14-
str: The version string of flika.
15-
"""
16-
# Find the pyproject.toml file relative to this file (version.py)
17-
module_path = Path(__file__).resolve()
18-
pyproject_path = None
19-
20-
# Look in the parent directories of this file for pyproject.toml
21-
for path in [module_path.parent, *module_path.parent.parents]:
22-
potential_path = path / "pyproject.toml"
23-
if potential_path.exists():
24-
pyproject_path = potential_path
25-
break
26-
27-
if pyproject_path is None:
28-
raise FileNotFoundError(
29-
"Could not find pyproject.toml in parent directories of the module"
30-
)
31-
32-
# Parse the TOML file
33-
with open(pyproject_path, "rb") as f:
34-
pyproject_data = tomllib.load(f)
35-
36-
# Extract the version
37-
flika_version = pyproject_data.get("project", {}).get("version")
38-
39-
if flika_version is None:
40-
raise ValueError("Version not found in pyproject.toml")
41-
42-
return flika_version
43-
44-
45-
# Expose the version at module level
46-
__version__ = _get_version()
7+
__version__ = importlib.metadata.version("flika")

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,21 @@ dev = [
7171
"sphinxcontrib-napoleon>=0.7",
7272
"mypy",
7373
"scipy-stubs",
74-
7574
]
7675

7776
[tool.setuptools]
7877
packages = ["flika"]
78+
package-dir = {"" = "."}
7979

8080
[tool.setuptools.package-data]
81-
"gui" = ["*.ui"]
82-
"images" = ["*.ico", "*.png", "*.txt", "*.tif"]
81+
"flika" = ["*.ui", "*.ico", "*.png", "*.txt", "*.tif"]
8382

8483
[tool.pytest.ini_options]
8584
testpaths = ["flika"]
8685
python_files = "test_*.py"
8786
python_classes = "Test*"
8887
python_functions = "test_*"
8988

90-
9189
[tool.ruff]
9290
line-length = 88
9391

0 commit comments

Comments
 (0)