From c338b3104e38d3b6922e31dcc7cca2f488e00ad4 Mon Sep 17 00:00:00 2001 From: Beau Harrison Date: Tue, 19 Aug 2025 13:58:02 -0500 Subject: [PATCH 1/3] refactor: :recycle: Migrate to pyproject.toml and remove setup.py, requirements, and settings files --- Makefile | 2 +- README.md | 33 ++++++++++++++++++--------------- pyproject.toml | 36 ++++++++++++++++++++++++++++++++++++ requirements.txt | 2 -- settings_requirements.txt | 1 - setup.py | 35 ----------------------------------- 6 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 settings_requirements.txt delete mode 100644 setup.py diff --git a/Makefile b/Makefile index 72fa641..ad272ed 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ build :: clean - python3 setup.py sdist + $(VIRTUAL_ENV)/bin/python3 -m build --sdist --wheel deploy : build scp dist/* chablis:/usr/local/www/data/pip3/acsys/ diff --git a/README.md b/README.md index d86af77..243504e 100644 --- a/README.md +++ b/README.md @@ -14,23 +14,34 @@ python3 -m pip install acsys --extra-index-url https://www-bd.fnal.gov/pip3 The command above will get you up and going quickly. See usage examples in the [wiki](https://github.com/fermi-controls/acsys-python/wiki). -If you need to perform settings, authentication is required and thus the `gssapi` authentication library. +If you need to perform settings, you will need the optional authentication library, `gssapi`. ```bash -python3 -m pip install "acsys[settings]" +python3 -m pip install "acsys[settings]" --extra-index-url https://www-bd.fnal.gov/pip3 ``` Note: This package only authenticates you as a user. There are other requirements to be able to set devices. Please make a request to the Controls Department for setting access. -If you would like to install all dependencies, use the following. +## Building and Distributing + +All dependencies are managed via pyproject.toml. + +Start by creating and activating a virtual environment. + +```bash +python3 -m venv venv +source ./venv/bin/activate +``` + +To build the project, ensure you have your development dependencies installed. ```bash -python3 -m pip install "acsys[all]" +pip install -e ".[dev]" ``` -## Building +This command installs your project in an editable mode along with all its development dependencies, like `build` and `wheel`. -Make sure `setup.py` has the correct version number. +Make sure `pyproject.toml` has the correct version number. ```bash make @@ -68,12 +79,4 @@ git push --tags ## Development -Start by installing development dependencies. - -```bash -pip install -r requirements.txt -``` - -To test local modifications, use pip's editable mode. - -`pip install -e .` +To get started with development, simply follow the "Building and Distributing" section. The `pip install -e ".[dev]"` command will set up your virtual environment so that any changes you make to the source code will be immediately reflected in your `venv`. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1ab45bf --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,36 @@ +[build-system] +requires = ["setuptools>=61.0", "wheel", "setuptools-git-versioning"] +build-backend = "setuptools.build_meta" + +[project] +name = "acsys" +dynamic = ["version"] +authors = [ + { name="Rich Neswold", email="neswold@fnal.gov" }, + { name="Beau Harrison", email="beau@fnal.gov" }, +] +description = "ACSys Client library" +readme = "README.md" +requires-python = ">=3.9.21" +license = { text = "MIT" } +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +dependencies = [ + "nest_asyncio", + 'importlib-metadata; python_version < "3.8"', +] + +[project.optional-dependencies] +settings = [ + "gssapi", +] +dev = [ + "build", + "wheel", +] + +[tool.setuptools-git-versioning] +enabled = true diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 3bf284d..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -nest_asyncio -importlib-metadata diff --git a/settings_requirements.txt b/settings_requirements.txt deleted file mode 100644 index be66cd0..0000000 --- a/settings_requirements.txt +++ /dev/null @@ -1 +0,0 @@ -gssapi diff --git a/setup.py b/setup.py deleted file mode 100644 index 691eacc..0000000 --- a/setup.py +++ /dev/null @@ -1,35 +0,0 @@ -import setuptools - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="acsys", - version="0.12.8", - author="Rich Neswold", - author_email="neswold@fnal.gov", - description="ACSys Client library", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/fermi-ad/acsys-python", - packages=setuptools.find_packages(), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - install_requires=[ # Default - 'nest_asyncio', - 'importlib-metadata; python_version < "3.8"', - ], - extras_require={ # Optional - 'settings': ['gssapi'], - 'all': [ - 'importlib-metadata; python_version < "3.8"', - 'gssapi', - 'nest_asyncio' - ] - }, - python_requires='>=3.6', - license="MIT", -) From e5f6a1749d88cf34ac8479bb67768088427e838d Mon Sep 17 00:00:00 2001 From: Beau Harrison Date: Tue, 19 Aug 2025 14:05:28 -0500 Subject: [PATCH 2/3] refactor: :recycle: Removing compatibility for Python 3.8 --- acsys/__init__.py | 9 +++------ pyproject.toml | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/acsys/__init__.py b/acsys/__init__.py index faea887..6916f0f 100644 --- a/acsys/__init__.py +++ b/acsys/__init__.py @@ -111,12 +111,9 @@ async def my_client(con): import struct import acsys.status as status -# https://packaging.python.org/guides/single-sourcing-package-version/#single-sourcing-the-version -try: - from importlib import metadata -except ImportError: - # Running on pre-3.8 Python; use importlib-metadata package - import importlib_metadata as metadata + +from importlib import metadata + __version__ = metadata.version('acsys') __all__ = [ diff --git a/pyproject.toml b/pyproject.toml index 1ab45bf..8f4b851 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,6 @@ classifiers = [ ] dependencies = [ "nest_asyncio", - 'importlib-metadata; python_version < "3.8"', ] [project.optional-dependencies] From c017b1e35937f28bc63bdad7dbcb4f089e6a624b Mon Sep 17 00:00:00 2001 From: Beau Harrison Date: Tue, 19 Aug 2025 14:10:31 -0500 Subject: [PATCH 3/3] refactor: :recycle: Update deployment instructions in README for clarity and consistency --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 243504e..e13e0ab 100644 --- a/README.md +++ b/README.md @@ -57,21 +57,27 @@ make all The above will generate "built distributions" as well as the source distributions from `make`. -## Deploying +## Releasing a New Version + +### Set the new version + +Ensure all your changes are committed to Git. Create a new Git tag for the version you are releasing. The tag name should follow the semver format `vX.Y.Z`. ```bash -make deploy +git tag vVID ``` -The above will generate the distributions and push them to the AD Controls pip server. +### Deploy the distributions -Make sure to use git to tag the version. +Run the `deploy` make target to build the package and push it to the pip server. This process will automatically use the new version from your Git tag. ```bash -git tag vVID +make deploy ``` -And push the tags. +### Push the tags + +Finally, push the new tag to the remote repository. This makes the new version official in your project's history. ```bash git push --tags