Skip to content

Commit

Permalink
DevOps: adopt PEP 621 and move build spec to pyproject.toml (#18)
Browse files Browse the repository at this point in the history
Following PEP 621 it is now possible to fully define the build procedure
of your package in `pyproject.toml`. Since this PEP is now well
supported, and for example `pip` can use it, we migrate to it since it
provides a bunch of benefits:

 * No longer need the deprecated `setup.py` to install the package,
   nor the custom `setup.json`.
 * Version number and description are now dynamically fetched from the
   package. So there is no need to manually update the `setup.json` and
   there is no need for the custom version validation utility script.
 * The `MANIFEST.in` is no longer necessary. The `flit` build tool will
   automatically include anything. The `pyproject.toml` has a tool
   section for `flit` that excludes the `tests` and `docs` folders.
* All configuration of tools are consolidated in `pyproject.toml`. This
  allows to remove `.style.yapf` and configuration options in the
  `.pre-commit-config.yaml`.

Also the `LICENSE` file is renamed to `LICENSE.txt` to use a correct
file extension.
  • Loading branch information
sphuber authored Feb 3, 2023
1 parent a77232b commit a61a743
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 184 deletions.
26 changes: 4 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,28 @@ repos:
rev: '0.55'
hooks:
- id: flynt
args: [
'--line-length=120',
'--fail-on-change',
]

- repo: https://github.com/PyCQA/pydocstyle
rev: 5.0.2
rev: 6.1.1
hooks:
- id: pydocstyle
additional_dependencies: ['toml']
exclude: &exclude_files >
(?x)^(
aiida_abinit/parsers/.*|
docs/.*|
tests/.*(?<!\.py)|
examples/.*(?<!\.py)$
)$
args: ['--ignore=D104,D202,D203,D213']

- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.30.0
rev: v0.32.0
hooks:
- id: yapf
name: yapf
types: [python]
args: ['-i']
additional_dependencies: ['toml']
exclude: 'docs/source/conf.py'

- repo: https://github.com/PyCQA/pylint
Expand All @@ -50,18 +47,3 @@ repos:
- id: pylint
language: system
exclude: *exclude_files

- repo: local
hooks:
- id: version-number
name: Check consistency in version number
entry: python ./utils/validate_version_number.py
args: ['version']
language: system
files: >-
(?x)^(
setup.json|
aiida_abinit/__init__.py|
./utils/validate_version_number.py|
)$
pass_filenames: false
8 changes: 0 additions & 8 deletions .style.yapf

This file was deleted.

File renamed without changes.
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

108 changes: 100 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,88 @@
[build-system]
requires = ['setuptools>=40.8.0', 'wheel', 'reentry~=1.3', 'fastentrypoints~=0.12']
build-backend = 'setuptools.build_meta:__legacy__'
requires = ['flit_core >=3.4,<4']
build-backend = 'flit_core.buildapi'

[project]
name = 'aiida-abinit'
dynamic = ['description', 'version']
authors = [{name = 'Samuel Ponce', email = 'samuel.pon@gmail.com'}]
readme = 'README.md'
license = {file = 'LICENSE.txt'}
classifiers = [
'Development Status :: 4 - Beta',
'Framework :: AiiDA',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Programming Language :: Python',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
]
keywords = ['aiida', 'abinit']
requires-python = '>=3.8'
dependencies = [
'aiida_core[atomic_tools]~=1.6.3,<3.0.0',
'aiida-pseudo~=0.6.1',
'abipy>=0.8.0',
'packaging',
'psycopg2-binary~=2.8.3',
'pymatgen>=2022.1.20',
'numpy',
'importlib_resources'
]

[project.urls]
Home = 'https://github.com/sponce24/aiida-abinit'
Source = 'https://github.com/sponce24/aiida-abinit'

[project.optional-dependencies]
docs = [
'sphinx',
'docutils',
'sphinx-copybutton~=0.3.0',
'sphinx-book-theme~=0.1.0',
'sphinx-click~=2.7.1'
]
pre-commit = [
'pre-commit~=2.2',
'pylint==2.6.0'
]
tests = [
'pgtest~=1.3',
'pytest~=6.0',
'pytest-regressions~=1.0'
]

[project.entry-points.'aiida.calculations']
'abinit' = 'aiida_abinit.calculations:AbinitCalculation'

[project.entry-points.'aiida.parsers']
'abinit' = 'aiida_abinit.parsers:AbinitParser'

[project.entry-points.'aiida.workflows']
'abinit.base' = 'aiida_abinit.workflows.base:AbinitBaseWorkChain'

[tool.flit.module]
name = 'aiida_abinit'

[tool.flit.sdist]
exclude = [
'.github/',
'docs/',
'tests/',
]

[tool.flynt]
line-length = 120
fail-on-change = true

[tool.pydocstyle]
ignore = [
'D104',
'D202',
'D203',
'D213'
]

[tool.pylint.format]
max-line-length = 120
Expand Down Expand Up @@ -37,26 +119,36 @@ good-names = [
]

[tool.pytest.ini_options]
minversion = '6.0'
testpaths = [
'tests',
]
filterwarnings = [
'ignore:Creating AiiDA configuration folder.*:UserWarning',
'ignore::DeprecationWarning:frozendict:',
'ignore::DeprecationWarning:pkg_resources:',
'ignore::DeprecationWarning:reentry:',
'ignore::DeprecationWarning:sqlalchemy_utils:',
]
minversion = '6.0'
testpaths = [
'tests',
]

[tool.yapf]
align_closing_bracket_with_visual_indent = true
based_on_style = 'google'
coalesce_brackets = true
column_limit = 120
dedent_closing_brackets = true
indent_dictionary_value = false
split_arguments_when_comma_terminated = true

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py37
envlist = py38
[testenv]
usedevelop=True
[testenv:py{36,37,38,39}]
[testenv:py{38,39}]
extras = tests
commands = pytest {posargs}
Expand Down
56 changes: 0 additions & 56 deletions setup.json

This file was deleted.

35 changes: 0 additions & 35 deletions setup.py

This file was deleted.

53 changes: 0 additions & 53 deletions utils/validate_version_number.py

This file was deleted.

0 comments on commit a61a743

Please sign in to comment.