From 8c1620c0a5e9481bc08eae9a84784c0521195c1f Mon Sep 17 00:00:00 2001 From: David Meyer Date: Sat, 13 Jul 2024 02:20:29 -0400 Subject: [PATCH] Move metadata to pyproject.toml, update setuptools-scm configs --- .github/workflows/release.yml | 1 - labscript_utils/__version__.py | 25 +++++++----- pyproject.toml | 69 +++++++++++++++++++++++++++++++++- setup.cfg | 53 -------------------------- setup.py | 48 ----------------------- 5 files changed, 83 insertions(+), 113 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f11fb46..6cff2e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,6 @@ on: env: PACKAGE_NAME: labscript-utils - SCM_LOCAL_SCHEME: no-local-version ANACONDA_USER: labscript-suite # Configuration for a package with compiled extensions: diff --git a/labscript_utils/__version__.py b/labscript_utils/__version__.py index 11bdd8d..c21f494 100644 --- a/labscript_utils/__version__.py +++ b/labscript_utils/__version__.py @@ -1,22 +1,27 @@ -import os from pathlib import Path - try: import importlib.metadata as importlib_metadata except ImportError: import importlib_metadata -VERSION_SCHEME = { - "version_scheme": os.getenv("SCM_VERSION_SCHEME", "release-branch-semver"), - "local_scheme": os.getenv("SCM_LOCAL_SCHEME", "node-and-date"), -} - root = Path(__file__).parent.parent if (root / '.git').is_dir(): - from setuptools_scm import get_version - __version__ = get_version(root, **VERSION_SCHEME) + try: + from setuptools_scm import get_version + VERSION_SCHEME = { + "version_scheme": "release-branch-semver", + "local_scheme": "node-and-date", + } + scm_version = get_version(root, **VERSION_SCHEME) + except ImportError: + scm_version = None +else: + scm_version = None + +if scm_version is not None: + __version__ = scm_version else: try: __version__ = importlib_metadata.version(__package__) except importlib_metadata.PackageNotFoundError: - __version__ = None \ No newline at end of file + __version__ = None diff --git a/pyproject.toml b/pyproject.toml index 3a61336..3863a26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,4 +2,71 @@ requires = ["setuptools>=64", "wheel", "setuptools_scm>=8"] build-backend = "setuptools.build_meta" -[tool.setuptools_scm] \ No newline at end of file +[tool.setuptools_scm] +version_scheme = "release-branch-semver" +local_scheme = "no-local-version" + +[tool.setuptools] +zip-safe = false +include-package-data = true +packages = [ + "labscript_utils", + "labscript_profile", +] + +[tool.setuptools.package-data] +labscript_profile = ["../labscript-suite.pth"] + +[project] +name = "labscript-utils" +description = "Shared utilities for the labscript suite" +authors = [ + {name = "The labscript suite community", email = "labscriptsuite@googlegroups.com"}, +] +keywords = ["experiment control", "automation"] +license = {file = 'LICENSE.txt'} +classifiers = [ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +requires-python = ">=3.6" +dependencies = [ + "importlib_metadata>=1.0", + "h5py>=2.9", + "numpy>=1.15", + "packaging>=20.4", + "pyqtgraph>=0.11.0rc0", + "qtutils>=2.2.3", + "scipy", + "setuptools_scm>=4.1.0", + "zprocess>=2.18.0", +] +dynamic = ["version"] + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[project.urls] +Homepage = "http://labscriptsuite.org/" +Documentation = "https://docs.labscriptsuite.org/" +Repository = "https://github.com/labscript-suite/labscript-utils/" +Downloads = "https://github.com/labscript-suite/labscript-utils/releases/" +Tracker = "https://github.com/labscript-suite/labscript-utils/issues/" + +[project.optional-dependencies] +docs = [ + "PyQt5", + "Sphinx==7.2.6", + "sphinx-rtd-theme==2.0.0", + "myst_parser==2.0.0", +] + +[project.scripts] +labscript-profile-create = "labscript_profile.create:create_profile" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 920ba4d..0000000 --- a/setup.cfg +++ /dev/null @@ -1,53 +0,0 @@ -[metadata] -name = labscript-utils -description = Shared utilities for the labscript suite -long_description = file: README.md -long_description_content_type = text/markdown -author = The labscript suite community -author_email = labscriptsuite@googlegroups.com -url = http://labscriptsuite.org -project_urls = - Source Code=https://github.com/labscript-suite/labscript-utils - Download=https://github.com/labscript-suite/labscript-utils/releases - Tracker=https://github.com/labscript-suite/labscript-utils/issues -keywords = experiment control automation -license = BSD -classifiers = - License :: OSI Approved :: BSD License - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - -[options] -zip_safe = False -include_package_data = True -packages = labscript_utils, labscript_profile -python_requires = >=3.6 -install_requires = - importlib_metadata>=1.0 - h5py>=2.9 - numpy>=1.15 - packaging>=20.4 - pyqtgraph>=0.11.0rc0 - qtutils>=2.2.3 - scipy - setuptools_scm>=4.1.0 - zprocess>=2.18.0 - -[options.extras_require] -docs = - PyQt5 - Sphinx==7.2.6 - sphinx-rtd-theme==2.0.0 - myst_parser==2.0.0 - -[options.package_data] -labscript_profile = ../labscript-suite.pth - -[options.entry_points] -console_scripts = - labscript-profile-create = labscript_profile.create:create_profile diff --git a/setup.py b/setup.py deleted file mode 100644 index 5f958c3..0000000 --- a/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -import os -from setuptools import setup -from setuptools.command.develop import develop -import logging - -# Setupstools >=64 -try: - from setuptools.command.editable_wheel import editable_wheel -except ImportError: - editable_wheel_command = None -else: - from wheel.wheelfile import WheelFile - - class editable_wheel_command(editable_wheel): - """Custom editable_wheel command which installs the .pth file to the - wheel file for editable installs.""" - def _create_wheel_file(self, bdist_wheel): - wheel_path = super()._create_wheel_file(bdist_wheel) - with WheelFile(wheel_path, 'a') as wheel: - wheel.write("labscript-suite.pth") - return wheel_path - - -# Setuptools <= 63: -class develop_command(develop): - """Custom develop command which installs the .pth file to site-packages for editable - installs.""" - def run(self): - path = os.path.join(self.install_dir, 'labscript-suite.pth') - super().run() - if not self.uninstall: - logging.info(f'Copying labscript-suite.pth to {path}') - if not self.dry_run: - self.copy_file('labscript-suite.pth', path) - - -VERSION_SCHEME = { - "version_scheme": os.getenv("SCM_VERSION_SCHEME", "release-branch-semver"), - "local_scheme": os.getenv("SCM_LOCAL_SCHEME", "node-and-date"), -} - -setup( - use_scm_version=VERSION_SCHEME, - cmdclass={ - 'develop': develop_command, - 'editable_wheel': editable_wheel_command, - }, -)