From 95728892c963a92a0d1cb03e2811d5813bf68ace Mon Sep 17 00:00:00 2001 From: G Adam Cox Date: Mon, 6 Feb 2023 15:46:39 -0800 Subject: [PATCH 1/2] Updates build system to use latest PEP recommendations --- .gitignore | 1 + README.md | 4 +- pyproject.toml | 57 ++++++++++++++++++++++++++++ setup.py | 42 -------------------- src/qt3rfsynthcontrol/__init__.py | 3 +- src/qt3rfsynthcontrol/__version__.py | 1 - 6 files changed, 61 insertions(+), 47 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py delete mode 100644 src/qt3rfsynthcontrol/__version__.py diff --git a/.gitignore b/.gitignore index 5513c8b..939cc90 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ src/qt3rfsynthcontrol.egg-info/* build/* dist/* +.idea* \ No newline at end of file diff --git a/README.md b/README.md index a4311dd..60a0ad7 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,7 @@ Helper code to control [Windfreak's SynthHD RF generator](https://windfreaktech. ## Installation ``` -git clone https://github.com/gadamc/qt3RFSynthControl -cd qt3rfsynthcontrol -python -m pip install . +pip install qt3rfsynthcontrol ``` ## Usage diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..822fd9b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,57 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "qt3rfsynthcontrol" +dynamic = ["version"] # version is defined in __init__.py + +description = "A package for controlling the Windfreak SynthHD RF generator." +readme = "README.md" +requires-python = ">=3.8" +license = {file = "LICENSE"} +keywords = ["qt3", "microwave", "electron spin control", "windfreak", + "synthHD", "rf generator", "rf synthesizer", "rf control", "rf"] + +authors = [ + {name = "G. Adam Cox", email = "gadamc@gmail.com" }, +] + +maintainers = [ + {name = "G. Adam Cox", email = "gadamc@gmail.com" }, + {name = "Maxwell Parsons", email = "mfpars@uw.edu " }, +] + +classifiers = [ + "Development Status :: 5 - Production/Stable", + + # Indicate who your project is intended for + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering :: Physics", + "Topic :: Scientific/Engineering", + + # Pick your license as you wish + "License :: OSI Approved :: BSD License", + + # Specify the Python versions you support here. In particular, ensure + # that you indicate you support Python 3. These classifiers are *not* + # checked by "pip install". See instead "python_requires" below. + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3 :: Only", +] + +dependencies = [ + "windfreak==0.3.0", +] + +[project.urls] +"Homepage" = "https://github.com/qt3uw/qt3rfsynthcontrol" +"Source" = "https://github.com/qt3uw/qt3rfsynthcontrol" +"Bug Tracker" = "https://github.com/qt3uw/qt3rfsynthcontrol/issues" +"Changelog" = "https://github.com/qt3uw/qt3rfsynthcontrol/releases" + +[tool.setuptools.dynamic] +version = {attr = "qt3rfsynthcontrol.__version__"} diff --git a/setup.py b/setup.py deleted file mode 100644 index 8d6c628..0000000 --- a/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- -import sys -import re -from setuptools import setup, find_namespace_packages - -package_name = 'qt3rfsynthcontrol' -package_source = 'src' - -VERSIONFILE=f'{package_source}/{package_name}/__version__.py' -verstrline = open(VERSIONFILE, 'rt').read() -VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]" -mo = re.search(VSRE, verstrline, re.M) -if mo: - __version__ = mo.group(1) -else: - raise RuntimeError(f'Unable to find version string in{VERSIONFILE}.') - - -requirements = [ - 'windfreak', -] - -with open('README.md', 'r') as file: - long_description = file.read() - - -setup( - name=package_name, - version=__version__, - packages=find_namespace_packages(where=package_source), - package_dir={'': package_source}, - package_data={'': ['README.md'], - }, - description='A package for controlling the Windfreak SynthHD RF generator', - long_description=long_description, - long_description_content_type='text/markdown', - url='https://github.com/gadamc/qt3rfsynthcontrol', - - license='GPLv3', # License tag - install_requires=requirements, # package dependencies - python_requires='~=3.8', # Specify compatible Python versions -) diff --git a/src/qt3rfsynthcontrol/__init__.py b/src/qt3rfsynthcontrol/__init__.py index dc4bd48..91fee7d 100644 --- a/src/qt3rfsynthcontrol/__init__.py +++ b/src/qt3rfsynthcontrol/__init__.py @@ -1,2 +1,3 @@ -from .__version__ import __version__ from .device import QT3SynthHD, discover_devices + +__version__ = '1.0.1.dev0' diff --git a/src/qt3rfsynthcontrol/__version__.py b/src/qt3rfsynthcontrol/__version__.py deleted file mode 100644 index 1f356cc..0000000 --- a/src/qt3rfsynthcontrol/__version__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '1.0.0' From 892d24258ff2b32fe84f2aeccab8871b1e233f3a Mon Sep 17 00:00:00 2001 From: G Adam Cox Date: Tue, 7 Feb 2023 12:03:34 -0800 Subject: [PATCH 2/2] Adds github workflow Moves verion to pyproject.toml file Updates __init__ to gather __version__ via importlib --- .github/workflows/python-publish.yml | 40 ++++++++++++++++++++++++++++ pyproject.toml | 5 +--- src/qt3rfsynthcontrol/__init__.py | 4 +-- 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..178676a --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,40 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 822fd9b..f814962 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "qt3rfsynthcontrol" -dynamic = ["version"] # version is defined in __init__.py +version = "1.0.1.dev1" description = "A package for controlling the Windfreak SynthHD RF generator." readme = "README.md" @@ -52,6 +52,3 @@ dependencies = [ "Source" = "https://github.com/qt3uw/qt3rfsynthcontrol" "Bug Tracker" = "https://github.com/qt3uw/qt3rfsynthcontrol/issues" "Changelog" = "https://github.com/qt3uw/qt3rfsynthcontrol/releases" - -[tool.setuptools.dynamic] -version = {attr = "qt3rfsynthcontrol.__version__"} diff --git a/src/qt3rfsynthcontrol/__init__.py b/src/qt3rfsynthcontrol/__init__.py index 91fee7d..b22b435 100644 --- a/src/qt3rfsynthcontrol/__init__.py +++ b/src/qt3rfsynthcontrol/__init__.py @@ -1,3 +1,3 @@ from .device import QT3SynthHD, discover_devices - -__version__ = '1.0.1.dev0' +from importlib.metadata import version +__version__ = version(__package__)