Skip to content

Commit

Permalink
Modernize setup (#38)
Browse files Browse the repository at this point in the history
Modernize the setup / install process:

* Introduce a `pyproject.toml` file with `[build-system]` information
  to allow PEP517 - compatible builds

* Move from `setup.json` to `setup.cfg`. The combined `dev` extra
  dependency is still handled in `setup.py` because there is no
  syntax to combine extras in `setup.cfg`

* Single-source the version from ``__init__.py`` using the `attr:` 
  command in `setup.cfg`, and remove the version consistency
  check

* Update list of authors

* Add missing `astroid` dependency

* Fix some minor linting issues

Co-authored-by: Daniel Marchand <t-dmarchand@microsoft.com>
Co-authored-by: Dominik Gresch <a-dogres@microsoft.com>
  • Loading branch information
3 people committed Oct 26, 2020
1 parent bea61f0 commit 80845b2
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 236 deletions.
2 changes: 1 addition & 1 deletion .ci/install_aiida_github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
git clone https://github.com/aiidateam/aiida_core ../aiida_core
cd ../aiida_core
git checkout $AIIDA_DEVELOP_GIT_HASH
pip install -e .[docs,pre-commit,testing]
pip install -e .[docs,pre_commit,testing]
cd ${TRAVIS_BUILD_DIR}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre-commit,docs,testing]
pip install -e .[pre_commit,docs,testing]
reentry scan -r aiida
- name: Run pre-commit
run: |
Expand Down
12 changes: 0 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,3 @@ repos:
types: [file, python]
language: system
exclude: '^(docs/)|(examples/)|(utils/fastentrypoints.py)'

- id: version-number
name: Check version numbers
entry: python ./utils/validate_version_consistency.py
language: system
files: >-
(?x)^(
setup.json|
utils/validate_version_consistency.py|
aiida_testing/__init__.py
)$
pass_filenames: false
2 changes: 1 addition & 1 deletion docs/source/developer_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Automatic coding style checks

Enable enable automatic checks of code sanity and coding style::

pip install -e .[pre-commit]
pip install -e .[pre_commit]
pre-commit install

After this, the `yapf <https://github.com/google/yapf>`_ formatter,
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools >= 46.4.0", "wheel", "fastentrypoints"]
build-backend = "setuptools.build_meta"
58 changes: 58 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[metadata]
name = aiida-testing
author = Dominik Gresch, Leopold Talirz, Jens Bröder, Philipp Rüßmann, and the AiiDA team
author_email =
version = attr: aiida_testing.__version__
url = https://aiida-testing.readthedocs.io/
description = Helpers for testing AiiDA plugins using pytest
long_description = file: README.md
long_description_content_type = text/markdown
keywords =
AiiDA
testing
pytest
mock
cache
license = MIT
classifiers =
Development Status :: 3 - Alpha
Environment :: Plugins
Intended Audience :: Science/Research
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Topic :: Scientific/Engineering :: Physics
Framework :: AiiDA
Framework :: Pytest

[options]
python_requires = >=3.6
include_package_data = true
install_requires =
aiida-core>=1.0.0<2.0.0
pytest>=3.6
pyyaml~=5.1.2
voluptuous~=0.11.7

[options.extras_require]
docs =
sphinx
sphinx-rtd-theme
testing =
pgtest~=1.3.1
aiida-diff
pytest-datadir
pre_commit =
astroid==2.2.5
yapf==0.28
pre-commit
prospector==1.1.7
pylint==2.3.1
mypy==0.740


[options.entry_points]
console_scripts =
aiida-mock-code = aiida_testing.mock_code._cli:run

59 changes: 0 additions & 59 deletions setup.json

This file was deleted.

42 changes: 18 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python

# Author: Dominik Gresch <greschd@gmx.ch>
"""
usage: pip install .[dev]
"""

import json
import os
from utils import fastentrypoints # NOQA
import warnings

import setuptools
from setuptools.config import read_configuration

from setuptools import find_packages, setup
try:
import fastentrypoints # NOQA
except ImportError:
warnings.warn(
"The 'fastentrypoints' module could not be loaded. "
"Installed console script will be slower."
)

SETUP_JSON_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'setup.json')
with open(SETUP_JSON_PATH, 'r') as json_file:
SETUP_KWARGS = json.load(json_file)
EXTRAS_REQUIRE = SETUP_KWARGS['extras_require']
SETUP_CONFIG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'setup.cfg')
SETUP_KWARGS = read_configuration(SETUP_CONFIG_PATH)
EXTRAS_REQUIRE = SETUP_KWARGS['options']['extras_require']
EXTRAS_REQUIRE['dev'] = (
EXTRAS_REQUIRE["docs"] + EXTRAS_REQUIRE["testing"] + EXTRAS_REQUIRE["pre-commit"]
EXTRAS_REQUIRE["docs"] + EXTRAS_REQUIRE["testing"] + EXTRAS_REQUIRE["pre_commit"]
)

if __name__ == '__main__':
setup(
packages=find_packages(),
long_description=open(
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.md')
).read(),
long_description_content_type="text/markdown",
**SETUP_KWARGS
)
if __name__ == "__main__":
setuptools.setup(extras_require=EXTRAS_REQUIRE)
112 changes: 0 additions & 112 deletions utils/fastentrypoints.py

This file was deleted.

26 changes: 0 additions & 26 deletions utils/validate_version_consistency.py

This file was deleted.

0 comments on commit 80845b2

Please sign in to comment.