Skip to content

Commit e338dc8

Browse files
committed
Also patch requirements-build.txt
1 parent b4d73b3 commit e338dc8

File tree

2 files changed

+136
-111
lines changed

2 files changed

+136
-111
lines changed

pyproject.toml

Lines changed: 105 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,50 @@ description = "An automated system for the portable solution of partial differen
66
readme = "README.rst"
77
license = {file = "LICENSE"}
88
maintainers = [
9-
{name = "Pablo D. Brubeck"},
10-
{name = "Daiane I. Dolci"},
11-
{name = "David A. Ham", email = "david.ham@imperial.ac.uk"},
12-
{name = "Josh Hope-Collins"},
13-
{name = "Koki Sagiyama"},
14-
{name = "Connor J. Ward", email = "c.ward20@imperial.ac.uk"},
9+
{name = "Pablo D. Brubeck"},
10+
{name = "Daiane I. Dolci"},
11+
{name = "David A. Ham", email = "david.ham@imperial.ac.uk"},
12+
{name = "Josh Hope-Collins"},
13+
{name = "Koki Sagiyama"},
14+
{name = "Connor J. Ward", email = "c.ward20@imperial.ac.uk"},
1515
]
1616
requires-python = ">=3.10"
1717
dependencies = [
18-
"cachetools",
19-
"decorator<=4.4.2",
20-
"mpi4py>3; python_version >= '3.13'",
21-
"mpi4py; python_version < '3.13'",
22-
"h5py>3.12.1",
23-
"libsupermesh",
24-
# NOTE: If changing the PETSc/SLEPc version then firedrake-configure also needs
25-
# changing (as well as other references to petsc4py and slepc4py here)
26-
"petsc4py==3.22.2",
27-
"numpy",
28-
"packaging",
29-
"pkgconfig",
30-
"progress",
31-
"pycparser",
32-
"pytools[siphash]",
33-
"requests",
34-
"rtree>=1.2",
35-
"scipy",
36-
"sympy",
37-
"fenics-ufl @ git+https://github.com/firedrakeproject/ufl.git",
38-
"fenics-fiat @ git+https://github.com/firedrakeproject/fiat.git",
39-
"pyadjoint-ad @ git+https://github.com/dolfin-adjoint/pyadjoint.git",
40-
"loopy @ git+https://github.com/firedrakeproject/loopy.git@main",
18+
"cachetools",
19+
"decorator<=4.4.2",
20+
"mpi4py>3; python_version >= '3.13'",
21+
"mpi4py; python_version < '3.13'",
22+
"h5py>3.12.1",
23+
"libsupermesh",
24+
# NOTE: If changing the PETSc/SLEPc version then firedrake-configure also needs
25+
# changing (as well as other references to petsc4py and slepc4py here)
26+
"petsc4py==3.22.2",
27+
"numpy",
28+
"packaging",
29+
"pkgconfig",
30+
"progress",
31+
"pycparser",
32+
"pytools[siphash]",
33+
"requests",
34+
"rtree>=1.2",
35+
"scipy",
36+
"sympy",
37+
"fenics-ufl @ git+https://github.com/firedrakeproject/ufl.git",
38+
"fenics-fiat @ git+https://github.com/firedrakeproject/fiat.git",
39+
"pyadjoint-ad @ git+https://github.com/dolfin-adjoint/pyadjoint.git",
40+
"loopy @ git+https://github.com/firedrakeproject/loopy.git@main",
4141
]
4242
classifiers = [
43-
"Development Status :: 5 - Production/Stable",
44-
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
45-
"Intended Audience :: Science/Research",
46-
"Programming Language :: Python",
47-
"Programming Language :: Python :: 3",
48-
"Programming Language :: Python :: 3.10",
49-
"Programming Language :: Python :: 3.11",
50-
"Programming Language :: Python :: 3.12",
51-
"Programming Language :: Python :: 3.13",
52-
"Operating System :: Unix",
43+
"Development Status :: 5 - Production/Stable",
44+
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
45+
"Intended Audience :: Science/Research",
46+
"Programming Language :: Python",
47+
"Programming Language :: Python :: 3",
48+
"Programming Language :: Python :: 3.10",
49+
"Programming Language :: Python :: 3.11",
50+
"Programming Language :: Python :: 3.12",
51+
"Programming Language :: Python :: 3.13",
52+
"Operating System :: Unix",
5353
]
5454

