-
Notifications
You must be signed in to change notification settings - Fork 131
Modernize python build configuration #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MilesCranmer
wants to merge
1
commit into
DedalusProject:master
Choose a base branch
from
MilesCranmer:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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, | ||
} | ||
|
||
Comment on lines
+188
to
+214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (The same one I use for PySR, so I can confirm this works!) |
||
|
||
# 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}) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.