Skip to content

Commit

Permalink
Transition to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Nov 13, 2024
1 parent e3fddf2 commit f294626
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 119 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,28 @@ jobs:
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}

- uses: actions/cache@v4
if: startsWith(runner.os, 'macOS')
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}

- uses: actions/cache@v4
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('**/*requirements.txt') }}
key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install numpy wheel
pip install -r requirements.txt
pip install -r dev-requirements.txt
pip install .[development,ase,biopython]
# Note the use of the -Wa flag to show DeprecationWarnings
# We test the package as-installed.
- name: Unit tests
- name: Unit tests and doctests
env:
MATERIALS_PROJECT_API_KEY: ${{ secrets.MATERIALS_PROJECT_API_KEY }}
run: |
Expand All @@ -67,14 +65,8 @@ jobs:
python -Wa -m pytest --pyargs crystals --full-trace
- name: Build documentation
run: |
python setup.py build_sphinx
- name: Doctests
run: |
python -m sphinx -b doctest docs build
python -m doctest README.md
run:
sphinx-build -M html docs build/docs

release:
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -93,8 +85,8 @@ jobs:

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r dev-requirements.txt
pip install build
pip install .[development,ase,biopython]
- name: Create release description
run: |
Expand All @@ -103,7 +95,7 @@ jobs:
- name: Create source distribution
run: |
python setup.py sdist
python -m build
- name: Create release
uses: softprops/action-gh-release@v2
Expand Down
6 changes: 4 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ build:

python:
install:
- requirements: requirements.txt
- requirements: dev-requirements.txt
- method: pip
path: .
extra_requirements:
- development
2 changes: 2 additions & 0 deletions crystals/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def chemical_composition(self) -> Dict[str, float]:
Example
-------
>>> from crystals import Crystal
>>> c = Crystal.from_cod(1508819)
>>> c.chemical_composition # doctest: +SKIP
OrderedDict([('H', 0.441),
Expand All @@ -196,6 +197,7 @@ def chemical_formula(self) -> str:
Example
-------
>>> from crystals import Crystal
>>> c = Crystal.from_cod(1508819)
>>> c.chemical_formula
'C15 H19 Cl N4 O4'
Expand Down
3 changes: 2 additions & 1 deletion crystals/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def bounded_reflections(
Examples
--------
>>> from crystals import Crystal
>>> cryst = Crystal.from_database('C')
>>> refls = cryst.bounded_reflections(1.5) # 1.5 inverse Angstroms
>>> list(refls)
Expand Down Expand Up @@ -491,7 +492,7 @@ def cyclic(iterable: Iterable[Any]) -> Iterable[Iterable[Any]]:
Examples
--------
>>> list(cyclic((1,2,3)))
[(1,2,3), (2,3,1), (3,1,2)]
[(1, 2, 3), (3, 1, 2), (2, 3, 1)]
"""
iterable = tuple(iterable)
n = len(iterable)
Expand Down
12 changes: 0 additions & 12 deletions dev-requirements.txt

This file was deleted.

81 changes: 81 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[build-system]
requires = ["build", "setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
version = {attr = "crystals.__version__"}

[project]
name = "crystals"
dynamic = ["version"]
authors = [
{ name="Laurent P. René de Cotret", email="[email protected]" },
]
maintainers = [
{ name="Laurent P. René de Cotret", email="[email protected]" },
]
description = "Data structures for crystallography"
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.7, <4"
dependencies = [
"numpy >= 1.20, < 3",
"spglib >= 1.15, < 3",
"pycifrw >= 4.4.1, < 5",
"requests >= 2, < 3",
]
keywords=["crystallography", "material science", "structural biology"]
classifiers = [
"Environment :: Console",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering :: Bio-Informatics",
]

[project.optional-dependencies]
development = [
"sphinx >= 3",
"sphinx_rtd_theme >= 0.4",
"pytest >= 6",
"wheel",
]
biopython = ["biopython >= 1, <2"]
ase = ["ase >= 3, <4"]

[project.urls]
Documentation = "https://crystals.readthedocs.io/"
Repository = "https://github.com/LaurentRDC/crystals"
"Bug Tracker" = "https://github.com/LaurentRDC/crystals/issues"

[project.scripts]
spam-cli = "crystals.__main__:main"

# See here for an explanation of how to include package data:
# https://setuptools.pypa.io/en/latest/userguide/datafiles.html#package-data
[tool.setuptools.package-data]
crystals = ["cifs/*.cif"]

[tool.black]
line-length = 120
include = '\.pyi?$'

[tool.isort]
profile = "black"

[tool.pytest.ini_options]
minversion = "6.0"
log_cli_level = "INFO"
# Very cool ability for pytest to also run doctests on package contents with `-doctest-modules`
addopts = [
"--doctest-modules",
]
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

80 changes: 0 additions & 80 deletions setup.py

This file was deleted.

0 comments on commit f294626

Please sign in to comment.