forked from aiidateam/aiida-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔧 Move to flit for PEP 621 compliant package build (aiidateam#5312)
The build process for python packages has recently been standardised, primarily via [PEP 621](https://www.python.org/dev/peps/pep-0621) (`pyproject.toml` only build specification), and [PEP 660](https://www.python.org/dev/peps/pep-0660) (editable installs via `pyproject.toml`). https://github.com/pypa/flit is a build tool, for pure-python packages, compliant with both of these PEPs. Switching to this build tool allows for the contents of the `setuptools` specific `setup.json`, `setup.py` and `MANIFEST.in` files to be transposed in to `pyproject.toml` and removed. The [fastentrypoints](https://github.com/ninjaaron/fast-entry_points) build requirement has been removed, since with flit the issue it solves is no longer present. The package version is now sourced directly from `aiida/__init__.py`, and so there is no need for any consistency checks, which have been removed. This change also removes the dynamically generated `all` extra, and the logic to append `rest`+`atomic_tools` to the `tests` and `docs` extras, present in the `setup.py`. Note that `pip install --editable .`, requires pip version>=21 for PEP 660 compliance.
- Loading branch information
1 parent
18f6c9a
commit d9f8c85
Showing
20 changed files
with
376 additions
and
481 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Check that the GitHub release tag matches the package version.""" | ||
import argparse | ||
import json | ||
import ast | ||
from pathlib import Path | ||
|
||
|
||
def get_version_from_module(content: str) -> str: | ||
"""Get the __version__ value from a module.""" | ||
# adapted from setuptools/config.py | ||
try: | ||
module = ast.parse(content) | ||
except SyntaxError as exc: | ||
raise IOError(f'Unable to parse module: {exc}') | ||
try: | ||
return next( | ||
ast.literal_eval(statement.value) for statement in module.body if isinstance(statement, ast.Assign) | ||
for target in statement.targets if isinstance(target, ast.Name) and target.id == '__version__' | ||
) | ||
except StopIteration: | ||
raise IOError('Unable to find __version__ in module') | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('GITHUB_REF', help='The GITHUB_REF environmental variable') | ||
parser.add_argument('SETUP_PATH', help='Path to the setup.json') | ||
args = parser.parse_args() | ||
assert args.GITHUB_REF.startswith('refs/tags/v'), f'GITHUB_REF should start with "refs/tags/v": {args.GITHUB_REF}' | ||
tag_version = args.GITHUB_REF[11:] | ||
with open(args.SETUP_PATH, encoding='utf8') as handle: | ||
data = json.load(handle) | ||
pypi_version = data['version'] | ||
assert tag_version == pypi_version, f'The tag version {tag_version} != {pypi_version} specified in `setup.json`' | ||
pypi_version = get_version_from_module(Path('aiida/__init__.py').read_text(encoding='utf-8')) | ||
assert tag_version == pypi_version, f'The tag version {tag_version} != {pypi_version} specified in `pyproject.toml`' |
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.