diff --git a/dpx/confutils/config.py b/dpx/confutils/config.py index 03f64cc..f784e7f 100644 --- a/dpx/confutils/config.py +++ b/dpx/confutils/config.py @@ -22,7 +22,7 @@ ''' -import ConfigParser +from configparser import ConfigParser import re import os import sys diff --git a/dpx/confutils/configtraits.py b/dpx/confutils/configtraits.py index a4dda2a..d80d04c 100644 --- a/dpx/confutils/configtraits.py +++ b/dpx/confutils/configtraits.py @@ -22,7 +22,7 @@ Note: for python 2.6, argparse and orderedDict is required, install them with easy_install ''' -import ConfigParser +from configparser import ConfigParser import re import os import sys diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2d09092 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,85 @@ +[build-system] +requires = ["setuptools>=62.0", "setuptools-git-versioning>=2.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "diffpy.srxconfutils" +dynamic=['version', 'dependencies'] +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 = "Configuration utilities for dpx project. Part of xPDFsuite" +keywords = ['diffpy', 'pdf', 'data interpretation'] +readme = "README.rst" +requires-python = ">=3.11, <3.14" +classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX', + 'Operating System :: Unix', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', + 'Topic :: Scientific/Engineering :: Physics', + 'Topic :: Scientific/Engineering :: Chemistry', +] + +[project.urls] +Homepage = "https://github.com/diffpy/diffpy.distanceprinter/" +Issues = "https://github.com/diffpy/diffpy.distanceprinter/issues/" + +[tool.setuptools-git-versioning] +enabled = true +template = "{tag}" +dev_template = "{tag}" +dirty_template = "{tag}" + +[tool.setuptools.packages.find] +where = ["diffpy"] # list of folders that contain the packages (["."] by default) +include = ["*"] # package names should match these glob patterns (["*"] by default) +exclude = [] # exclude packages matching these glob patterns (empty by default) +namespaces = false # to disable scanning PEP 420 namespaces (true by default) + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements/pip.txt"]} + +[tool.codespell] +exclude-file = ".codespell/ignore_lines.txt" +ignore-words = ".codespell/ignore_words.txt" +skip = "*.cif,*.dat,*agr" + +[tool.docformatter] +recursive = true +wrap-summaries = 72 +wrap-descriptions = 72 + +[tool.black] +line-length = 79 +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | \.rst + | \.txt + | _build + | buck-out + | build + | dist + + # The following are specific to Black, you probably don't want those. + | blib2to3 + | tests/data +)/ +''' diff --git a/requirements/pip.txt b/requirements/pip.txt new file mode 100644 index 0000000..f8d7a2e --- /dev/null +++ b/requirements/pip.txt @@ -0,0 +1,4 @@ +numpy +configparser +traits +traitsui \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100755 index 57f2e07..0000000 --- a/setup.py +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env python - -# Installation script for dpx.confutils - -"""dpx.confutils - configuration utilities for dpx project - -Packages: dpx.confutils -Scripts: None -""" - -import os -from setuptools import setup, find_packages -from setuptools.command.build_py import build_py -import py_compile - - -class custom_build_pyc(build_py): - - def byte_compile(self, files): - for file in files: - if file.endswith('.py'): - py_compile.compile(file) - os.unlink(file) - -# Use this version when git data are not available, like in git zip archive. -# Update when tagging a new release. -FALLBACK_VERSION = '1.0' - -# 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, 'dpx', 'confutils', 'version.cfg') -gitarchivecfgfile = versioncfgfile.replace('version.cfg', 'gitarchive.cfg') - - -def gitinfo(): - from subprocess import Popen, PIPE - 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'] = '.post'.join(desc.strip().split('-')[:2]).lstrip('v') - rv['commit'], rv['timestamp'], rv['date'] = glog.strip().split(None, 2) - return rv - - -def getversioncfg(): - import re - from ConfigParser import RawConfigParser - vd0 = dict(version=FALLBACK_VERSION, commit='', date='', timestamp=0) - # first fetch data from gitarchivecfgfile, ignore if it is unexpanded - g = vd0.copy() - cp0 = RawConfigParser(vd0) - cp0.read(gitarchivecfgfile) - if '$Format:' not in cp0.get('DEFAULT', 'commit'): - g = cp0.defaults() - mx = re.search(r'\btag: v(\d[^,]*)', g.pop('refnames')) - if mx: - g['version'] = mx.group(1) - # then try to obtain version data from git. - gitdir = os.path.join(MYDIR, '.git') - if os.path.exists(gitdir) or 'GIT_DIR' in os.environ: - try: - g = gitinfo() - except OSError: - pass - # finally, check and update the active version file - cp = RawConfigParser() - cp.read(versioncfgfile) - d = cp.defaults() - rewrite = not d or (g['commit'] and ( - g['version'] != d.get('version') or g['commit'] != d.get('commit'))) - if rewrite: - 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() - - -def dirglob(d, *patterns): - from glob import glob - rv = [] - for p in patterns: - rv += glob(os.path.join(d, p)) - return rv - -# define distribution -setup_args = dict( - name='dpx.confutils', - cmdclass=dict(build_py=custom_build_pyc), - version=versiondata.get('DEFAULT', 'version'), - namespace_packages=['dpx'], - packages=find_packages(), - include_package_data=True, - zip_safe=False, - entry_points={ - # define console_scripts here, see setuptools docs for details. - }, - - author='Simon J.L. Billinge', - author_email='sb2896@columbia.edu', - description='configuration utilities for dpx project', - maintainer='Xiaohao Yang', - maintainer_email='sodestiny1@gmail.com', - license='see LICENSENOTICE.txt', - url='', - keywords='dpx configuration utilities', - classifiers=[ - # List of possible values at - # http://pypi.python.org/pypi?:action=list_classifiers - 'Development Status :: 5 - Production/Stable', - 'Environment :: MacOS X', - 'Environment :: Win32 (MS Windows)', - 'Environment :: X11 Applications', - 'Intended Audience :: Science/Research', - 'Operating System :: MacOS', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Topic :: Scientific/Engineering :: Physics', - ], -) - -if __name__ == '__main__': - setup(**setup_args) - -# End of file