From ee5747dc3840ecd1fba3b75fffdb79ab7d2345a8 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel) YANG" Date: Wed, 9 Oct 2024 23:28:45 +0800 Subject: [PATCH] Migrate setup.py to pyproject.toml (#950) * add python 3.12 * migrate project section and scm plugin * migrate classifiers * migrate dependencies * test path * migrate package and packaga-data (default True) * clear long description as readme * remove obsolete zip_safe https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html * simplify test workflow as build time dep install is not needed * NEED CONFIRM: remove "Intended Audience :: System Administrators" * cleaner declare of extra tests Co-authored-by: Matthew Evans <7916000+ml-evs@users.noreply.github.com> --------- Co-authored-by: Matthew Evans <7916000+ml-evs@users.noreply.github.com> --- .github/workflows/test.yml | 9 ++-- pyproject.toml | 71 ++++++++++++++++++++++++++++++-- setup.py | 84 -------------------------------------- 3 files changed, 72 insertions(+), 92 deletions(-) delete mode 100644 setup.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d960bd4bc..ac383f12c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ -# This workflow runs only on Ubuntu and aims to be more complete than the Mac and Windows workflows. -# In particular, Openbabel and many of the external command line dependencies are included for testing.defaults: +# This workflow runs only on Ubuntu and aims to be more complete than the MacOS and Windows workflows. +# In particular, Open Babel and many of the external command line dependencies are included for testing.defaults: # The ext package is also only tested in this workflow. Coverage is also computed based on this platform. name: Testing @@ -61,14 +61,14 @@ jobs: - name: Install Python dependencies run: | - python${{ matrix.python-version }} -m pip install --upgrade pip pip-tools setuptools setuptools_scm + python${{ matrix.python-version }} -m pip install --upgrade pip pip-tools python${{ matrix.python-version }} -m piptools sync --user requirements/ubuntu-latest_py${{ matrix.python-version }}.txt # Using non-editable install for testing building of MANIFEST files python${{ matrix.python-version }} -m pip install --no-deps . - python${{ matrix.python-version }} -m pip install pre-commit - name: linting run: | + python${{ matrix.python-version }} -m pip install pre-commit pre-commit run --all-files - name: Run tests @@ -78,7 +78,6 @@ jobs: - name: Build package if: matrix.python-version == 3.9 run: | - python${{ matrix.python-version }} -m pip install --upgrade pip build setuptools setuptools_scm wheel python${{ matrix.python-version }} -m build auto-gen-release: diff --git a/pyproject.toml b/pyproject.toml index adbe3e6bf..ed30097d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,74 @@ [build-system] -requires = [ - "setuptools>=43.0.0", -] +requires = ["setuptools>=64", "setuptools-scm>=8"] build-backend = "setuptools.build_meta" +[project] +name = "matminer" +description = "matminer is a library that contains tools for data mining in Materials Science" +readme = "README.md" +license = {text = "modified BSD"} +keywords = ["data mining", "materials science", "scientific tools"] +authors = [ + { name = "Anubhav Jain", email = "anubhavster@gmail.com" } +] +requires-python = ">=3.9" +dynamic = ["version"] +classifiers = [ + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "Intended Audience :: Information Technology", + "Operating System :: OS Independent", + "Topic :: Other/Nonlisted Topic", + "Topic :: Scientific/Engineering", +] +dependencies = [ + "numpy>=1.23", + "requests~=2.31", + "pandas>=1.5, <3", + "tqdm~=4.66", + "pymongo~=4.5", + "scikit-learn~=1.3", + "sympy~=1.11", + "monty>=2023", + "pymatgen>=2023", +] + +[project.urls] +"Homepage" = "https://github.com/hackingmaterials/matminer" + + +[project.optional-dependencies] +mpds = ["ujson", "jmespath", "httplib2", "ase", "jsonschema"] +dscribe = ["dscribe~=2.1"] +mdfforge = ["mdf-forge"] +aflow = ["aflow"] +citrine = ["citrination-client"] +dev = [ + "pytest", + "pytest-cov", + "pytest-timeout", + "coverage", + "coveralls", + "flake8", + "black", + "pylint", + "sphinx" +] +tests = ["matminer[mpds,describe,mdfforge,aflow,citrine,dev]"] + +[tool.setuptools_scm] +version_scheme = "guess-next-dev" +local_scheme = "no-local-version" + +[tool.setuptools.packages.find] +where = ["matminer"] + +[tool.pytest.ini_options] +testpaths = ["matminer"] [tool.black] line-length = 120 diff --git a/setup.py b/setup.py deleted file mode 100644 index 7cc859eb6..000000000 --- a/setup.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python - -import os - -from setuptools import find_packages, setup - - -def local_version(version): - # https://github.com/pypa/setuptools_scm/issues/342 - return "" - - -module_dir = os.path.dirname(os.path.abspath(__file__)) - -extras_require = { - "mpds": ["ujson", "jmespath", "httplib2", "ase", "jsonschema"], - "dscribe": ["dscribe~=2.1"], - "mdfforge": ["mdf-forge"], - "aflow": ["aflow"], - "citrine": ["citrination-client"], - "dev": [ - "pytest", - "pytest-cov", - "pytest-timeout", - "coverage", - "coveralls", - "flake8", - "black", - "pylint", - "sphinx", - ], -} -tests_require = [r for v in extras_require.values() for r in v] - -extras_require["tests"] = tests_require - -if __name__ == "__main__": - setup( - name="matminer", - use_scm_version={ - "root": ".", - "relative_to": __file__, - "local_scheme": local_version, - }, - setup_requires=["setuptools_scm"], - description="matminer is a library that contains tools for data mining in Materials Science", - long_description=open(os.path.join(module_dir, "README.md")).read(), - url="https://github.com/hackingmaterials/matminer", - long_description_content_type="text/markdown", - author="Anubhav Jain", - author_email="anubhavster@gmail.com", - license="modified BSD", - packages=find_packages(), - include_package_data=True, - zip_safe=False, - install_requires=[ - "numpy >= 1.23", - "requests ~= 2.31", - "pandas >= 1.5, < 3", - "tqdm ~= 4.66", - "pymongo ~= 4.5", - "scikit_learn ~= 1.3", - "sympy ~= 1.11", - "monty >= 2023", - "pymatgen >= 2023", - ], - extras_require=extras_require, - classifiers=[ - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Development Status :: 4 - Beta", - "Intended Audience :: Science/Research", - "Intended Audience :: System Administrators", - "Intended Audience :: Information Technology", - "Operating System :: OS Independent", - "Topic :: Other/Nonlisted Topic", - "Topic :: Scientific/Engineering", - ], - python_requires=">=3.9", - test_suite="matminer", - tests_require=tests_require, - scripts=[], - )