Skip to content

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.

2 participants