Skip to content

Commit c60ce37

Browse files
authored
Start switch to hatch (#312)
* Start switch to hatch * Add ci file * Adjust make * no codecov * use all * Install more CI * Hatch with latex * add feynmf to ci * Makefile hatch * docs * More latex
1 parent e0bd50d commit c60ce37

File tree

8 files changed

+164
-5434
lines changed

8 files changed

+164
-5434
lines changed

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
# Run daily at 0:01 UTC
9+
schedule:
10+
- cron: '1 0 * * *'
11+
workflow_dispatch:
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
test:
22+
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: [ubuntu-latest]
28+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
allow-prereleases: true
40+
41+
- uses: astral-sh/setup-uv@v3
42+
43+
- name: Install dependencies
44+
run: |
45+
uv pip install --system '.[test]'
46+
uv pip list
47+
48+
- name: Install external packages
49+
run: >-
50+
sudo apt-get update -y &&
51+
sudo apt-get install -y
52+
latexmk
53+
graphviz
54+
texlive-latex-base
55+
texlive-fonts-extra
56+
texlive-extra-utils
57+
texlive-metapost
58+
texlive-latex-extra
59+
feynmf
60+
61+
- name: Test with pytest
62+
run: |
63+
pytest --cov --cov-report=xml -r sx

.github/workflows/devel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
devel:
1313
runs-on: ubuntu-latest
1414
container:
15-
image: apnpucky/ubuntu-python-latexmk
15+
image: apnpucky/ubuntu-hatch-latexmk
1616
steps:
1717
- uses: APN-Pucky/make-python-action@main
1818
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
stable:
1010
runs-on: ubuntu-latest
1111
container:
12-
image: apnpucky/ubuntu-python-latexmk
12+
image: apnpucky/ubuntu-hatch-latexmk
1313
steps:
1414
- uses: APN-Pucky/make-python-action@main
1515
with:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
unstable:
1212
runs-on: ubuntu-latest
1313
container:
14-
image: apnpucky/ubuntu-python-latexmk
14+
image: apnpucky/ubuntu-hatch-latexmk
1515
steps:
1616
- uses: APN-Pucky/make-python-action@main
1717
with:

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
livehtml:
2-
poetry run $(MAKE) -C docs livehtml
2+
hatch run all:$(MAKE) -C docs livehtml
33

44
html:
5-
poetry run $(MAKE) -C docs html
5+
hatch run all:$(MAKE) -C docs html
66

77
pdf:
8-
poetry run $(MAKE) -C docs latexpdf
8+
hatch run all:$(MAKE) -C docs latexpdf
99

1010
doc: html
1111

1212
install:
13-
poetry install --with docs --with dev --with test
13+
hatch env create
1414
python3 -m pip install --user .
1515

1616
build:
17-
poetry build
17+
hatch build
1818

1919
test:
2020
rm -f .coverage coverage.xml
21-
poetry run pytest
21+
hatch run all:pytest
2222

2323
commit:
2424
-git add .

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
info = toml.load("../../pyproject.toml")
3636
except FileNotFoundError:
3737
info = toml.load("pyproject.toml")
38-
project = info["tool"]["poetry"]["name"]
38+
project = info["project"]["name"]
3939
copyright = str(datetime.datetime.now().year) + ", Alexander Puck Neuwirth"
40-
author = ", ".join(info["tool"]["poetry"]["authors"])
40+
author = ", ".join([a["name"] for a in info["project"]["authors"]])
4141
version = re.sub("^", "", os.popen("git describe --tags").read().strip())
4242
rst_epilog = f""".. |project| replace:: {project}\n\n"""
4343

poetry.lock

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

pyproject.toml

Lines changed: 90 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,105 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = [
3+
"hatchling",
4+
"hatch-vcs",
5+
]
6+
build-backend = "hatchling.build"
7+
8+
[project]
29
name = "pyfeyn2"
3-
version = "0.0.0"
4-
description = "PyFeyn is a package which makes drawing Feynman diagrams simple and programmatic. Feynman diagrams are important constructs in perturbative field theory, so being able to draw them in a programmatic fashion is important if attempting to enumerate a large number of diagram configurations is important. The output quality of PyFeyn diagrams (into PDF or EPS formats) is very high, and special effects can be obtained by using constructs from PyX, which PyFeyn is based around"
5-
authors = ["Alexander Puck Neuwirth <alexander@neuwirth-informatik.de>"]
10+
dynamic = ["version"]
11+
description = 'PyFeyn is a package which makes drawing Feynman diagrams simple and programmatic. Feynman diagrams are important constructs in perturbative field theory, so being able to draw them in a programmatic fashion is important if attempting to enumerate a large number of diagram configurations is important. The output quality of PyFeyn diagrams (into PDF or EPS formats) is very high, and special effects can be obtained by using constructs from PyX, which PyFeyn is based around'
612
readme = "README.md"
7-
repository = "https://github.com/APN-Pucky/pyfeyn2"
8-
9-
[tool.poetry.dependencies]
10-
python = "^3.8"
11-
particle = "*"
12-
xsdata = {version = "*", extras = ["cli","lxml","soap"]}
13-
pylatex = "*"
14-
dot2tex = "*"
15-
matplotlib = ">=1.4.0,<4.0.0"
16-
Wand = "*"
17-
numpy = "*" # Upper limit due to feynman using np.complex
18-
pyx = ">=0.12,<1.0.0" # Original pyfeyn
19-
pydot = "*"
20-
feynman=">=2.1"
21-
cssutils= "*"
22-
pylatexenc = "*"
23-
pygments = "*"
24-
graphviz = "*"
25-
ipyparallel = "*"
26-
deprecated = "*"
27-
deprecation = "*"
28-
cssselect ="*"
29-
smpl_io = "*"
30-
smpl_doc = "*"
31-
smpl_util= "*"
32-
iminuit = "*"
33-
colorama = "*"
34-
termcolor = "*"
35-
feynml = {version = ">=0.2.24", extras = ["interfaces"]}
36-
#feynml= {path = "../feynml", develop = true, extras = ["interfaces"]}
37-
#asciidraw = {path = "../asciidraw", develop = true}
38-
asciidraw = ">=0.1.2"
39-
40-
[tool.poetry.scripts]
41-
mkfeyndiag = "pyfeyn2.mkfeyndiag:main"
42-
43-
[tool.poetry.group.docs]
44-
optional = true
45-
46-
[tool.poetry.group.docs.dependencies]
47-
sphinx = "<8.0.0"
48-
sphinx-rtd-theme = "*"
49-
sphinxcontrib-napoleon = "*"
50-
nbsphinx = "*"
51-
jupyter-sphinx = "*"
52-
sphinx_autobuild = "*"
53-
sphinx_math_dollar = "*"
54-
myst-parser = "*"
55-
toml = "*"
56-
57-
[tool.poetry.group.test]
58-
optional = true
13+
requires-python = ">=3.8"
14+
keywords = []
15+
authors = [
16+
{ name = "Alexander Puck Neuwirth", email = "alexander@neuwirth-informatik.de" },
17+
]
18+
classifiers = [
19+
"Development Status :: 4 - Beta",
20+
"Intended Audience :: Developers",
21+
"Intended Audience :: Science/Research",
22+
"License :: OSI Approved :: BSD License",
23+
"Programming Language :: Python",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: 3.13",
30+
"Programming Language :: Python :: Implementation :: CPython",
31+
"Programming Language :: Python :: Implementation :: PyPy",
32+
"Topic :: Scientific/Engineering",
33+
]
34+
dependencies = [
35+
"feynml",
36+
"pylatex",
37+
"dot2tex",
38+
"matplotlib",
39+
"Wand",
40+
"numpy",
41+
"pyx", # Original pyfeyn
42+
"pydot",
43+
"feynman>=2.1",
44+
"pylatexenc",
45+
"pygments",
46+
"graphviz",
47+
"ipyparallel",
48+
"iminuit",
49+
"feynml[interfaces]>=0.2.24",
50+
"asciidraw>=0.1.2",
51+
]
5952

60-
[tool.poetry.group.test.dependencies]
61-
pytest = "*"
62-
pytest-cov = "*"
63-
pytest-profiling = "*"
64-
pytest-line-profiler-apn = ">=0.1.3"
53+
[project.urls]
54+
Documentation = "https://github.com/APN-Pucky/pyfeyn2#readme"
55+
Issues = "https://github.com/APN-Pucky/pyfeyn2/issues"
56+
Source = "https://github.com/APN-Pucky/pyfeyn2/"
6557

66-
[tool.poetry.group.dev]
67-
optional = true
58+
[project.optional-dependencies]
59+
lint = [
60+
"ruff",
61+
]
62+
docs = [
63+
"sphinx<8.0.0",
64+
"sphinx-rtd-theme",
65+
"sphinxcontrib-napoleon",
66+
"nbsphinx",
67+
"jupyter-sphinx",
68+
"sphinx_autobuild",
69+
"sphinx_math_dollar",
70+
"myst-parser",
71+
"toml",
72+
]
73+
test = [
74+
"pytest",
75+
"pytest-cov",
76+
]
77+
dev = [
78+
"pre-commit",
79+
"ipython",
80+
"jupyter",
81+
"jupyterlab",
82+
]
6883

69-
[tool.poetry.group.dev.dependencies]
70-
pre-commit = ">=2.20,<4.0"
71-
ipython = "*"
72-
jupyterlab = "*"
73-
jupyter = "*"
74-
poetry-dynamic-versioning = {extras = ["plugin"], version = ">=0.21.1,<1.7.0"}
84+
[tool.hatch.envs.all]
85+
features = [
86+
"dev",
87+
"docs",
88+
"test",
89+
]
7590

76-
[build-system]
77-
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
78-
build-backend = "poetry_dynamic_versioning.backend"
91+
[tool.hatch]
92+
version.source = "vcs"
7993

80-
[tool.poetry-dynamic-versioning]
81-
enable = true
82-
vcs = "git"
83-
style = "pep440"
84-
dirty = true
85-
# modified dunami default pattern without v
86-
pattern = '(?x)(?# ignore whitespace)^((?P<epoch>\d+)!)?(?P<base>\d+(\.\d+)*)(?# v1.2.3 or v1!2000.1.2)([-._]?((?P<stage>[a-zA-Z]+)[-._]?(?P<revision>\d+)?))?(?# b0)(\+(?P<tagged_metadata>.+))?$(?# +linux)'
87-
strict = true
88-
format-jinja = "{% if distance == 0 %}{{ base }}{% else %}{{ base }}.{{ distance }}{% endif %}"
94+
[tool.hatch.scripts]
95+
mkfeyndiag = "pyfeyn2.mkfeyndiag:main"
8996

9097
[tool.pytest.ini_options]
9198
minversion = "6.0"
9299
testpaths = ["tests"]
93100
addopts = [ "-Werror","-v","--cov=pyfeyn2","--cov-config=.coveragerc","--cov-append","--cov-report=term","--cov-report=xml","--doctest-modules","--ignore=docs/source/conf.py" ]
94101
filterwarnings = [
95102
'error',
96-
'ignore: pkg_resources is deprecated as an API:DeprecationWarning'
103+
'ignore: pkg_resources is deprecated as an API:DeprecationWarning',
104+
"ignore:The 'wheel' package is no longer the canonical location of the 'bdist_wheel' command:DeprecationWarning",
97105
]

0 commit comments

Comments
 (0)