Skip to content

Commit

Permalink
Start switch to hatch (#312)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
APN-Pucky authored Jan 19, 2025
1 parent e0bd50d commit c60ce37
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 5,434 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI/CD

on:
push:
branches:
- master
pull_request:
# Run daily at 0:01 UTC
schedule:
- cron: '1 0 * * *'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: |
uv pip install --system '.[test]'
uv pip list
- name: Install external packages
run: >-
sudo apt-get update -y &&
sudo apt-get install -y
latexmk
graphviz
texlive-latex-base
texlive-fonts-extra
texlive-extra-utils
texlive-metapost
texlive-latex-extra
feynmf
- name: Test with pytest
run: |
pytest --cov --cov-report=xml -r sx
2 changes: 1 addition & 1 deletion .github/workflows/devel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
devel:
runs-on: ubuntu-latest
container:
image: apnpucky/ubuntu-python-latexmk
image: apnpucky/ubuntu-hatch-latexmk
steps:
- uses: APN-Pucky/make-python-action@main
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
stable:
runs-on: ubuntu-latest
container:
image: apnpucky/ubuntu-python-latexmk
image: apnpucky/ubuntu-hatch-latexmk
steps:
- uses: APN-Pucky/make-python-action@main
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
unstable:
runs-on: ubuntu-latest
container:
image: apnpucky/ubuntu-python-latexmk
image: apnpucky/ubuntu-hatch-latexmk
steps:
- uses: APN-Pucky/make-python-action@main
with:
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
livehtml:
poetry run $(MAKE) -C docs livehtml
hatch run all:$(MAKE) -C docs livehtml

html:
poetry run $(MAKE) -C docs html
hatch run all:$(MAKE) -C docs html

pdf:
poetry run $(MAKE) -C docs latexpdf
hatch run all:$(MAKE) -C docs latexpdf

doc: html

install:
poetry install --with docs --with dev --with test
hatch env create
python3 -m pip install --user .

build:
poetry build
hatch build

test:
rm -f .coverage coverage.xml
poetry run pytest
hatch run all:pytest

commit:
-git add .
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
info = toml.load("../../pyproject.toml")
except FileNotFoundError:
info = toml.load("pyproject.toml")
project = info["tool"]["poetry"]["name"]
project = info["project"]["name"]
copyright = str(datetime.datetime.now().year) + ", Alexander Puck Neuwirth"
author = ", ".join(info["tool"]["poetry"]["authors"])
author = ", ".join([a["name"] for a in info["project"]["authors"]])
version = re.sub("^", "", os.popen("git describe --tags").read().strip())
rst_epilog = f""".. |project| replace:: {project}\n\n"""

Expand Down
5,341 changes: 0 additions & 5,341 deletions poetry.lock

This file was deleted.

172 changes: 90 additions & 82 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,97 +1,105 @@
[tool.poetry]
[build-system]
requires = [
"hatchling",
"hatch-vcs",
]
build-backend = "hatchling.build"

[project]
name = "pyfeyn2"
version = "0.0.0"
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"
authors = ["Alexander Puck Neuwirth <[email protected]>"]
dynamic = ["version"]
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'
readme = "README.md"
repository = "https://github.com/APN-Pucky/pyfeyn2"

[tool.poetry.dependencies]
python = "^3.8"
particle = "*"
xsdata = {version = "*", extras = ["cli","lxml","soap"]}
pylatex = "*"
dot2tex = "*"
matplotlib = ">=1.4.0,<4.0.0"
Wand = "*"
numpy = "*" # Upper limit due to feynman using np.complex
pyx = ">=0.12,<1.0.0" # Original pyfeyn
pydot = "*"
feynman=">=2.1"
cssutils= "*"
pylatexenc = "*"
pygments = "*"
graphviz = "*"
ipyparallel = "*"
deprecated = "*"
deprecation = "*"
cssselect ="*"
smpl_io = "*"
smpl_doc = "*"
smpl_util= "*"
iminuit = "*"
colorama = "*"
termcolor = "*"
feynml = {version = ">=0.2.24", extras = ["interfaces"]}
#feynml= {path = "../feynml", develop = true, extras = ["interfaces"]}
#asciidraw = {path = "../asciidraw", develop = true}
asciidraw = ">=0.1.2"

[tool.poetry.scripts]
mkfeyndiag = "pyfeyn2.mkfeyndiag:main"

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
sphinx = "<8.0.0"
sphinx-rtd-theme = "*"
sphinxcontrib-napoleon = "*"
nbsphinx = "*"
jupyter-sphinx = "*"
sphinx_autobuild = "*"
sphinx_math_dollar = "*"
myst-parser = "*"
toml = "*"

[tool.poetry.group.test]
optional = true
requires-python = ">=3.8"
keywords = []
authors = [
{ name = "Alexander Puck Neuwirth", email = "[email protected]" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering",
]
dependencies = [
"feynml",
"pylatex",
"dot2tex",
"matplotlib",
"Wand",
"numpy",
"pyx", # Original pyfeyn
"pydot",
"feynman>=2.1",
"pylatexenc",
"pygments",
"graphviz",
"ipyparallel",
"iminuit",
"feynml[interfaces]>=0.2.24",
"asciidraw>=0.1.2",
]

[tool.poetry.group.test.dependencies]
pytest = "*"
pytest-cov = "*"
pytest-profiling = "*"
pytest-line-profiler-apn = ">=0.1.3"
[project.urls]
Documentation = "https://github.com/APN-Pucky/pyfeyn2#readme"
Issues = "https://github.com/APN-Pucky/pyfeyn2/issues"
Source = "https://github.com/APN-Pucky/pyfeyn2/"

[tool.poetry.group.dev]
optional = true
[project.optional-dependencies]
lint = [
"ruff",
]
docs = [
"sphinx<8.0.0",
"sphinx-rtd-theme",
"sphinxcontrib-napoleon",
"nbsphinx",
"jupyter-sphinx",
"sphinx_autobuild",
"sphinx_math_dollar",
"myst-parser",
"toml",
]
test = [
"pytest",
"pytest-cov",
]
dev = [
"pre-commit",
"ipython",
"jupyter",
"jupyterlab",
]

[tool.poetry.group.dev.dependencies]
pre-commit = ">=2.20,<4.0"
ipython = "*"
jupyterlab = "*"
jupyter = "*"
poetry-dynamic-versioning = {extras = ["plugin"], version = ">=0.21.1,<1.7.0"}
[tool.hatch.envs.all]
features = [
"dev",
"docs",
"test",
]

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry_dynamic_versioning.backend"
[tool.hatch]
version.source = "vcs"

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "pep440"
dirty = true
# modified dunami default pattern without v
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)'
strict = true
format-jinja = "{% if distance == 0 %}{{ base }}{% else %}{{ base }}.{{ distance }}{% endif %}"
[tool.hatch.scripts]
mkfeyndiag = "pyfeyn2.mkfeyndiag:main"

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

0 comments on commit c60ce37

Please sign in to comment.