diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index f967bd9..862028b 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -6,7 +6,6 @@ on: pull_request: jobs: - test: name: Test strategy: @@ -27,21 +26,21 @@ jobs: os: windows-latest runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref }} - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -mpip install -U wheel pip - pip install -r requirements-dev.txt + - name: Install build dependencies + run: python -m pip install build flake8 + - name: Run flake8 + run: flake8 ./omero_user_token + - name: Install package + run: python -m pip install .[dev] - name: Run tests - run: | - git fetch --prune --unshallow --tags --force - git describe - flake8 - python setup.py install - pytest -v + run: pytest -v # https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ publish-pypi: @@ -50,18 +49,20 @@ jobs: needs: # Only publish if other jobs passed - test - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref }} - uses: actions/setup-python@v4 - - name: Build package - run: | - # actions/checkout#206 - git fetch --prune --unshallow --tags --force - python -mpip install wheel - python setup.py sdist bdist_wheel + with: + python-version: "3.9" + - name: Install build dependencies + run: python -m pip install build + - name: Build wheel + run: python -m build - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.3.0 + uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} - diff --git a/MANIFEST.in b/MANIFEST.in index 14947ca..3e677d0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,2 @@ include README.md include LICENSE.txt -include version.py diff --git a/README.md b/README.md index dff874d..4a772c7 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,16 @@ API under non-interactive, headless conditions. ## Requirements -* Python 3.6+ +* Python 3.9+ * OMERO.server 5.6 ## Usage Creating a user token and making it active: - omero_user_token set + omero-user-token set -Please see `omero_user_token set --help` for detailed information. The +Please see `omero-user-token set --help` for detailed information. The default server hostname and port can be set in `${HOME}/.omero_user_token/config` using an INI file compatible style: @@ -24,7 +24,7 @@ default server hostname and port can be set in Retrieving the current active token (validation will be performed): - omero_user_token get + omero-user-token get ## Token format @@ -36,7 +36,7 @@ The token format is as follows: ### Bash: ```bash -token=$(omero_user_token get) +token=$(omero-user-token get) if [ $? -ne 0]; then echo "No valid token found" exit 1 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f1dc464 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +[build-system] +requires = ["setuptools>=61", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +dynamic = ["version"] +name = "omero-user-token" +description = "OMERO user token management system" +readme = "README.md" +license = {file = "LICENSE.txt"} +classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', + 'Intended Audience :: Science/Research', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', +] +dependencies = [ + 'click>=7.0', + 'configparser==4.0.2', + 'omero-py>5.6', +] +requires-python = ">=3.9" +authors = [ + {name = "Glencoe Software, Inc.", email="info@glencoesoftware.com"}, +] + +[project.urls] +Repository = "https://github.com/glencoesoftware/omero-user-token" + +[project.scripts] +omero_user_token = "omero_user_token.cli.omero_user_token:main" +omero-user-token = "omero_user_token.cli.omero_user_token:main" + + +[project.optional-dependencies] +dev = [ + "pytest", + "zeroc-ice @ https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp39-cp39-manylinux_2_28_x86_64.whl ; platform_system=='Linux' and python_version=='3.9'", + "zeroc-ice @ https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp310-cp310-manylinux_2_28_x86_64.whl ; platform_system=='Linux' and python_version=='3.10'", + "zeroc-ice @ https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp311-cp311-manylinux_2_28_x86_64.whl ; platform_system=='Linux' and python_version=='3.11'", + "zeroc-ice @ https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp312-cp312-manylinux_2_28_x86_64.whl ; platform_system=='Linux' and python_version=='3.12'", + "zeroc-ice @ https://github.com/glencoesoftware/zeroc-ice-py-macos-x86_64/releases/download/20231130/zeroc_ice-3.6.5-cp39-cp39-macosx_11_0_x86_64.whl ; platform_system=='Darwin' and python_version=='3.9'", + "zeroc-ice @ https://github.com/glencoesoftware/zeroc-ice-py-macos-universal2/releases/download/20240131/zeroc_ice-3.6.5-cp310-cp310-macosx_11_0_universal2.whl ; platform_system=='Darwin' and python_version=='3.10'", + "zeroc-ice @ https://github.com/glencoesoftware/zeroc-ice-py-win-x86_64/releases/download/20240325/zeroc_ice-3.6.5-cp39-cp39-win_amd64.whl ; platform_system=='Windows' and python_version=='3.9'" +] + +[tool.setuptools_scm] \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index a748097..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,10 +0,0 @@ -https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp39-cp39-manylinux_2_28_x86_64.whl; platform_system=="Linux" and python_version=="3.9" -https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp310-cp310-manylinux_2_28_x86_64.whl; platform_system=="Linux" and python_version=="3.10" -https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp311-cp311-manylinux_2_28_x86_64.whl; platform_system=="Linux" and python_version=="3.11" -https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp312-cp312-manylinux_2_28_x86_64.whl; platform_system=="Linux" and python_version=="3.12" -https://github.com/glencoesoftware/zeroc-ice-py-macos-x86_64/releases/download/20231130/zeroc_ice-3.6.5-cp39-cp39-macosx_11_0_x86_64.whl; platform_system!="Windows" and platform_system!="Linux" and python_version=="3.9" -https://github.com/glencoesoftware/zeroc-ice-py-macos-universal2/releases/download/20240131/zeroc_ice-3.6.5-cp310-cp310-macosx_11_0_universal2.whl; platform_system!="Windows" and platform_system!="Linux" and python_version=="3.10" -https://github.com/glencoesoftware/zeroc-ice-py-win-x86_64/releases/download/20240325/zeroc_ice-3.6.5-cp39-cp39-win_amd64.whl; platform_system=="Windows" and python_version=="3.9" -flake8 -setuptools -pytest diff --git a/setup.py b/setup.py deleted file mode 100644 index 9aaab5f..0000000 --- a/setup.py +++ /dev/null @@ -1,86 +0,0 @@ -import os -import sys - -from setuptools import setup, find_packages -from setuptools.command.test import test as TestCommand - -import version - -# Hack to prevent stupid "TypeError: 'NoneType' object is not callable" error -# in multiprocessing/util.py _exit_function when running `python -# setup.py test` or `python setup.py flake8`. See: -# * http://www.eby-sarna.com/pipermail/peak/2010-May/003357.html) -# * https://github.com/getsentry/raven-python/blob/master/setup.py -import multiprocessing -assert multiprocessing # silence flake8 - - -class PyTest(TestCommand): - - user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = [] - - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = [] - self.test_suite = True - - def run_tests(self): - import pytest - if isinstance(self.pytest_args, str): - # pytest requires arguments as a list or tuple even if singular - self.pytest_args = [self.pytest_args] - errno = pytest.main(self.pytest_args) - sys.exit(errno) - - -def read(fname): - """ - Utility function to read the README file. - :rtype : String - """ - return open(os.path.join(os.path.dirname(__file__), fname)).read() - - -setup(name='omero-user-token', - python_requires='>=3.9', - version=version.getVersion(), - description='OMERO user token management system', - long_description=read('README.md'), - long_description_content_type='text/markdown', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', - 'Intended Audience :: Science/Research', - 'Intended Audience :: Developers', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10' - 'Programming Language :: Python :: 3.11' - 'Programming Language :: Python :: 3.12' - ], - keywords='', - author='Glencoe Software, Inc.', - author_email='info@glencoesoftware.com', - url='https://github.com/glencoesoftware/omero-user-token', - packages=find_packages(), - zip_safe=True, - include_package_data=True, - platforms='any', - setup_requires=['flake8'], - install_requires=[ - 'click>=7.0', - 'configparser==4.0.2', - 'omero-py>5.6', - ], - tests_require=[], - cmdclass={'test': PyTest}, - data_files=[], - entry_points={ - 'console_scripts': [ - 'omero_user_token = omero_user_token.cli.omero_user_token:main', - ] - } - ) diff --git a/version.py b/version.py deleted file mode 100644 index 6e54202..0000000 --- a/version.py +++ /dev/null @@ -1,123 +0,0 @@ -# -*- coding: utf-8 -*- - -"""Calculates the current version number. - -If possible, uses output of “git describe” modified to conform to the -visioning scheme that setuptools uses (see PEP 386). Releases must be -labelled with annotated tags (signed tags are annotated) of the following -format: - - v(.)+ [ {a|b|c|rc} (.)* ] - -If “git describe” returns an error (likely because we're in an unpacked copy -of a release tarball, rather than a git working copy), or returns a tag that -does not match the above format, version is read from RELEASE-VERSION file. - -To use this script, simply import it your setup.py file, and use the results -of getVersion() as your package version: - - import version - setup( - version=version.getVersion(), - . - . - . - ) - -This will automatically update the RELEASE-VERSION file. The RELEASE-VERSION -file should *not* be checked into git but it *should* be included in sdist -tarballs (as should version.py file). To do this, run: - - echo include RELEASE-VERSION version.py >>MANIFEST.in - echo RELEASE-VERSION >>.gitignore - -With that setup, a new release can be labelled by simply invoking: - - git tag -s v1.0 -""" - -__author__ = ('Douglas Creager ', - 'Michal Nazarewicz ') -__license__ = 'This file is placed into the public domain.' -__maintainer__ = 'Michal Nazarewicz' -__email__ = 'mina86@mina86.com' - -__all__ = ('getVersion') - - -import re -import subprocess -import sys - - -RELEASE_VERSION_FILE = 'omero_user_token/version.py' - -# http://www.python.org/dev/peps/pep-0386/ -_PEP386_SHORT_VERSION_RE = r'\d+(?:\.\d+)+(?:(?:[abc]|rc)\d+(?:\.\d+)*)?' -_PEP386_VERSION_RE = r'^%s(?:\.post\d+)?(?:\.dev\d+)?$' % ( - _PEP386_SHORT_VERSION_RE) -_GIT_DESCRIPTION_RE = r'^v(?P%s)-(?P\d+)-g(?P[\da-f]+)$' % ( - _PEP386_SHORT_VERSION_RE) - - -def readGitVersion(): - try: - proc = subprocess.Popen(('git', 'describe', '--long', - '--match', 'v[0-9]*.*'), - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - data, _ = proc.communicate() - if proc.returncode: - return None - ver = data.splitlines()[0].strip().decode('utf-8') - except Exception: - return None - - if not ver: - return None - m = re.search(_GIT_DESCRIPTION_RE, ver) - if not m: - sys.stderr.write('version: git description (%s) is invalid, ' - 'ignoring\n' % ver) - return None - - commits = int(m.group('commits')) - if not commits: - return m.group('ver') - else: - return '%s.post%d.dev%d' % ( - m.group('ver'), commits, int(m.group('sha'), 16)) - - -def readReleaseVersion(): - try: - fd = open(RELEASE_VERSION_FILE) - try: - ver = fd.readline().rsplit('= ', 1)[-1].strip('\'').strip() - finally: - fd.close() - if not re.search(_PEP386_VERSION_RE, ver): - sys.stderr.write('version: release version (%s) is invalid, ' - 'will use it anyway\n' % ver) - return ver - except Exception: - return None - - -def writeReleaseVersion(version): - fd = open(RELEASE_VERSION_FILE, 'w') - fd.write("VERSION = '%s'\n" % version) - fd.close() - - -def getVersion(): - release_version = readReleaseVersion() - version = readGitVersion() or release_version - if not version: - version = '0.0.0' - elif version != release_version: - writeReleaseVersion(version) - return version - - -if __name__ == '__main__': - print(getVersion())