diff --git a/.ci_support/environment_mini.yml b/.ci_support/environment_mini.yml index 127279796..f6620267d 100644 --- a/.ci_support/environment_mini.yml +++ b/.ci_support/environment_mini.yml @@ -3,6 +3,6 @@ channels: dependencies: - ase =3.22.1 - coverage -- matplotlib-base =3.7.2 +- matplotlib-base =3.8.2 - numpy =1.26.2 - scipy =1.11.4 diff --git a/.ci_support/release.py b/.ci_support/release.py new file mode 100644 index 000000000..79620758c --- /dev/null +++ b/.ci_support/release.py @@ -0,0 +1,61 @@ +def get_setup_version_and_pattern(setup_content): + depend_lst, version_lst = [], [] + for l in setup_content: + if '==' in l: + lst = l.split('[')[-1].split(']')[0].replace(' ', '').replace('"', '').replace("'", '').split(',') + for dep in lst: + if dep != '\n': + version_lst.append(dep.split('==')[1]) + depend_lst.append(dep.split('==')[0]) + + version_high_dict = {d: v for d, v in zip(depend_lst, version_lst)} + return version_high_dict + + +def get_env_version(env_content): + read_flag = False + depend_lst, version_lst = [], [] + for l in env_content: + if 'dependencies:' in l: + read_flag = True + elif read_flag: + lst = l.replace('-', '').replace(' ', '').replace('\n', '').split("=") + if len(lst) == 2: + depend_lst.append(lst[0]) + version_lst.append(lst[1]) + return {d:v for d, v in zip(depend_lst, version_lst)} + + +def update_dependencies(setup_content, version_low_dict, version_high_dict): + version_combo_dict = {} + for dep, ver in version_high_dict.items(): + if dep in version_low_dict.keys() and version_low_dict[dep] != ver: + version_combo_dict[dep] = dep + ">=" + version_low_dict[dep] + ",<=" + ver + else: + version_combo_dict[dep] = dep + "==" + ver + + setup_content_new = "" + pattern_dict = {d:d + "==" + v for d, v in version_high_dict.items()} + for l in setup_content: + for k, v in pattern_dict.items(): + if v in l: + l = l.replace(v, version_combo_dict[k]) + setup_content_new +=l + return setup_content_new + + +if __name__ == "__main__": + with open('pyproject.toml', "r") as f: + setup_content = f.readlines() + + with open('environment.yml', "r") as f: + env_content = f.readlines() + + setup_content_new = update_dependencies( + setup_content=setup_content, + version_low_dict=get_env_version(env_content=env_content), + version_high_dict=get_setup_version_and_pattern(setup_content=setup_content), + ) + + with open('pyproject.toml', "w") as f: + f.writelines(setup_content_new) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 9f5d698e1..572a0e26f 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -12,7 +12,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: psf/black@stable with: options: "--check --diff" diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index fb5936842..756af1d4e 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest if: (github.actor == 'dependabot[bot]') steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.ref }} # Check out the head of the actual branch, not the PR fetch-depth: 0 # otherwise, you will fail to push refs to dest repo diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3607ace63..c8ff34087 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,15 +22,13 @@ jobs: - uses: actions/setup-python@v2 with: python-version: "3.11" - - name: Install dependencies - run: >- - python -m pip install --user --upgrade setuptools wheel + run: python -m pip install --user --upgrade setuptools wheel - name: Convert dependencies - run: >- - sed -i 's/==/>=/g' setup.py; cat setup.py + run: | + cp .ci_support/environment-old.yml environment.yml + python .ci_support/release.py; cat pyproject.toml - name: Build - run: >- - python setup.py sdist bdist_wheel + run: python setup.py sdist bdist_wheel - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/mini.yml b/.github/workflows/mini.yml index 069022437..d73d362b4 100644 --- a/.github/workflows/mini.yml +++ b/.github/workflows/mini.yml @@ -17,9 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup environment - run: cp .ci_support/environment_mini.yml environment.yml + - uses: actions/checkout@v4 - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: @@ -28,14 +26,11 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: .ci_support/environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f environment.yml - - name: Setup - shell: bash -l {0} - run: | - pip install --no-deps . - name: Test shell: bash -l {0} timeout-minutes: 30 - run: python -m unittest discover tests + run: | + python -m pip install --no-deps . + python -m unittest discover tests diff --git a/.github/workflows/pypicheck.yml b/.github/workflows/pypicheck.yml index da2583c4f..a52449dcc 100644 --- a/.github/workflows/pypicheck.yml +++ b/.github/workflows/pypicheck.yml @@ -14,9 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup environment - run: cp .ci_support/environment.yml environment.yml + - uses: actions/checkout@v4 - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: @@ -25,12 +23,10 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: .ci_support/environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f environment.yml - if: steps.cache.outputs.cache-hit != 'true' - name: Pip check shell: bash -l {0} run: | - pip install --no-deps . - pip check \ No newline at end of file + python -m pip install --no-deps . + python -m pip check \ No newline at end of file diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index aaf5233ec..df5368612 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -45,9 +45,7 @@ jobs: prefix: /usr/share/miniconda3/envs/my-env steps: - - uses: actions/checkout@v2 - - name: Setup environment - run: cp .ci_support/environment.yml environment.yml + - uses: actions/checkout@v4 - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: @@ -56,17 +54,13 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: .ci_support/environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f environment.yml - - name: Setup - shell: bash -l {0} - run: | - pip install --no-deps . - name: Test shell: bash -l {0} timeout-minutes: 30 run: | + python -m pip install --no-deps . coverage run --omit structuretoolkit/_version.py -m unittest discover tests - name: Coverage if: matrix.label == 'linux-64-py-3-10' diff --git a/.github/workflows/unittests_old.yml b/.github/workflows/unittests_old.yml index c11206e69..6060d2bf6 100644 --- a/.github/workflows/unittests_old.yml +++ b/.github/workflows/unittests_old.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: @@ -22,13 +22,11 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: .ci_support/environment-old.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f .ci_support/environment-old.yml - - name: Setup - shell: bash -l {0} - run: pip install --no-deps . - name: Test shell: bash -l {0} timeout-minutes: 30 - run: python -m unittest discover tests + run: | + python -m pip install --no-deps . + python -m unittest discover tests diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..9a3919fed --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,70 @@ +[build-system] +requires = ["ase", "matplotlib", "numpy", "setuptools", "scipy"] +build-backend = "setuptools.build_meta" + +[project] +name = "structuretoolkit" +description = "build, analyse and visualise atomistic structures for materials science" +authors = [ + { name = "Jan Janssen", email = "janssen@mpie.de" }, +] +readme = "README.md" +license = { file = "LICENSE" } +keywords = ["pyiron"] +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Topic :: Scientific/Engineering :: Physics", + "License :: OSI Approved :: BSD License", + "Intended Audience :: Science/Research", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dependencies = [ + "ase==3.22.1", + "matplotlib==3.8.2", + "numpy==1.26.2", + "scipy==1.11.4", +] +dynamic = ["version"] + +[project.urls] +Homepage = "https://github.com/pyiron/structuretoolkit" +Documentation = "https://github.com/pyiron/structuretoolkit" +Repository = "https://github.com/pyiron/structuretoolkit" + +[project.optional-dependencies] +grainboundary = [ + "aimsgb==1.1.0", + "pymatgen==2023.11.12", +] +pyscal = ["pyscal2==2.10.18"] +nglview = ["nglview==3.0.8"] +plotly = ["plotly==5.18.0"] +clusters = ["scikit-learn==1.3.2"] +symmetry = ["spglib==2.1.0"] +surface = [ + "spglib==2.1.0", + "pymatgen==2023.11.12", +] +phonopy = [ + "phonopy==2.20.0", + "spglib==2.1.0", +] +pyxtal = ["pyxtal==0.6.1"] + +[tool.setuptools] +packages = ["structuretoolkit"] + +[tool.setuptools.dynamic] +version = {attr = "structuretoolkit.__version__"} + +[tool.versioneer] +VCS = "git" +style = "pep440-pre" +versionfile_source = "structuretoolkit/_version.py" +parentdir_prefix = "structuretoolkit" +tag_prefix = "structuretoolkit-" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b516ae651..000000000 --- a/setup.cfg +++ /dev/null @@ -1,13 +0,0 @@ - -# See the docstring in versioneer.py for instructions. Note that you must -# re-run 'versioneer.py setup' after changing this section, and commit the -# resulting files. - -[versioneer] -VCS = git -style = pep440-pre -versionfile_source = structuretoolkit/_version.py -#versionfile_build = -tag_prefix = structuretoolkit- -parentdir_prefix = structuretoolkit - diff --git a/setup.py b/setup.py index 20815a039..fc1f76c84 100644 --- a/setup.py +++ b/setup.py @@ -1,50 +1,3 @@ -""" -Setuptools based setup module -""" -from setuptools import setup, find_packages -import versioneer +from setuptools import setup -setup( - name='structuretoolkit', - version=versioneer.get_version(), - description='structuretoolkit - to analyse, build and visualise atomistic structures.', - long_description='http://pyiron.org', - - url='https://github.com/pyiron/structuretoolkit', - author='Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department', - author_email='janssen@mpie.de', - license='BSD', - - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Topic :: Scientific/Engineering :: Physics', - 'License :: OSI Approved :: BSD License', - 'Intended Audience :: Science/Research', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11' - ], - - keywords='pyiron', - packages=find_packages(exclude=["*tests*", "*docs*", "*binder*", "*conda*", "*notebooks*", "*.ci_support*"]), - install_requires=[ - 'ase==3.22.1', - 'matplotlib==3.8.2', # ase already requires matplotlib - 'numpy==1.26.2', # ase already requires numpy - 'scipy==1.11.4', # ase already requires scipy - ], - extras_require={ - "grainboundary": ['aimsgb==1.1.0', 'pymatgen==2023.11.12'], - "pyscal": ['pyscal2==2.10.18'], - "nglview": ['nglview==3.0.8'], - "plotly": ['plotly==5.18.0'], - "clusters": ['scikit-learn==1.3.2'], - "symmetry": ['spglib==2.1.0'], - "surface": ['spglib==2.1.0', 'pymatgen==2023.11.12'], - "phonopy": ['phonopy==2.20.0', 'spglib==2.1.0'], - "pyxtal": ['pyxtal==0.6.1'] - }, - cmdclass=versioneer.get_cmdclass(), -) +setup() \ No newline at end of file diff --git a/structuretoolkit/__init__.py b/structuretoolkit/__init__.py index cf64fdab7..470edb17b 100644 --- a/structuretoolkit/__init__.py +++ b/structuretoolkit/__init__.py @@ -1,3 +1,5 @@ +from . import _version + # Analyse from structuretoolkit.analyse import ( find_mic, @@ -73,3 +75,5 @@ grainboundary as grainboundary_build, sqs_structures as get_sqs_structures, ) + +__version__ = _version.get_versions()["version"] diff --git a/structuretoolkit/analyse/spatial.py b/structuretoolkit/analyse/spatial.py index 252819a1f..da9299fd3 100644 --- a/structuretoolkit/analyse/spatial.py +++ b/structuretoolkit/analyse/spatial.py @@ -174,7 +174,7 @@ def __init__( var_ratio=5, min_samples=None, neigh_args={}, - **kwargs + **kwargs, ): """ @@ -333,7 +333,7 @@ def get_interstitials( var_ratio=5, min_samples=None, neigh_args={}, - **kwargs + **kwargs, ): return Interstitials( structure=structure, @@ -347,7 +347,7 @@ def get_interstitials( var_ratio=var_ratio, min_samples=min_samples, neigh_args=neigh_args, - **kwargs + **kwargs, )