Skip to content
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

Modernize python build configuration #290

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MilesCranmer
Copy link

@MilesCranmer MilesCranmer commented Apr 29, 2024

Moves much of setup.py to pyproject.toml which is required for many tools to install the package. It is backwards compatible though.

The versioning is also handled by pyproject.toml now which helps create finer-grained development versions if you are building locally (so they are not assumed to be the same as the release version).

@kburns

Comment on lines +188 to +214
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,
}

Copy link
Author

Choose a reason for hiding this comment

The 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!)

@MilesCranmer
Copy link
Author

Friendly ping @kburns

@MilesCranmer
Copy link
Author

Ping @kburns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants