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 diff --git a/python/MDSplus/pyproject.toml b/python/MDSplus/pyproject.toml new file mode 100644 index 0000000000..7afed270e8 --- /dev/null +++ b/python/MDSplus/pyproject.toml @@ -0,0 +1,57 @@ +[build-system] + requires = ["setuptools>=44.1.1", "wheel"] # python2.7 support + build-backend = "setuptools.build_meta" + +[project] + name='MDSplus' + authors = [ + {name = "MDSplus Development Team", email = "mdsplusadmin@psfc.mit.edu"}, + ] + 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', + ] + 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] + 'MDSplus.wsgi' = [ + 'html/*', + 'conf/*', + 'js/*', + '*.tbl', + ] + +[tool.setuptools.dynamic] + version = {attr = '_version.version'} diff --git a/python/MDSplus/setup.py b/python/MDSplus/setup.py index 87cd4c496a..9e5e95e323 100644 --- a/python/MDSplus/setup.py +++ b/python/MDSplus/setup.py @@ -23,80 +23,90 @@ # 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 +import setuptools +from setuptools import setup + def setupkw(): + from runpy import run_path 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()) + ver_data = run_path(os.path.join(mod_dir, "_version.py")) + version = ver_data["version"] release = "%d.%d.%d" % version + release_tag = ver_data["release_tag"] + except Exception: - release = '0.0.0' - release_tag = 'Unknown' + 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), + name="MDSplus", + extra_path=("mdsplus", pth_dir), version=release, - description='MDSplus Python Objects - '+release_tag, + 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', + author="MDSplus Development Team", + author_email="mdsplusadmin@psfc.mit.edu", + url="http://www.mdsplus.org/", + license="MIT", classifiers=[ - 'Programming Language :: Python', - 'Intended Audience :: Science/Research', - 'Environment :: Console', - 'Topic :: Scientific/Engineering', + "Programming Language :: Python", + "Intended Audience :: Science/Research", + "Environment :: Console", + "Topic :: Scientific/Engineering", + ], + keywords=[ + "physics", + "mdsplus", ], - keywords=['physics', 'mdsplus', ], ) -def use_distutils(): - from distutils.core import setup - from distutils.cmd import Command - - class TestCommand(Command): - user_options = [] +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 - def initialize_options(self): - """nothing to do.""" + 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 - def finalize_options(self): - """nothing to do.""" + print("Removing --user") + argv = sys.argv + argv.remove("--user") + argv.append("--install-dir") + argv.append(site.getusersitepackages()) + sys.argv = argv - 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', + 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() ) - -if __name__ == '__main__': - if 'pip-egg-info' in sys.argv: - print("When using pip to install MDSplus use 'pip install -e