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..e13e0ab 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 @@ -46,34 +57,32 @@ make all The above will generate "built distributions" as well as the source distributions from `make`. -## Deploying - -```bash -make deploy -``` +## Releasing a New Version -The above will generate the distributions and push them to the AD Controls pip server. +### Set the new version -Make sure to use git to tag the 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 git tag vVID ``` -And push the tags. +### Deploy the distributions + +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 push --tags +make deploy ``` -## Development +### Push the tags -Start by installing development dependencies. +Finally, push the new tag to the remote repository. This makes the new version official in your project's history. ```bash -pip install -r requirements.txt +git push --tags ``` -To test local modifications, use pip's editable mode. +## Development -`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/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 new file mode 100644 index 0000000..8f4b851 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,35 @@ +[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", +] + +[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", -)