-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modernize python build configuration
- Loading branch information
1 parent
d83755b
commit 8265162
Showing
4 changed files
with
87 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,43 @@ | ||
[build-system] | ||
requires = ["cython >= 3.0.5", | ||
"mpi4py >= 2.0.0", | ||
"numpy >= 1.20.0", | ||
"setuptools", | ||
"wheel"] | ||
requires = [ | ||
"Cython >= 3.0.5", | ||
"mpi4py >= 2.0.0", | ||
"numpy >= 1.20.0", | ||
"setuptools", | ||
"wheel" | ||
] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "dedalus" | ||
version = "3.0.2" | ||
authors = [ | ||
{ name = "Keaton J. Burns", email = "[email protected]" } | ||
] | ||
description = "A flexible framework for solving PDEs with modern spectral methods." | ||
long-description = { file = "README.md", content-type = "text/markdown" } | ||
readme = { file = "README.md", content-type = "text/markdown" } | ||
license = { file = "LICENSE", content-type = "text/plain" } | ||
classifiers = ["Programming Language :: Python :: 3"] | ||
requires-python = ">=3.9" | ||
dynamic = ["dependencies"] | ||
|
||
[project.urls] | ||
homepage = "http://dedalus-project.org" | ||
|
||
[project.entry-points."xarray.backends"] | ||
dedalus = "dedalus.tools.post:DedalusXarrayBackend" | ||
|
||
[tool.setuptools] | ||
packages = ["dedalus"] | ||
package-data = { dedalus = ["dedalus.cfg", "examples.tar.gz"] } | ||
|
||
[tool.setuptools.dynamic] | ||
dependencies = {file = "requirements.txt"} | ||
|
||
[project.optional-dependencies] | ||
xarray = ["xarray"] | ||
|
||
[project.scripts] | ||
dedalus = "dedalus.tools.post:DedalusXarrayBackend" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
docopt | ||
h5py >= 3.0.0 | ||
matplotlib | ||
mpi4py >= 2.0.0 | ||
numexpr | ||
numpy >= 1.20.0 | ||
py | ||
pytest | ||
pytest-benchmark | ||
pytest-cov | ||
pytest-parallel | ||
scipy >= 1.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,19 +82,6 @@ def get_lib(name): | |
if prefix := get_library_prefix(name): | ||
return os.path.join(prefix, "lib") | ||
|
||
def get_version(rel_path): | ||
"""Read version from a file via text parsing, following PyPA guide.""" | ||
def read(rel_path): | ||
here = os.path.abspath(os.path.dirname(__file__)) | ||
with codecs.open(os.path.join(here, rel_path), "r") as fp: | ||
return fp.read() | ||
for line in read(rel_path).splitlines(): | ||
if line.startswith("__version__"): | ||
delim = '"' if '"' in line else "'" | ||
return line.split(delim)[1] | ||
else: | ||
raise RuntimeError("Unable to find version string.") | ||
|
||
# Configuratin | ||
INCLUDE_MPI = True | ||
INCLUDE_FFTW = True | ||
|
@@ -179,26 +166,6 @@ def read(rel_path): | |
extra_compile_args=extra_compile_args, | ||
extra_link_args=extra_link_args)) | ||
|
||
# Runtime requirements | ||
install_requires = [ | ||
"docopt", | ||
"h5py >= 3.0.0", | ||
"matplotlib", | ||
"mpi4py >= 2.0.0", | ||
"numexpr", | ||
"numpy >= 1.20.0", | ||
"py", | ||
"pytest", | ||
"pytest-benchmark", | ||
"pytest-cov", | ||
"pytest-parallel", | ||
"scipy >= 1.4.0", | ||
"xarray"] | ||
|
||
# Grab long_description from README | ||
with open("README.md") as f: | ||
long_description = f.read() | ||
|
||
# Cython directives | ||
compiler_directives = {} | ||
compiler_directives["language_level"] = 3 | ||
|
@@ -217,24 +184,38 @@ def run(self): | |
# Run the original build command | ||
_build.run(self) | ||
|
||
# Set version | ||
if os.path.exists(".git"): | ||
# If on a git repository, we can | ||
# get the version from the commit sha | ||
kwargs = { | ||
"use_scm_version": { | ||
"write_to": "dedalus/version.py", | ||
}, | ||
"setup_requires": ["setuptools", "setuptools_scm"], | ||
} | ||
else: | ||
# As a backup, we read from the pyproject.toml | ||
import re | ||
|
||
with open(os.path.join(os.path.dirname(__file__), "pyproject.toml")) as f: | ||
data = f.read() | ||
version = re.search(r'version = "(.*)"', data).group(1) | ||
# TODO: When limited to Python 3.11, can use tomllib from the standard library | ||
|
||
# Write the version to version.py | ||
with open(os.path.join(os.path.dirname(__file__), "dedalus", "version.py"), "w") as f: | ||
f.write(f'__version__ = "{version}"') | ||
|
||
kwargs = { | ||
"use_scm_version": False, | ||
"version": version, | ||
} | ||
|
||
|
||
# Setup | ||
print() | ||
setup( | ||
name="dedalus", | ||
version=get_version("dedalus/__init__.py"), | ||
author="Keaton J. Burns", | ||
author_email="[email protected]", | ||
description="A flexible framework for solving PDEs with modern spectral methods.", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="http://dedalus-project.org", | ||
classifiers=["Programming Language :: Python :: 3"], | ||
python_requires=">=3.9", | ||
install_requires=install_requires, | ||
license="GPL3", | ||
packages=setuptools.find_packages(), | ||
package_data={"": ["dedalus.cfg", "examples.tar.gz"]}, | ||
ext_modules=cythonize(extensions, compiler_directives=compiler_directives), | ||
cmdclass={"build": build}, | ||
entry_points={"xarray.backends": ["dedalus=dedalus.tools.post:DedalusXarrayBackend"]}) | ||
cmdclass={"build": build}) | ||
|