Migrate to pyproject.toml

This commit is contained in:
2025-11-06 13:51:26 +01:00
parent 58ef47468e
commit 57c0037289
4 changed files with 54 additions and 32 deletions

View File

@@ -1,8 +1,10 @@
{% set data = load_setup_py_data() %}
{% set version_match = load_file_regex(load_file="pyzebra/__init__.py", regex_pattern='__version__ = "(.+?)"') %}
{% set version = version_match[1] %}
{% set pyproject = load_file_data('pyproject.toml') %}
package:
name: pyzebra
version: {{ data['version'] }}
name: {{ pyproject['project']['name'] }}
version: {{ version }}
source:
path: ..
@@ -10,26 +12,25 @@ source:
build:
script: python -m pip install .
noarch: python
number: 0
entry_points:
- pyzebra = pyzebra.app.cli:main
requirements:
build:
host:
- python >=3.8
- setuptools
- hatchling
run:
- python >=3.8
- numpy
- scipy
- h5py
- bokeh =2.4
- numba
- lmfit >=1.0.2
{% for dep in pyproject['project']['dependencies'] %}
- {{ dep }}
{% endfor %}
about:
home: https://gitlab.psi.ch/zebra/pyzebra
summary: {{ data['description'] }}
license: GNU GPLv3
license_file: LICENSE
home: {{ pyproject['project']['urls']['Homepage'] }}
summary: {{ pyproject['project']['description'] }}
license: {{ pyproject['project']['license'] }}
license_file:
{% for lf in pyproject['project']['license-files'] %}
- {{ lf }}
{% endfor %}

View File

@@ -22,7 +22,7 @@ def main():
with open(version_filepath) as f:
file_content = f.read()
version = re.search(r'__version__ = "(.*?)"', file_content).group(1)
version = re.search(r'__version__ = "(.+?)"', file_content).group(1)
major, minor, patch = map(int, version.split(sep="."))
if args.level == "patch":
@@ -38,7 +38,7 @@ def main():
new_version = f"{major}.{minor}.{patch}"
with open(version_filepath, "w") as f:
f.write(re.sub(r'__version__ = "(.*?)"', f'__version__ = "{new_version}"', file_content))
f.write(re.sub(r'__version__ = "(.+?)"', f'__version__ = "{new_version}"', file_content))
os.system(f"git commit {version_filepath} -m 'Updating for version {new_version}'")
os.system(f"git tag -a {new_version} -m 'Release {new_version}'")

35
pyproject.toml Normal file
View File

@@ -0,0 +1,35 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "pyzebra"
dynamic = ["version"] # version will be read from __init__.py
requires-python = ">=3.8"
dependencies = [
"numpy",
"scipy",
"h5py",
"bokeh ~=2.4",
"numba",
"lmfit >=1.0.2",
]
authors = [
{name = "Paul Scherrer Institute"}
]
maintainers = [
{name = "Ivan Usov", email = "ivan.usov@psi.ch"}
]
description = "An experimental data analysis library for zebra instrument."
readme = "README.md"
license = "GPL-3.0-or-later"
license-files = ["LICENSE"]
[project.urls]
Homepage = "https://gitea.psi.ch/zebra/pyzebra"
[tool.hatch.build.targets.wheel]
include = ["pyzebra"]
[tool.hatch.version]
path = "pyzebra/__init__.py"

View File

@@ -1,14 +0,0 @@
import re
from setuptools import find_packages, setup
with open("pyzebra/__init__.py") as f:
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)
setup(
name="pyzebra",
version=version,
description="An experimental data analysis library for zebra instrument.",
packages=find_packages(),
license="GNU GPLv3",
)