From 827ea1debda5d0295084c50701b9d56b59abd580 Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Mon, 10 Jun 2024 19:03:03 +0800 Subject: [PATCH 1/3] Initial commit to replace deprecated package with importlib. Add pyproject.toml. --- pyproject.toml | 76 ++++++++++++++++++++++++++++++ src/diffpy/srfit/tests/__init__.py | 4 +- src/diffpy/srfit/version.py | 4 +- 3 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e1b2191d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,76 @@ +[build-system] +requires = ["setuptools>=62.0", "setuptools-git-versioning<2"] +build-backend = "setuptools.build_meta" + +[project] +name = "diffpy.srfit" +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 = "SrFit - Structure refinement from diffraction data" +keywords = "optimization constraints restraints structure refinement complex modeling" +readme = "README.rst" +requires-python = ">=3.10" +classifiers = [ + # List of possible values at + # http://pypi.python.org/pypi?:action=list_classifiers + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Education', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Operating System :: MacOS', + 'Operating System :: POSIX', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Topic :: Scientific/Engineering :: Chemistry', + 'Topic :: Scientific/Engineering :: Physics', + 'Topic :: Software Development :: Libraries', +] + +[project.urls] +Homepage = "https://github.com/diffpy/diffpy.srfit" +Issues = "https://github.com/diffpy/diffpy.srfit/issues" + +[tool.setuptools-git-versioning] +enabled = true +template = "{tag}" +dev_template = "{tag}" +dirty_template = "{tag}" + +[project.scripts] +srfit = "diffpy.srfit:main" + +[tool.setuptools.packages.find] +where = ["src"] # list of folders that contain the packages (["."] by default) +include = ["diffpy*"] # package names should match these glob patterns (["*"] by default) +exclude = ["diffpy.srfit.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?$' +exclude = ''' +/( + \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + + # The following are specific to Black, you probably don't want those. + | blib2to3 + | tests/data +)/ +''' diff --git a/src/diffpy/srfit/tests/__init__.py b/src/diffpy/srfit/tests/__init__.py index 845b5c39..2b476c95 100644 --- a/src/diffpy/srfit/tests/__init__.py +++ b/src/diffpy/srfit/tests/__init__.py @@ -43,9 +43,9 @@ def testsuite(pattern=''): import re from os.path import dirname from itertools import chain - from pkg_resources import resource_filename + from importlib.resources import files loader = unittest.defaultTestLoader - thisdir = resource_filename(__name__, '') + thisdir = files(__name__) / "" depth = __name__.count('.') + 1 topdir = thisdir for i in range(depth): diff --git a/src/diffpy/srfit/version.py b/src/diffpy/srfit/version.py index 98c20188..63fea4d7 100644 --- a/src/diffpy/srfit/version.py +++ b/src/diffpy/srfit/version.py @@ -26,12 +26,12 @@ import os.path -from pkg_resources import resource_filename +from importlib.resources import files # obtain version information from the version.cfg file cp = dict(version='', date='', commit='', timestamp='0') -fcfg = resource_filename(__name__, 'version.cfg') +fcfg = files(__name__) / "version.cfg" if not os.path.isfile(fcfg): # pragma: no cover from warnings import warn warn('Package metadata not found, execute "./setup.py egg_info".') From f8daec6b9a2d9dd9b438ca8b57c523cd119b2dd3 Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Mon, 10 Jun 2024 19:23:57 +0800 Subject: [PATCH 2/3] Initial commit to replace deprecated package with importlib. Add pyproject.toml. --- pyproject.toml | 1 + src/diffpy/srfit/tests/__init__.py | 3 ++- src/diffpy/srfit/version.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e1b2191d..c45ea829 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,3 +74,4 @@ exclude = ''' | tests/data )/ ''' + diff --git a/src/diffpy/srfit/tests/__init__.py b/src/diffpy/srfit/tests/__init__.py index 2b476c95..391786e8 100644 --- a/src/diffpy/srfit/tests/__init__.py +++ b/src/diffpy/srfit/tests/__init__.py @@ -16,8 +16,8 @@ """Unit tests for diffpy.srfit. """ -import unittest import logging +import unittest # create logger instance for the tests subpackage logging.basicConfig() @@ -82,4 +82,5 @@ def test(): return result + # End of file diff --git a/src/diffpy/srfit/version.py b/src/diffpy/srfit/version.py index 63fea4d7..ebde11de 100644 --- a/src/diffpy/srfit/version.py +++ b/src/diffpy/srfit/version.py @@ -47,6 +47,7 @@ __git_commit__ = cp['commit'] __timestamp__ = int(cp['timestamp']) + # TODO remove deprecated __gitsha__ in version 3.1. __gitsha__ = __git_commit__ From 369b1a8c0f9cfad3294378d059cb3fac27d547cf Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Mon, 10 Jun 2024 19:33:20 +0800 Subject: [PATCH 3/3] Initial commit to replace deprecated package with importlib. Add pyproject.toml. --- .DS_Store | Bin 0 -> 6148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3ca8eddeb869126ac98365444a3115d1c75bb151 GIT binary patch literal 6148 zcmeHK!A{#i5PeH>h%l|-Mh}(z1C7MF7bi`CNR&!-dxpk|s#GaPAwh8Sz5l>3@O?d% zH?ynC-h?9vp&4oRt=IE*JkRp37l7-pCI`SSfDT=-z0GEW$$jxP+X^FZh)(DDg0INY z#S%Ab(KcWTm;x_N0r_?l^za?uaE$u*yBy8SVmvR$jF9D_NALbqV-MKDCo+0C#Sw-$ zA@_)1{%=eo-u)V{K#2=X@B<&Pz!U{$xWu%{bMGTwhm0w%vEu47!yH#p{GTYk&G;Fv z5Y^%SMsY31l_;9CZT*a*5>_~3#Y5Jcv-N9SG&iKyyP8IO5$g;CRqXK@MCJMn2|g=h zghOV{`Ifq@>Z19ys#Tr!mU`aO7p&};D!kMuF8O}uO)fri@qSl(=54OwL*^VXv(&lR zprL48&(~qhl<#H5oL$M?%%Pgs<6DehY}C9S#Uy4=r~vnDu}