From f3cdb5893297ca82bcfd691ab2456b8e4ad1e74c Mon Sep 17 00:00:00 2001 From: Rundong Hua <157993340+stevenhua0320@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:04:31 +0800 Subject: [PATCH] add pyproject.toml (#42) * add pyproject.toml * [pre-commit.ci] auto fixes from pre-commit hooks * update classifiers pyproject.toml * Delete setup.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- diffpy/srmise/modelparts.py | 2 +- pyproject.toml | 54 +++++++++++++++++++ setup.py | 105 ------------------------------------ 3 files changed, 55 insertions(+), 106 deletions(-) delete mode 100755 setup.py diff --git a/diffpy/srmise/modelparts.py b/diffpy/srmise/modelparts.py index 9bd3f14..37d6e0c 100644 --- a/diffpy/srmise/modelparts.py +++ b/diffpy/srmise/modelparts.py @@ -172,7 +172,7 @@ def fit( y, r, (y - self.value(r, range=range)) - 1.1 * (max(y) - min(y)), - *[i for sublist in [[r, p.value(r, range=range)] for p in self] for i in sublist] + *[i for sublist in [[r, p.value(r, range=range)] for p in self] for i in sublist], ) plt.draw() diff --git a/pyproject.toml b/pyproject.toml index 3239179..897eb5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,55 @@ +[build-system] +requires = ["setuptools>=62.0", "setuptools-git-versioning<2"] +build-backend = "setuptools.build_meta" + +[project] +name = "diffpy.srmise" +dynamic=['version'] +authors = [ + { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, +] +maintainers = [ + { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, +] +description = "Peak extraction and peak fitting tool for atomic pair distribution functions." +keywords = ['peak extraction fitting PDF AIC multimodeling'] +readme = "README.rst" +requires-python = ">=3.10" +classifiers = [ + 'Development Status :: 3 - Alpha', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'Intended Audience :: Education', + 'License :: OSI Approved :: BSD License', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX', + 'Operating System :: Unix', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Topic :: Scientific/Engineering :: Physics', + 'Topic :: Scientific/Engineering :: Chemistry', + 'Topic :: Software Development :: Libraries', +] + +[project.urls] +Homepage = "https://github.com/diffpy/diffpy.srmise/" +Issues = "https://github.com/diffpy/diffpy.srmise/issues/" + +[tool.setuptools-git-versioning] +enabled = true +template = "{tag}" +dev_template = "{tag}" +dirty_template = "{tag}" + +[tool.setuptools.packages.find] +where = ["src"] # list of folders that contain the packages (["."] by default) +include = ["*"] # package names should match these glob patterns (["*"] by default) +exclude = ["diffpy.srmise.tests*"] # exclude packages matching these glob patterns (empty by default) +namespaces = false # to disable scanning PEP 420 namespaces (true by default) + [tool.black] line-length = 115 include = '\.pyi?$' @@ -8,6 +60,8 @@ exclude = ''' | \.mypy_cache | \.tox | \.venv + | \.rst + | \.txt | _build | buck-out | build diff --git a/setup.py b/setup.py deleted file mode 100755 index 9828c76..0000000 --- a/setup.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env python - -# Installation script for diffpy.srmise - -"""diffpy.srmise - Peak extraction/fitting tool for pair distribution functions - -Packages: diffpy.srmise -""" - -import os - -from setuptools import find_packages, setup - -# versioncfgfile holds version data for git commit hash and date. -# It must reside in the same directory as version.py. -MYDIR = os.path.dirname(os.path.abspath(__file__)) -versioncfgfile = os.path.join(MYDIR, "diffpy/srmise/version.cfg") - - -def gitinfo(): - from subprocess import PIPE, Popen - - kw = dict(stdout=PIPE, cwd=MYDIR) - proc = Popen(["git", "describe", "--match=v[[:digit:]]*"], **kw) - desc = proc.stdout.read() - proc = Popen(["git", "log", "-1", "--format=%H %at %ai"], **kw) - glog = proc.stdout.read() - rv = {} - rv["version"] = "-".join(desc.strip().split("-")[:2]).lstrip("v") - rv["commit"], rv["timestamp"], rv["date"] = glog.strip().split(None, 2) - return rv - - -def getversioncfg(): - from ConfigParser import SafeConfigParser - - cp = SafeConfigParser() - cp.read(versioncfgfile) - gitdir = os.path.join(MYDIR, ".git") - if not os.path.isdir(gitdir): - return cp - try: - g = gitinfo() - except OSError: - return cp - d = cp.defaults() - if g["version"] != d.get("version") or g["commit"] != d.get("commit"): - cp.set("DEFAULT", "version", g["version"]) - cp.set("DEFAULT", "commit", g["commit"]) - cp.set("DEFAULT", "date", g["date"]) - cp.set("DEFAULT", "timestamp", g["timestamp"]) - cp.write(open(versioncfgfile, "w")) - return cp - - -versiondata = getversioncfg() - -# define distribution, but make this module importable -setup_args = dict( - name="diffpy.srmise", - version=versiondata.get("DEFAULT", "version"), - namespace_packages=["diffpy"], - packages=find_packages(), - include_package_data=True, - zip_safe=False, - # Dependencies - # numpy - # scipy - # matplotlib >= 1.1.0 - install_requires=["matplotlib >= 1.1.0", "numpy", "scipy"], - # other arguments here... - entry_points={ - "console_scripts": [ - "srmise = diffpy.srmise.applications.extract:main", - "srmiseplot = diffpy.srmise.applications.plot:main", - ] - }, - author="Luke Granlund", - author_email="luke.r.granlund@gmail.com", - description=("Peak extraction and peak fitting tool for atomic " "pair distribution functions."), - license="BSD-style license", - url="https://github.com/diffpy/diffpy.srmise/", - keywords="peak extraction fitting PDF AIC multimodeling", - classifiers=[ - # List of possible values at - # http://pypi.python.org/pypi?:action=list_classifiers - "Development Status :: 3 - Alpha", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: BSD License", - "Operating System :: MacOS", - "Operating System :: POSIX", - "Operating System :: Microsoft :: Windows", - "Programming Language :: Python :: 2.6", - "Programming Language :: Python :: 2.7", - "Topic :: Scientific/Engineering :: Chemistry", - "Topic :: Scientific/Engineering :: Physics", - "Topic :: Software Development :: Libraries", - ], -) - -if __name__ == "__main__": - setup(**setup_args)