From 2440e93029e1d1b1472147affff65f57a85ef3cb Mon Sep 17 00:00:00 2001 From: "darren@openstar.nz" Date: Wed, 31 Jan 2024 17:45:22 +0000 Subject: [PATCH 1/6] Change to pyproject.toml with stub setup.py --- python/MDSplus/pyproject.toml | 52 +++++++++++++++++++++++ python/MDSplus/setup.py | 78 +---------------------------------- 2 files changed, 54 insertions(+), 76 deletions(-) create mode 100644 python/MDSplus/pyproject.toml diff --git a/python/MDSplus/pyproject.toml b/python/MDSplus/pyproject.toml new file mode 100644 index 0000000000..6731855ee9 --- /dev/null +++ b/python/MDSplus/pyproject.toml @@ -0,0 +1,52 @@ +[build-system] + requires = ["setuptools>=40.8.0", "wheel"] + build-backend = "setuptools.build_meta" + +[project] + name='MDSplus' + authors = [ + {name = "MDSplus Development Team", email = "twf@www.mdsplus.org"}, + ] + license = {text = "MIT License"} + description = "MDSplus Python Object interface" + classifiers = [ + "Programming Language :: Python", + "Intended Audience :: Science/Research", + "Environment :: Console", + "Topic :: Scientific/Engineering", + "License :: OSI Approved :: MIT License", + ] + keywords=['physics', 'mdsplus'] + dynamic = ["version"] + dependencies = [ + 'numpy', + ] + +[project.urls] + Homepage = "http://www.mdsplus.org/" + Repository = "https://github.com/MDSplus/mdsplus" + Issues = "https://github.com/MDSplus/mdsplus/issues" + +[project.optional-dependencies] + widgets = ["gtk", "gobject"] + +[tool.setuptools] + packages = [ + 'MDSplus', + 'MDSplus.widgets', + 'MDSplus.wsgi', + 'MDSplus.tests', + ] + package-dir = { 'MDSplus' = '.' } + include-package-data = false # use package-data below + +[tool.setuptools.package-data] + '*' = [ + 'wsgi/html/*', + 'wsgi/conf/*', + 'wsgi/js/*', + 'wsgi/*.tbl', + ] + +[tool.setuptools.dynamic] + version = {attr = '_version.version'} diff --git a/python/MDSplus/setup.py b/python/MDSplus/setup.py index 87cd4c496a..52e8781512 100644 --- a/python/MDSplus/setup.py +++ b/python/MDSplus/setup.py @@ -23,80 +23,6 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -import sys -import os - -def setupkw(): - try: - version = () - mod_dir = os.path.dirname(os.path.abspath(__file__)) - with open(os.path.join(mod_dir, '_version.py')) as f: - exec(f.read()) - release = "%d.%d.%d" % version - except Exception: - release = '0.0.0' - release_tag = 'Unknown' - pth_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - return dict( - name='MDSplus', - extra_path=('mdsplus', pth_dir), - version=release, - description='MDSplus Python Objects - '+release_tag, - long_description=( - "This module provides all of the functionality of MDSplus TDI natively in python.\n" - "All of the MDSplus data types such as signal are represented as python classes.\n" - ), - author='MDSplus Development Team', - author_email='twf@www.mdsplus.org', - url='http://www.mdsplus.org/', - license='MIT', - classifiers=[ - 'Programming Language :: Python', - 'Intended Audience :: Science/Research', - 'Environment :: Console', - 'Topic :: Scientific/Engineering', - ], - keywords=['physics', 'mdsplus', ], - ) - - -def use_distutils(): - from distutils.core import setup - from distutils.cmd import Command - - class TestCommand(Command): - user_options = [] - - def initialize_options(self): - """nothing to do.""" - - def finalize_options(self): - """nothing to do.""" - - def run(self): - import subprocess - raise SystemExit( - subprocess.call([sys.executable, '-m', 'tests.__init__'])) - - setup(cmdclass={'test': TestCommand}, **setupkw()) - - -def use_setuptools(): - from setuptools import setup - setup( - include_package_data=True, - test_suite='tests.test_all', - zip_safe=False, - **setupkw() - ) - - -if __name__ == '__main__': - if 'pip-egg-info' in sys.argv: - print("When using pip to install MDSplus use 'pip install -e '") - sys.exit(1) - try: - use_setuptools() - except (ImportError, RuntimeError): - use_distutils() +from setuptools import setup +setup() From 5c12216f4ff9cc16f5ecab8fb59cdaa8607634ac Mon Sep 17 00:00:00 2001 From: "darren@openstar.nz" Date: Thu, 1 Feb 2024 16:19:02 +0000 Subject: [PATCH 2/6] actually this requirest setuptools >= 60.0.0 for the blank setup.py --- python/MDSplus/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/MDSplus/pyproject.toml b/python/MDSplus/pyproject.toml index 6731855ee9..73e4403cbb 100644 --- a/python/MDSplus/pyproject.toml +++ b/python/MDSplus/pyproject.toml @@ -1,5 +1,5 @@ [build-system] - requires = ["setuptools>=40.8.0", "wheel"] + requires = ["setuptools>=60.0.0", "wheel"] build-backend = "setuptools.build_meta" [project] From 8dfcf6ac6a446be6c8e2e04c5db8a3aad5d86b45 Mon Sep 17 00:00:00 2001 From: "darren@openstar.nz" Date: Thu, 1 Feb 2024 20:24:38 +0000 Subject: [PATCH 3/6] add pyproject.toml to dist files --- deploy/packaging/debian/python.noarch | 1 + deploy/packaging/redhat/python.noarch | 1 + deploy/packaging/windows/mdsplus.nsi | 2 +- macosx/scripts/postinstall | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/deploy/packaging/debian/python.noarch b/deploy/packaging/debian/python.noarch index 0366910800..4086298248 100644 --- a/deploy/packaging/debian/python.noarch +++ b/deploy/packaging/debian/python.noarch @@ -15,6 +15,7 @@ ./usr/local/mdsplus/python/MDSplus/modpython.py ./usr/local/mdsplus/python/MDSplus/scope.py ./usr/local/mdsplus/python/MDSplus/setup.py +./usr/local/mdsplus/python/MDSplus/pyproject.toml ./usr/local/mdsplus/python/MDSplus/tests/__init__.py ./usr/local/mdsplus/python/MDSplus/tests/_common.py ./usr/local/mdsplus/python/MDSplus/tests/connection_case.py diff --git a/deploy/packaging/redhat/python.noarch b/deploy/packaging/redhat/python.noarch index 078a82b4d2..10aaaf3ed2 100644 --- a/deploy/packaging/redhat/python.noarch +++ b/deploy/packaging/redhat/python.noarch @@ -16,6 +16,7 @@ ./usr/local/mdsplus/python/MDSplus/modpython.py ./usr/local/mdsplus/python/MDSplus/scope.py ./usr/local/mdsplus/python/MDSplus/setup.py +./usr/local/mdsplus/python/MDSplus/pyproject.toml ./usr/local/mdsplus/python/MDSplus/tests ./usr/local/mdsplus/python/MDSplus/tests/__init__.py ./usr/local/mdsplus/python/MDSplus/tests/_common.py diff --git a/deploy/packaging/windows/mdsplus.nsi b/deploy/packaging/windows/mdsplus.nsi index d3a50d907a..08b5a52bb2 100644 --- a/deploy/packaging/windows/mdsplus.nsi +++ b/deploy/packaging/windows/mdsplus.nsi @@ -412,7 +412,7 @@ SectionGroup /e "!APIs" apis Section "!MDSplus package" python_cp SectionIn 1 2 SetOutPath "$INSTDIR\python\MDSplus" - File /x modpython.py /x setup.py python/MDSplus/*.py + File /x modpython.py /x setup.py python/MDSplus/*.py python/MDSplus/pyproject.toml File /workspace/releasebld/64/python/MDSplus/_version.py SectionEnd ; python_cp Section "tests" python_tst diff --git a/macosx/scripts/postinstall b/macosx/scripts/postinstall index d1c0ca147b..5d9823ffca 100755 --- a/macosx/scripts/postinstall +++ b/macosx/scripts/postinstall @@ -32,9 +32,9 @@ fi date > /var/log/mdsplus_postinstall pushd ${MDSPLUS_DIR}/python/MDSplus >> /var/log/mdsplus_postinstall 2>&1 -python setup.py install >>/var/log/mdsplus_postinstall 2>&1 +python -m pip install . >>/var/log/mdsplus_postinstall 2>&1 popd >> /var/log/mdsplus_postinstall 2>&1 pushd ${MDSPLUS_DIR}/tdi/MitDevices >> /var/log/mdsplus_postinstall 2>&1 -python setup.py install >>/var/log/mdsplus_postinstall 2>&1 +python -m pip install . >>/var/log/mdsplus_postinstall 2>&1 popd >> /var/log/mdsplus_postinstall 2>&1 exit 0 From 1b8c5bc9e28bb4409bca15256b97bc0f7b44aa12 Mon Sep 17 00:00:00 2001 From: "darren@openstar.nz" Date: Fri, 2 Feb 2024 01:38:57 +0000 Subject: [PATCH 4/6] enable python2.7 and setuptools<60 support --- python/MDSplus/pyproject.toml | 19 +++++--- python/MDSplus/setup.py | 87 ++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 8 deletions(-) diff --git a/python/MDSplus/pyproject.toml b/python/MDSplus/pyproject.toml index 73e4403cbb..d4bee67945 100644 --- a/python/MDSplus/pyproject.toml +++ b/python/MDSplus/pyproject.toml @@ -1,5 +1,5 @@ [build-system] - requires = ["setuptools>=60.0.0", "wheel"] + requires = ["setuptools>=44.1.1", "wheel"] # python2.7 support build-backend = "setuptools.build_meta" [project] @@ -37,15 +37,20 @@ 'MDSplus.wsgi', 'MDSplus.tests', ] - package-dir = { 'MDSplus' = '.' } include-package-data = false # use package-data below +[tool.setuptools.package-dir] + 'MDSplus' = '.' + 'MDSplus.widgets' = 'widgets' + 'MDSplus.wsgi' = 'wsgi' + 'MDSplus.tests' = 'tests' + [tool.setuptools.package-data] - '*' = [ - 'wsgi/html/*', - 'wsgi/conf/*', - 'wsgi/js/*', - 'wsgi/*.tbl', + 'MDSplus.wsgi' = [ + 'html/*', + 'conf/*', + 'js/*', + '*.tbl', ] [tool.setuptools.dynamic] diff --git a/python/MDSplus/setup.py b/python/MDSplus/setup.py index 52e8781512..ffb062609b 100644 --- a/python/MDSplus/setup.py +++ b/python/MDSplus/setup.py @@ -24,5 +24,90 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +import sys +import os + +import setuptools from setuptools import setup -setup() + + +def setupkw(): + try: + loc = {} + mod_dir = os.path.dirname(os.path.abspath(__file__)) + with open(os.path.join(mod_dir, "_version.py")) as f: + exec(f.read(), None, loc) + version = loc["version"] + release = "%d.%d.%d" % version + release_tag = loc["release_tag"] + + except Exception: + release = "0.0.0" + release_tag = "Unknown" + pth_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + return dict( + name="MDSplus", + extra_path=("mdsplus", pth_dir), + version=release, + description="MDSplus Python Objects - " + release_tag, + long_description=( + "This module provides all of the functionality of MDSplus TDI natively in python.\n" + "All of the MDSplus data types such as signal are represented as python classes.\n" + ), + author="MDSplus Development Team", + author_email="twf@www.mdsplus.org", + url="http://www.mdsplus.org/", + license="MIT", + classifiers=[ + "Programming Language :: Python", + "Intended Audience :: Science/Research", + "Environment :: Console", + "Topic :: Scientific/Engineering", + ], + keywords=[ + "physics", + "mdsplus", + ], + ) + + +if setuptools.__version__ < "60.0.0": + # assume that setuptools can't directly use pyproject.toml + # for the [project] section, so need the old setup.py + + print(sys.argv) + if "develop" in sys.argv: + # old setuptools can't have both --editable and --user + # but it defaults to user anyway! + if "--user" in sys.argv: + import site + + print("Removing --user") + argv = sys.argv + argv.remove("--user") + argv.append("--install-dir") + argv.append(site.getusersitepackages()) + sys.argv = argv + + setup( + test_suite="tests.test_all", + zip_safe=False, + packages=["MDSplus", + "MDSplus.wsgi", + "MDSplus.widgets", + "MDSplus.tests"], + package_dir={"MDSplus": ".", + "MDSplus.widgets":"widgets", + "MDSplus.wsgi":"wsgi", + "MDSplus.tests":"tests"}, + package_data={"MDSplus.wsgi":[ + 'html/*', + 'conf/*', + 'js/*', + '*.tbl']}, + **setupkw() + ) + +else: + # setuptools can use pyproject.toml + setup() From e82742220941c52f6c251f073fca919dd46f5e1f Mon Sep 17 00:00:00 2001 From: Darren Garnier Date: Tue, 6 Feb 2024 13:33:19 -0500 Subject: [PATCH 5/6] using slightly cleaner api --- python/MDSplus/setup.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/python/MDSplus/setup.py b/python/MDSplus/setup.py index ffb062609b..a5c2e766ad 100644 --- a/python/MDSplus/setup.py +++ b/python/MDSplus/setup.py @@ -32,14 +32,13 @@ def setupkw(): + from runpy import run_path try: - loc = {} mod_dir = os.path.dirname(os.path.abspath(__file__)) - with open(os.path.join(mod_dir, "_version.py")) as f: - exec(f.read(), None, loc) - version = loc["version"] + ver_data = run_path(os.path.join(mod_dir, "_version.py")) + version = ver_data["version"] release = "%d.%d.%d" % version - release_tag = loc["release_tag"] + release_tag = ver_data["release_tag"] except Exception: release = "0.0.0" @@ -64,10 +63,7 @@ def setupkw(): "Environment :: Console", "Topic :: Scientific/Engineering", ], - keywords=[ - "physics", - "mdsplus", - ], + keywords=["physics", "mdsplus",], ) @@ -97,9 +93,9 @@ def setupkw(): "MDSplus.widgets", "MDSplus.tests"], package_dir={"MDSplus": ".", - "MDSplus.widgets":"widgets", - "MDSplus.wsgi":"wsgi", - "MDSplus.tests":"tests"}, + "MDSplus.widgets":"widgets", + "MDSplus.wsgi":"wsgi", + "MDSplus.tests":"tests"}, package_data={"MDSplus.wsgi":[ 'html/*', 'conf/*', From bcebfaec6a6d52485c273daf53ae77c60dac757c Mon Sep 17 00:00:00 2001 From: Darren Garnier Date: Mon, 12 Feb 2024 16:49:13 -0500 Subject: [PATCH 6/6] change correspondence email --- python/MDSplus/pyproject.toml | 2 +- python/MDSplus/setup.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/python/MDSplus/pyproject.toml b/python/MDSplus/pyproject.toml index d4bee67945..7afed270e8 100644 --- a/python/MDSplus/pyproject.toml +++ b/python/MDSplus/pyproject.toml @@ -5,7 +5,7 @@ [project] name='MDSplus' authors = [ - {name = "MDSplus Development Team", email = "twf@www.mdsplus.org"}, + {name = "MDSplus Development Team", email = "mdsplusadmin@psfc.mit.edu"}, ] license = {text = "MIT License"} description = "MDSplus Python Object interface" diff --git a/python/MDSplus/setup.py b/python/MDSplus/setup.py index a5c2e766ad..9e5e95e323 100644 --- a/python/MDSplus/setup.py +++ b/python/MDSplus/setup.py @@ -54,7 +54,7 @@ def setupkw(): "All of the MDSplus data types such as signal are represented as python classes.\n" ), author="MDSplus Development Team", - author_email="twf@www.mdsplus.org", + author_email="mdsplusadmin@psfc.mit.edu", url="http://www.mdsplus.org/", license="MIT", classifiers=[ @@ -63,7 +63,10 @@ def setupkw(): "Environment :: Console", "Topic :: Scientific/Engineering", ], - keywords=["physics", "mdsplus",], + keywords=[ + "physics", + "mdsplus", + ], )