From 54c0044a56e03f77d470d1c768818255ae280d1e Mon Sep 17 00:00:00 2001 From: Stephen Knox Date: Thu, 26 Jun 2025 14:50:17 +0100 Subject: [PATCH] Upgrade from setup.py to pyproject.toml, and add a build script --- build.sh | 23 ++++++++++++++++++++ pyproject.toml | 32 ++++++++++++++++++++++++++++ setup.py | 58 -------------------------------------------------- 3 files changed, 55 insertions(+), 58 deletions(-) create mode 100755 build.sh create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..dc72aae --- /dev/null +++ b/build.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail # fail on error, missing vars, or pipe fails + +echo "▶ Cleaning previous artefacts (if any)…" +for dir in dist build; do + if [[ -d "$dir" ]]; then + echo " • Removing $dir" + rm -rf "$dir" + fi +done + +shopt -s nullglob # *.egg-info expands to empty list if none +for egg in *.egg-info; do + echo " • Removing $egg" + rm -rf "$egg" +done +shopt -u nullglob # restore default + +echo "▶ Building package…" +python -m build + +echo "▶ Uploading to PyPI…" +twine upload dist/* diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..85aea71 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,32 @@ +[project] +name="hydra-server" +description="A JSON RPC web server to interact with the Hydra Platform Base Libary" +readme="README.rst" +dynamic = ["version"] +authors = [ + {name = "Stephen Knox", email = "knoxsp@gmail.com"}, +] +requires-python=">=3.10" +license-files = ["LICENSE"] +dependencies=[ +"spyne >= 2.13.2-alpha", +"hydra-base", +"lxml", +"click" +] + + +[project.urls] +Documentation="https://hydraplatform.org" +Repository="https://github.com/hydraplatform/hydra-server" + +[build-system] +requires = ["setuptools>=77", "setuptools_scm", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +version_scheme = "post-release" +local_scheme = "no-local-version" + +[project.scripts] +hydra-server = "hydra_server.cli:start_cli" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 405a64f..0000000 --- a/setup.py +++ /dev/null @@ -1,58 +0,0 @@ -#This is just a work-around for a Python2.7 issue causing -#interpreter crash at exit when trying to log an info message. -try: - import logging - import multiprocessing -except: - pass - -import platform -import sys -import os -from packaging.version import Version - -py_version = sys.version_info[:2] - -try: - from setuptools import setup, find_packages -except ImportError: - from ez_setup import use_setuptools - use_setuptools() - from setuptools import setup, find_packages - -# get version string from __init__.py -with open(os.path.join(os.path.dirname(__file__), "hydra_server", "__init__.py")) as f: - for line in f: - if line.startswith("__version__"): - version = Version(line.split("=")[1].strip().strip("\"'")) - -install_requires=[ - "hydra-base", - "lxml", - "spyne", - "click", - ] - -dependency_links=[ - "git+https://github.com/arskom/spyne.git@spyne-2.13.2-alpha#egg=spyne", -] - -if platform.system() == "Windows": # only add winpaths when platform is Windows so that setup.py is universal - install_requires.append("winpaths") - -setup( - name='hydra-server', - version=str(version), - description='A JSON RPC server front end for the hydra-base network manager', - author='Stephen Knox', - author_email='stephen.knox@manchester.ac.uk', - url='https://github.com/hydraplatform/hydra-server', - packages=find_packages(exclude=['ez_setup']), - install_requires=install_requires, - dependency_links=dependency_links, - include_package_data=True, - entry_points={ - 'console_scripts': ['hydra-server=hydra_server.cli:start_cli'] - }, - zip_safe=False, -)