5555
[project.urls]
@@ -69,87 +69,92 @@ spydump = "pyop2.scripts.spydump:main"
6969
[project.optional-dependencies]
7070
# Dependencies needed to run firedrake-check
7171
test = [
72-
"mpi-pytest",
73-
"pytest",
72+
"mpi-pytest",
73+
"pytest",
7474
]
7575
# Dependencies needed to run the full test suite
7676
ci = [
77-
"ipympl", # needed for notebook testing
78-
"jax",
79-
"matplotlib",
80-
"mpi-pytest",
81-
"nbval",
82-
"ngsPETSc",
83-
"pylit",
84-
"pytest",
85-
"pytest-split", # needed for firedrake-run-split-tests
86-
"pytest-timeout",
87-
"pytest-xdist",
88-
"slepc4py==3.22.2",
89-
"torch", # requires passing '--extra-index-url' to work
90-
"vtk",
77+
"ipympl", # needed for notebook testing
78+
"jax",
79+
"matplotlib",
80+
"mpi-pytest",
81+
"nbval",
82+
"ngsPETSc",
83+
"pylit",
84+
"pytest",
85+
"pytest-split", # needed for firedrake-run-split-tests
86+
"pytest-timeout",
87+
"pytest-xdist",
88+
"slepc4py==3.22.2",
89+
"torch", # requires passing '--extra-index-url' to work
90+
"vtk",
9191
]
9292
docker = [ # Used in firedrake-vanilla container
93-
"ipympl", # needed for notebook testing
94-
"matplotlib",
95-
"mpi-pytest",
96-
"nbval",
97-
"pylit",
98-
"pytest",
99-
"pytest-split", # needed for firedrake-run-split-tests
100-
"pytest-timeout",
101-
"pytest-xdist",
102-
"slepc4py==3.22.2",
93+
"ipympl", # needed for notebook testing
94+
"matplotlib",
95+
"mpi-pytest",
96+
"nbval",
97+
"pylit",
98+
"pytest",
99+
"pytest-split", # needed for firedrake-run-split-tests
100+
"pytest-timeout",
101+
"pytest-xdist",
102+
"slepc4py==3.22.2",
103103
]
104104
# Dependencies needed to build the docs
105105
docs = [
106-
"bibtexparser",
107-
"matplotlib", # needed to resolve API
108-
"numpydoc",
109-
"pylit",
110-
"sphinx<8.2.0", # https://github.com/firedrakeproject/firedrake/issues/4059
111-
"sphinx-autobuild",
112-
"sphinx-reredirects",
113-
"sphinxcontrib-bibtex",
114-
"sphinxcontrib-jquery",
115-
"sphinxcontrib-svg2pdfconverter",
116-
"sphinxcontrib-youtube",
117-
"vtk", # needed to resolve API
118-
]
119-
# Developer dependencies. In particular the build dependencies that are needed to run 'make'.
120-
dev = [
121-
"Cython",
122-
"mpi-pytest",
123-
"pybind11",
124-
"pytest",
125-
"setuptools",
106+
"bibtexparser",
107+
"matplotlib", # needed to resolve API
108+
"numpydoc",
109+
"pylit",
110+
"sphinx<8.2.0", # https://github.com/firedrakeproject/firedrake/issues/4059
111+
"sphinx-autobuild",
112+
"sphinx-reredirects",
113+
"sphinxcontrib-bibtex",
114+
"sphinxcontrib-jquery",
115+
"sphinxcontrib-svg2pdfconverter",
116+
"sphinxcontrib-youtube",
117+
"vtk", # needed to resolve API
126118
]
127119

128120
[build-system]
129121
requires = [
130-
"Cython>=3.0",
131-
"libsupermesh",
132-
"mpi4py>3; python_version >= '3.13'",
133-
"mpi4py; python_version < '3.13'",
134-
"numpy",
135-
"pkgconfig",
136-
"pybind11",
137-
"setuptools>61.2",
138-
"petsc4py==3.22.2",
139-
"rtree>=1.2",
122+
"Cython>=3.0",
123+
"libsupermesh",
124+
"mpi4py>3; python_version >= '3.13'",
125+
"mpi4py; python_version < '3.13'",
126+
"numpy",
127+
"pkgconfig",
128+
"pybind11",
129+
"setuptools>61.2",
130+
"petsc4py==3.22.2",
131+
"rtree>=1.2",
140132
]
141133
build-backend = "setuptools.build_meta"
142134

