Skip to content

Commit 08a3af0

Browse files
committed
convert flow.laplace to cython
1 parent 563bc1d commit 08a3af0

5 files changed

Lines changed: 479 additions & 168 deletions

File tree

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
prune **
2+
recursive-include tests *.py
3+
recursive-include src/anaflow *.py *.pyx
4+
include LICENSE README.md pyproject.toml setup.py

pyproject.toml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
[build-system]
22
requires = [
3-
"hatchling>=1.8.0",
4-
"hatch-vcs",
3+
"setuptools>=64",
4+
"wheel",
5+
"Cython>=3",
6+
"numpy>=2",
7+
"scipy>=1.1.0",
8+
"pentapy>=1.1.0,<2",
9+
"setuptools_scm[toml]>=7",
510
]
6-
build-backend = "hatchling.build"
11+
build-backend = "setuptools.build_meta"
712

813
[project]
914
requires-python = ">=3.8"
1015
name = "anaflow"
1116
authors = [{name = "Sebastian Mueller", email = "sebastian.mueller@ufz.de"}]
1217
readme = "README.md"
13-
license = "MIT"
18+
license = { text = "MIT License" }
1419
dynamic = ["version"]
1520
description = "AnaFlow - analytical solutions for the groundwater-flow equation."
1621
classifiers = [
1722
"Development Status :: 5 - Production/Stable",
1823
"Intended Audience :: Developers",
1924
"Intended Audience :: End Users/Desktop",
2025
"Intended Audience :: Science/Research",
21-
"License :: OSI Approved :: MIT License",
2226
"Natural Language :: English",
2327
"Operating System :: MacOS",
2428
"Operating System :: MacOS :: MacOS X",
@@ -40,7 +44,7 @@ classifiers = [
4044
"Topic :: Utilities",
4145
]
4246
dependencies = [
43-
"numpy>=1.14.5",
47+
"numpy>=2",
4448
"pentapy>=1.1.0,<2",
4549
"scipy>=1.1.0",
4650
]
@@ -69,25 +73,18 @@ Tracker = "https://github.com/GeoStat-Framework/anaflow/issues"
6973
Changelog = "https://github.com/GeoStat-Framework/anaflow/blob/main/CHANGELOG.md"
7074
Conda-Forge = "https://anaconda.org/conda-forge/anaflow"
7175

72-
[tool.hatch.version]
73-
source = "vcs"
74-
fallback_version = "0.0.0.dev0"
76+
[tool.setuptools]
77+
package-dir = {"" = "src"}
7578

76-
[tool.hatch.version.raw-options]
77-
local_scheme = "no-local-version"
79+
[tool.setuptools.packages.find]
80+
where = ["src"]
7881

79-
[tool.hatch.build.hooks.vcs]
80-
version-file = "src/anaflow/_version.py"
81-
template = "__version__ = '{version}'"
82-
83-
[tool.hatch.build.targets.sdist]
84-
include = [
85-
"/src",
86-
"/tests",
87-
]
82+
[tool.setuptools.package-data]
83+
"anaflow.flow" = ["*.pyx", "*.pxd"]
8884

89-
[tool.hatch.build.targets.wheel]
90-
packages = ["src/anaflow"]
85+
[tool.setuptools_scm]
86+
write_to = "src/anaflow/_version.py"
87+
write_to_template = "__version__ = '{version}'"
9188

9289
[tool.isort]
9390
profile = "black"

setup.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from __future__ import annotations
2+
3+
from pathlib import Path
4+
5+
import numpy as np
6+
from Cython.Build import cythonize
7+
from setuptools import Extension, setup
8+
9+
SRC_DIR = Path("src")
10+
MODULE_PATH = SRC_DIR / "anaflow" / "flow"
11+
MODULE_NAME = "anaflow.flow._laplace_accel"
12+
13+
extensions = [
14+
Extension(
15+
MODULE_NAME,
16+
[str(MODULE_PATH / "_laplace_accel.pyx")],
17+
include_dirs=[np.get_include()],
18+
)
19+
]
20+
21+
extensions = cythonize(
22+
extensions,
23+
language_level=3,
24+
compiler_directives={
25+
"boundscheck": False,
26+
"wraparound": False,
27+
"initializedcheck": False,
28+
},
29+
)
30+
31+
setup(ext_modules=extensions, package_dir={"": "src"})

0 commit comments

Comments
 (0)