Skip to content

Commit 00b86ef

Browse files
Migrate to pyproject (#575)
* migrate to pyproject setup * fix typo in prototypes + add latex-->unicode decoding for special chars
1 parent 091cea7 commit 00b86ef

File tree

10 files changed

+127
-121
lines changed

10 files changed

+127
-121
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
- name: Install dependencies
2121
run: |
2222
conda install --quiet --yes -c conda-forge openbabel pip ruamel.yaml
23-
pip install -r requirements.txt
24-
pip install -e .[tests]
23+
pip install -e .[strict,tests]
2524
2625
- name: Test
27-
run: pytest
26+
run: pytest -n auto tests
2827

2928
- name: Build packages
3029
run: |
31-
python setup.py sdist bdist_wheel
30+
pip install --upgrade build
31+
python -m build
3232
3333
- name: Publish
3434
uses: pypa/gh-action-pypi-publish@master

.github/workflows/tests.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ jobs:
2424
shell: bash -l {0}
2525
run: |
2626
conda install --quiet --yes -c conda-forge openbabel pip ruamel.yaml
27-
python${{ matrix.python-version }} -m pip install -r requirements.txt
28-
python${{ matrix.python-version }} -m pip install -e .[tests,cli]
27+
python${{ matrix.python-version }} -m pip install -e .[strict,tests,cli]
2928
3029
- name: Test
3130
shell: bash -l {0}
32-
run: python${{ matrix.python-version }} -m pytest --cov=robocrys --cov-report=xml --cov-config=.coveragerc tests/
31+
run: python${{ matrix.python-version }} -m pytest -n auto --cov=robocrys --cov-report=xml --cov-config=.coveragerc tests/
3332

3433
docs:
3534
runs-on: ubuntu-latest
@@ -44,8 +43,7 @@ jobs:
4443
- name: Install dependencies
4544
run: |
4645
python -m pip install --upgrade pip
47-
pip install -r requirements.txt
48-
pip install -e .[docs,cli]
46+
pip install -e .[strict,docs,cli]
4947
5048
- name: Build
5149
run: sphinx-build docs/src docs_build

.mypy.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

pyproject.toml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
[build-system]
3+
requires = ["setuptools>=80.0.0","setuptools-scm>=8"]
4+
build-backend = "setuptools.build_meta"
5+
6+
[tool.setuptools_scm]
7+
root = "."
8+
relative_to = "__file__"
9+
10+
[tool.setuptools]
11+
include-package-data = true
12+
13+
[tool.setuptools.packages.find]
14+
where = ["."]
15+
exclude = ["tests", "docs", "dev_scripts"]
16+
include = ["robocrys"]
17+
18+
[tool.setuptools.package-data]
19+
"robocrys.condense" = ["*.json.gz"]
20+
21+
[project]
22+
name = "robocrys"
23+
dynamic = ["version"]
24+
requires-python = ">=3.10"
25+
description="Automatic generation of crystal structure descriptions"
26+
license = {text = "Modified BSD"}
27+
authors = [
28+
{name = "Alex Ganose", email="aganose@lbl.gov"},
29+
]
30+
dependencies = [
31+
"spglib>=2.5.0",
32+
"numpy",
33+
"scipy",
34+
"pymatgen>=2024.1.26",
35+
"inflect",
36+
"networkx",
37+
"matminer>=0.9.2",
38+
"monty",
39+
"pubchempy",
40+
"pybtex",
41+
]
42+
classifiers=[
43+
"Development Status :: 3 - Alpha",
44+
"Intended Audience :: Science/Research",
45+
"Intended Audience :: Information Technology",
46+
"License :: OSI Approved :: MIT License",
47+
"Natural Language :: English",
48+
"Programming Language :: Python :: 3 :: Only",
49+
"Programming Language :: Python :: 3.10",
50+
"Programming Language :: Python :: 3.11",
51+
"Programming Language :: Python :: 3.12",
52+
"Topic :: Scientific/Engineering :: Chemistry",
53+
"Topic :: Scientific/Engineering :: Physics",
54+
"Topic :: Scientific/Engineering",
55+
"Topic :: Other/Nonlisted Topic",
56+
"Operating System :: OS Independent",
57+
]
58+
keywords=["crystal-structure", "crystallography", "materials-science"]
59+
60+
[project.urls]
61+
Homepage = "https://github.com/hackingmaterials/robocrystallographer"
62+
Documentation = "https://hackingmaterials.lbl.gov/robocrystallographer/"
63+
64+
[project.optional-dependencies]
65+
docs = [
66+
"sphinx>=5.3.0",
67+
"sphinx-argparse==0.5.2",
68+
"sphinx_rtd_theme==3.0.2",
69+
"sphinx-autodoc-typehints==3.0.1",
70+
]
71+
dev = ["tqdm", "pybel", "pebble", "maggma"]
72+
tests = ["pytest", "pytest-cov", "pytest-xdist"]
73+
cli = ["mp_api"]
74+
lint = [
75+
"coverage==7.11.0",
76+
"codacy-coverage==1.3.11",
77+
"pycodestyle==2.14.0",
78+
"mypy==1.18.2",
79+
"pydocstyle==6.1.1",
80+
"flake8==7.3.0",
81+
"pylint==4.0.2",
82+
"black==25.9.0",
83+
]
84+
strict = [
85+
"spglib==2.6.0",
86+
"numpy==2.2.6,",
87+
"scipy==1.15.3",
88+
"pymatgen==2025.10.7",
89+
"inflect==7.5.0",
90+
"networkx==3.4.2",
91+
"matminer==0.9.3",
92+
"monty==2025.3.3",
93+
"pubchempy==1.0.5",
94+
"pybtex==0.25.1",
95+
]
96+
97+
[project.scripts]
98+
robocrys = "robocrys.cli:main"
99+
100+
[tool.mypy]
101+
ignore_missing_imports = true

requirements.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

robocrys/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55

66
from __future__ import annotations
77

8-
from robocrys._version import __version__
8+
from importlib.metadata import PackageNotFoundError, version
9+
910
from robocrys.condense.condenser import StructureCondenser
1011
from robocrys.describe.describer import StructureDescriber
1112
from robocrys.util import common_formulas
1213

1314
__all__ = ["__version__", "StructureDescriber", "StructureCondenser", "common_formulas"]
15+
16+
try:
17+
__version__ = version("robocrys")
18+
except PackageNotFoundError:
19+
# package is not installed
20+
pass

robocrys/_version.py

Lines changed: 0 additions & 6 deletions
This file was deleted.
1 Byte
Binary file not shown.

robocrys/describe/describer.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,18 @@ def get_mineral_description(self) -> str:
171171
spg_symbol = htmlify_spacegroup(self._da.spg_symbol)
172172
formula = htmlify(formula)
173173

174-
mineral_name = get_mineral_name(self._da.mineral)
174+
if mineral_name := get_mineral_name(self._da.mineral):
175+
# replace latex-like characters with unicode
176+
latex_reps = {
177+
"$\\mu$": "\u03BC",
178+
"\\'{c}": "\u0107",
179+
}
180+
if self.fmt in {"html", "unicode"} and any(
181+
k in mineral_name for k in latex_reps
182+
):
183+
for k, v in latex_reps.items():
184+
mineral_name = mineral_name.replace(k, v)
175185

176-
if mineral_name:
177186
desc = f"{formula} is {mineral_name} structured and"
178187
else:
179188
desc = f"{formula}"

setup.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)