143135
# TODO: Convert firedrake-zenodo to a proper entrypoint script.
144136
[tool.setuptools]
145137
script-files = [
146-
"firedrake/scripts/firedrake-zenodo",
147-
"scripts/firedrake-run-split-tests",
138+
"firedrake/scripts/firedrake-zenodo",
139+
"scripts/firedrake-run-split-tests",
148140
]
149141

150142
[tool.setuptools.package-data]
151143
# Unless specified these files will not be installed along with the
152144
# rest of the package
153-
firedrake = ["evaluate.h", "locate.c", "icons/*.png"]
154-
firedrake_check = ["Makefile", "tests/firedrake/conftest.py", "tests/*/*/*.py"]
155-
pyop2 = ["*.h", "*.pxd", "*.pyx", "codegen/c/*.c"]
145+
firedrake = [
146+
"evaluate.h",
147+
"locate.c",
148+
"icons/*.png",
149+
]
150+
firedrake_check = [
151+
"Makefile",
152+
"tests/firedrake/conftest.py",
153+
"tests/*/*/*.py",
154+
]
155+
pyop2 = [
156+
"*.h",
157+
"*.pxd",
158+
"*.pyx",
159+
"codegen/c/*.c",
160+
]

scripts/firedrake-dev-patch

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,65 @@ import tomli
88
import tomli_w
99

1010

11+
REPO = pathlib.Path(__file__).parent.parent
12+
13+
1114
# TODO:
1215
# * logging
1316
# * save prev pyproj as pyproject.toml.orig
14-
# * also patch requirements-build.txt
1517

1618
def main():
1719
args = parse_args()
20+
patch_pyproject(args.existing_packages)
21+
patch_build_requirements(args.existing_packages)
22+
print("done")
1823

19-
repo_root = pathlib.Path(__file__).parent.parent
2024

21-
with open(repo_root / "pyproject.toml", "rb") as f:
25+
def parse_args():
26+
parser = argparse.ArgumentParser()
27+
parser.add_argument("existing_packages", nargs="*")
28+
return parser.parse_args()
29+
30+
31+
def patch_pyproject(existing_packages):
32+
with open(REPO / "pyproject.toml", "rb") as f:
2233
data = tomli.load(f)
2334

2435
removed_deps = set()
25-
removed_deps |= filter_deps(data["project"]["dependencies"], args.existing_packages)
36+
removed_deps |= filter_deps(data["project"]["dependencies"], existing_packages)
2637
for optional_deps in data["project"]["optional-dependencies"].values():
27-
removed_deps |= filter_deps(optional_deps, args.existing_packages)
38+
removed_deps |= filter_deps(optional_deps, existing_packages)
2839

2940
print("Removed: ", removed_deps)
3041

31-
with open(repo_root / "pyproject.toml", "wb") as f:
42+
with open(REPO / "pyproject.toml", "wb") as f:
3243
tomli_w.dump(data, f)
3344

3445

35-
def parse_args():
36-
parser = argparse.ArgumentParser()
37-
parser.add_argument("existing_packages", nargs="*")
38-
return parser.parse_args()
46+
def patch_build_requirements(existing_packages):
47+
with open(REPO / "requirements-build.txt", "r") as f:
48+
deps = f.read().splitlines()
49+
50+
filtered_deps = [dep for dep in deps if not matches_existing(dep, existing_packages)]
51+
52+
with open(REPO / "requirements-build.txt", "w") as f:
53+
f.write("\n".join(filtered_deps))
3954

4055

4156
def filter_deps(deps, existing_packages):
4257
to_remove = set()
4358
for dep in deps:
44-
if any(dep.startswith(p) for p in existing_packages):
59+
if matches_existing(dep, existing_packages):
4560
to_remove.add(dep)
4661
for dep in to_remove:
4762
deps.remove(dep)
4863
return to_remove
4964

5065

66+
def matches_existing(spec, existing_packages):
67+
return any(spec.startswith(p) for p in existing_packages)
68+
69+
70+
5171
if __name__ == "__main__":
5272
main()

0 commit comments

Comments
 (0)