From 0a08fc97fa74fa5ef471bdfc3c6248d3cec7f5ce Mon Sep 17 00:00:00 2001 From: Jaladh Singhal Date: Thu, 29 Aug 2024 16:39:24 -0700 Subject: [PATCH 1/4] FIREFLY-1527: Update package config and remove outdated files --- .travis.yml | 22 ------------------- firefly_client/__init__.py | 9 ++++++-- pyproject.toml | 44 ++++++++++++++++++++++++++++++++++++++ requirements.txt | 4 ---- setup.cfg | 2 -- setup.py | 20 ----------------- 6 files changed, 51 insertions(+), 50 deletions(-) delete mode 100644 .travis.yml create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 27a7068..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -sudo: false -language: python -matrix: - include: - - python: '3.6' - env: LTD_MASON_BUILD=true -install: -- pip install -r requirements.txt -- pip install -e . -script: -- pytest -- cd doc && sphinx-build -b html -a -d _build/doctree . _build/html && cd .. -after_success: -- ltd-mason-travis --html-dir doc/_build/html --verbose -env: - global: - - LTD_MASON_BUILD=false - - LTD_MASON_PRODUCT="firefly-client" - # travis encrypt "LTD_MASON_AWS_ID=... LTD_MASON_AWS_SECRET=... - - secure: Sd/7ZpYW5bcHKr5mWUdIAXTW/yd0jjCgrOQez/Q0+qHjySTXVi6kFPJcrG7fMOS2iRMetGgroec12OfIDRek1598yEU6FLD7CuKfS2mPd6qCMCUV9p0JQcIej267ItGWR7FYjsNdI7U9kzLfFa6/56jbIoDIRX/QAmTB9PGl3LTbpHiGkLZ0diFi1xtoGhmPMwA/iWxJ4MEKmWe5xCA2Da3DEJVKgpG4aj/4yW/Hb/dycGk15rbNvKP7GMRsdJ4D1slp98E22KFs5Mtm9NLBP9TKnJUTTn9Rt3PWYRx/6U0BXwdCKayZrFQJ/EFVls6jDjo+MnE69vwfwftqmvi+Bd2Z6rsEWXjLgTDFYenowKY8TJHAX13x6KDqUFwhvrQKt7PaT5WuNbOnmIO428PYkopv2QLU1qEj8Ht9Ih6tmh6AbxXfMbLJ8q8xslY1XIZ5W2X9heOCqn2u7McpZlFtuDYiF46Vl8tqgG6ZA3nhXNcNLq6MJhMsOZ6MHBxSru7bR6RaoA+NJ7yHOw32P2Sw2ENwshIocauhy0tzE0SYTMlXxiVuXIFvea0kcnSn7K/MP2EsiPZJfIvttrE6sQVRKh5/zkK6eCEewyg0hCzkCc0Z+BhNs9veHxTxRQn5UDXxBA9j5gsp72nExa37Tvc6uQQlbPCNCTyNcwusi+fdZ+Y= - # travis encrypt "LTD_KEEPER_URL=... LTD_KEEPER_USER=... LTD_KEEPER_PASSWORD=..." --add env.global - - secure: pXL676/O/IGUX2DNXhz2c119d+w4lzMc5e99i0vCVn5R/+t3DPbQP6zyjACeUqfJoS1JFLqSURsl3nhayj+GU3bStPX/3iAZEWBYYHrsRh6zy0kjBC68mmwmqpt2cm3vtS8IOQvPMt1xgnkvLX+Jn+WP9VcNp6cHwRWAW3nS36o8aieLjJgvJui6YYdPOOQUgnn1ZH37LXCIxfVbARMvKZteDhEJmwQuaaofFO0YizvENUUi5aK/QEzpsazEBlmRrRGtUp8Nm0yudPg/Ugxfv9M/vj6cTpKrqh5eMNMPjopcmdpn5j4ZWC/ES6gaFl3DwcG8zg2rEVtLCjnR39JnQs5Ba+U37jAXqmOwSFROR+kWuZpRYL3G40tvpx8i9bd0qVFUFJnABuHGmqWXYQCt4cQ7C5FfUdIzQmW/1H0hIErHWeK0jaGFgixJUU3m4QJnz9NsbFenywGPVMBIdA6vpiuwJIcOa8lkFfu9ExjtJDoagtL5oTgLETDUTJcNx5t7zMlDxJ6j2D46WEB45SBUnUoIw5BmAzGRppFRKMetXvkVwwJaNeUB/nMSE6C2UJyqCYZWO4/4JC59qiDGfoJn3KTebp24CUA1nv4JYKhYY+9FCl+eirfWoJq4t/LMuMTTz39zUB4Vz0G4YgJ2K3aQBnn6GUtGHGJ4r25prmJyJ0s= diff --git a/firefly_client/__init__.py b/firefly_client/__init__.py index 75f0568..30fe29e 100644 --- a/firefly_client/__init__.py +++ b/firefly_client/__init__.py @@ -1,7 +1,12 @@ +from importlib.metadata import PackageNotFoundError, version + from .firefly_client import FireflyClient from .ffws import FFWs from .env import Env from .range_values import RangeValues -import pkg_resources -__version__ = pkg_resources.get_distribution("firefly_client").version +try: + __version__ = version("firefly_client") +except PackageNotFoundError: + # package is not installed + __version__ = None diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a1cbb14 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,44 @@ +[build-system] +requires = ["setuptools >= 64.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "firefly_client" +version = "3.0.2" +description = "Python API for Firefly: displaying tables, images, & charts" +authors = [ + {name = "IPAC LSST SUIT"} +] +readme = "README.md" +license = {file = "License.txt"} +requires-python = ">=3.8" +dependencies = [ + "websocket-client", + "requests" +] +keywords = [ + "jupyter", + "firefly", + "caltech", + "ipac", + "astronomy", + "visualization", + "images", + "charts", + "tables" +] +classifiers = [ + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Framework :: Jupyter", + "Framework :: Jupyter :: JupyterLab", + "Topic :: Scientific/Engineering :: Astronomy", + "Topic :: Scientific/Engineering :: Visualization", + "Programming Language :: Python", + "Programming Language :: Python :: 3" +] + +[project.urls] +Homepage = "https://github.com/Caltech-IPAC/firefly_client" +Documentation = "https://caltech-ipac.github.io/firefly_client" +Repository = "http://github.com/Caltech-IPAC/firefly_client.git" diff --git a/requirements.txt b/requirements.txt index 5572af8..d873dba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,3 @@ -requests~=2.30.0 -setuptools~=41.0.1 -websocket-client~=0.58.0 - # Documentation dependencies Sphinx~=7.1.0 sphinx-automodapi diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3c6e79c..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 diff --git a/setup.py b/setup.py deleted file mode 100755 index c998dc1..0000000 --- a/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed under a 3-clause BSD style license - see License.txt - -from setuptools import setup - -setup( - name='firefly_client', - version='3.0.2', - description='Python API for Firefly', - author='IPAC LSST SUIT', - license='BSD', - url='http://github.com/Caltech-IPAC/firefly_client', - packages=['firefly_client'], - install_requires=['websocket-client', 'requests'], - classifiers=[ - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - ] -) From 0b009703849b85b9b688bffb9dbfb59de48dc2a5 Mon Sep 17 00:00:00 2001 From: Jaladh Singhal Date: Thu, 29 Aug 2024 16:57:52 -0700 Subject: [PATCH 2/4] FIREFLY-1527: Fix linting errors --- firefly_client/env.py | 4 ++-- firefly_client/firefly_client.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firefly_client/env.py b/firefly_client/env.py index dd80692..0f552d0 100644 --- a/firefly_client/env.py +++ b/firefly_client/env.py @@ -46,7 +46,7 @@ def raise_invalid_lab_error(cls): if not cls.firefly_channel_lab: raise RuntimeError(COULD_NO_FIND_ENV + ENV_FF_CHANNEL_LAB + '. ' + EXT_INCORRECT + ' ' + SUGGESTION) if not cls.firefly_url_lab: - raise RuntimeError(COULD_NO_FIND_ENV + ENV_FF_URL_LAB_LAB + '. ' + EXT_INCORRECT + ' ' + SUGGESTION) + raise RuntimeError(COULD_NO_FIND_ENV + ENV_FF_URL_LAB + '. ' + EXT_INCORRECT + ' ' + SUGGESTION) @classmethod def show_start_browser_tab_msg(cls, url): @@ -99,6 +99,6 @@ def failed_net_message(cls, location, status_code=-1): if cls.firefly_lab_extension and cls.firefly_url_lab: err_message += ('\nCheck the Firefly URL in ~/.jupyter/jupyter_notebook_config.py' + ' or ~/.jupyter/jupyter_notebook_config.json') - elif firefly_url: + elif cls.firefly_url: err_message += 'Check setting of FIREFLY_URL environment variable: %s' % cls.firefly_url return err_message diff --git a/firefly_client/firefly_client.py b/firefly_client/firefly_client.py index a2be968..a08f47c 100644 --- a/firefly_client/firefly_client.py +++ b/firefly_client/firefly_client.py @@ -266,7 +266,7 @@ def show_lab_tab(self, html_file=_def_html_file): @staticmethod def get_viewer_mode(html_file, viewer_override): if viewer_override: - if viewer_override in _viewer_modes: + if viewer_override in FireflyClient._viewer_modes: return viewer_override else: warn('viewer_override mode: {} is not a recognized mode, using {}'.format(viewer_override, UNKNOWN)) @@ -348,7 +348,7 @@ def add_listener(self, callback, name=ALL): def header_cb(headers): self.header_from_ws = headers FFWs.add_listener(self.wsproto, self.auth_headers, self.channel, self.location, callback, name, header_cb) except ConnectionRefusedError as err: - raise ValueError(err_message) from err + raise ValueError(f"Couldn't add listener: {err}") from err def remove_listener(self, callback, name=ALL): """ From d95a01abe2b9b8e303992530e1e4ca81e8f718fd Mon Sep 17 00:00:00 2001 From: Jaladh Singhal Date: Thu, 29 Aug 2024 17:23:51 -0700 Subject: [PATCH 3/4] FIREFLY-1527: Update release doc & package description --- docs/development/new-release-procedure.md | 26 ++++++++++------------- pyproject.toml | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/docs/development/new-release-procedure.md b/docs/development/new-release-procedure.md index 2896788..9f66954 100644 --- a/docs/development/new-release-procedure.md +++ b/docs/development/new-release-procedure.md @@ -2,20 +2,17 @@ ## Procedure 1. To push a new release you must be a maintainer in pypi ([see pypi below](#pypi)) -2. Bump version in setup.py (this step is might be done in the PR) +2. Bump version in pyproject.toml (this step might be done in the PR) 3. Clean out old distribution - `rm dist/*` 4. Create the distribution - - Create a tar/gzip file with the correct directory structure + - Create a tar/gzip file (unbuilt source distibution) and a wheel file + (built package) together using the `build` package: ```bash - python setup.py sdist + pip install --upgrade build + python -m build ``` - - Create the wheel file - ```bash - pip install --upgrade wheel - python setup.py bdist_wheel - ``` - - check it: `ls dist` should show two files a `.tar.gz` file and a `.whl` file + - Check it: `ls dist` should show two files a `.tar.gz` file and a `.whl` file 5. _Optional_ - At this point you could do an optional test installation ([see below](#optional-test-installation)) 6. Upload to PYPI 1. _One-time-only auth setup:_ Login to pypi and then in your account settings, go to the API tokens section and select "Add API token". Give it any name and select scope to project:firefly-client and create token. To save this token for later uses, make sure to create a `$HOME/.pypirc` file (or update it if you already have it) with the following: @@ -35,22 +32,21 @@ pip install --upgrade twine twine upload dist/* --repository firefly-client ``` -7. If any files were edited (i.e `setup.py`) +7. If any files were edited (i.e `pyproject.toml`) - `git commit - a` - `git push origin master` 8. Tag - - `git tag -a 2.5.0` (replace version number with the current version from setup.py) + - `git tag -a 2.5.0` (replace version number with the current version from pyproject.toml) 9. Push tags - `git push --tags` 10. After this you can install - `pip install firefly_client` -11. Make is release with github, using the tag above +11. Make a release with github, using the tag above - https://github.com/Caltech-IPAC/firefly_client/releases ## PYPI -- https://pypi.org/project/firefly-client/ -- Currently two maintainers +- Must be maintainer at https://pypi.org/project/firefly-client/ - Testing site: https://test.pypi.org/project/firefly-client/ ## Optional Test installation @@ -63,7 +59,7 @@ ## Conda and conda-forge -Anytime the version tag is updated conda-forge it set up to do a pull and add `firefly_client` to its distribution. +Anytime the version tag is updated, conda-forge is set up to do a pull and add `firefly_client` to its distribution. See the following sites: - https://github.com/conda-forge/firefly-client-feedstock/ diff --git a/pyproject.toml b/pyproject.toml index a1cbb14..5e7a65b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "firefly_client" version = "3.0.2" -description = "Python API for Firefly: displaying tables, images, & charts" +description = "Python API for Firefly: display astronomical data as tables, images, charts, and more!" authors = [ {name = "IPAC LSST SUIT"} ] From ebf2c9e8b8ffb53237ee07709f22a7e7231617bb Mon Sep 17 00:00:00 2001 From: Jaladh Singhal Date: Thu, 29 Aug 2024 18:40:03 -0700 Subject: [PATCH 4/4] FIREFLY-1527: Move docs dependencies to pyproject.toml --- .github/workflows/publish-docs.yml | 7 ++----- pyproject.toml | 8 ++++++++ requirements.txt | 5 ----- 3 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 requirements.txt diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index d7906c7..1298df9 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -24,11 +24,8 @@ jobs: python -m venv .venv source .venv/bin/activate - - name: Install dependencies - run: pip install -r requirements.txt - - - name: Install package - run: pip install -e . + - name: Install the package with docs dependencies + run: pip install -e .[docs] - name: Build docs run: | diff --git a/pyproject.toml b/pyproject.toml index 5e7a65b..0b381ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,3 +42,11 @@ classifiers = [ Homepage = "https://github.com/Caltech-IPAC/firefly_client" Documentation = "https://caltech-ipac.github.io/firefly_client" Repository = "http://github.com/Caltech-IPAC/firefly_client.git" + +[project.optional-dependencies] +docs = [ + "Sphinx~=7.1.0", + "sphinx-automodapi", + "pydata-sphinx-theme", + "myst-parser" +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d873dba..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Documentation dependencies -Sphinx~=7.1.0 -sphinx-automodapi -pydata-sphinx-theme -myst-parser \ No newline at end of file