From 50a142f1cc761553f14570c6c5f7e799846a0ddf Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Tue, 19 Mar 2024 23:29:34 -0500 Subject: [PATCH 1/3] MNT #914 setup.py --> pyproject.toml --- .ruff.toml | 81 ---------------- CHANGES.rst | 1 + docs/source/conf.py | 21 +++-- docs/source/index.rst | 2 +- pyproject.toml | 214 +++++++++++++++++++++++++++++++++++++++++- setup.cfg | 129 ------------------------- setup.py | 24 ----- 7 files changed, 225 insertions(+), 247 deletions(-) delete mode 100644 .ruff.toml delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/.ruff.toml b/.ruff.toml deleted file mode 100644 index b03f2a21a..000000000 --- a/.ruff.toml +++ /dev/null @@ -1,81 +0,0 @@ -# Exclude a variety of commonly ignored directories. -exclude = [ - ".bzr", - ".direnv", - ".eggs", - ".git", - ".git-rewrite", - ".hg", - ".ipynb_checkpoints", - ".mypy_cache", - ".nox", - ".pants.d", - ".pyenv", - ".pytest_cache", - ".pytype", - ".ruff_cache", - ".svn", - ".tox", - ".venv", - ".vscode", - "__pypackages__", - "_build", - "buck-out", - "build", - "dist", - "node_modules", - "site-packages", - "venv", -] - -# Same as Black. -line-length = 115 -indent-width = 4 - -# Assume Python 3.8 -target-version = "py38" - -[lint] -# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. -# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or -# McCabe complexity (`C901`) by default. -select = ["E4", "E7", "E9", "F"] -ignore = ["E402", "E741", "F405"] - -# Allow fix for all enabled rules (when `--fix`) is provided. -fixable = ["ALL"] -unfixable = [] - -# Allow unused variables when underscore-prefixed. -dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" - -[lint.per-file-ignores] -"__init__.py" = ["F401", "F403"] -"**/{tests,docs,tools}/*" = ["E402"] - -[format] -# Like Black, use double quotes for strings. -quote-style = "double" - -# Like Black, indent with spaces, rather than tabs. -indent-style = "space" - -# Like Black, respect magic trailing commas. -skip-magic-trailing-comma = false - -# Like Black, automatically detect the appropriate line ending. -line-ending = "auto" - -# Enable auto-formatting of code examples in docstrings. Markdown, -# reStructuredText code/literal blocks and doctests are all supported. -# -# This is currently disabled by default, but it is planned for this -# to be opt-out in the future. -docstring-code-format = false - -# Set the line length limit used when formatting code snippets in -# docstrings. -# -# This only has an effect when the `docstring-code-format` setting is -# enabled. -docstring-code-line-length = "dynamic" diff --git a/CHANGES.rst b/CHANGES.rst index dd6abefd3..fda58dd04 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -42,6 +42,7 @@ Maintenance * Code format conforms to 'ruff'. * Add additional support for APS Data Management API. +* Refactor packaging from setup.py to pyproject.toml. 1.6.18 ****** diff --git a/docs/source/conf.py b/docs/source/conf.py index a4398f066..5fdf46226 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -5,33 +5,36 @@ # -- Path setup -------------------------------------------------------------- -import configparser +from importlib.metadata import version import json import pathlib import sys +import tomllib sys.path.insert(0, str(pathlib.Path().absolute().parent.parent)) -import apstools +import apstools # noqa # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information root_path = pathlib.Path(__file__).parent.parent.parent -parser = configparser.ConfigParser() -parser.read(root_path / "setup.cfg") -metadata = parser["metadata"] +with open(root_path / "pyproject.toml", "rb") as fp: + toml = tomllib.load(fp) +metadata = toml["project"] + +gh_org = "BCDA-APS" project = metadata["name"] -copyright = metadata["copyright"] -author = metadata["author"] +copyright = toml["tool"]["copyright"]["copyright"] +author = metadata["authors"][0]["name"] description = metadata["description"] rst_prolog = f".. |author| replace:: {author}" +github_url = f"https://github.com/{gh_org}/{project}" # -- Special handling for version numbers ------------------------------------ # https://github.com/pypa/setuptools_scm#usage-from-sphinx -gh_org = "BCDA-APS" -release = apstools.__version__ +release = version(project) version = ".".join(release.split(".")[:2]) # fmt: off diff --git a/docs/source/index.rst b/docs/source/index.rst index 4cef64130..1bd6bac9c 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -2,7 +2,7 @@ apstools ======== -Various Python tools for use with Bluesky at the APS +Library of Python tools for use with Bluesky at the APS .. toctree:: :maxdepth: 1 diff --git a/pyproject.toml b/pyproject.toml index 2bb0bc8c0..3467664cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,86 @@ [build-system] -requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" +requires = [ + "setuptools_scm[toml]>=8.0", + "setuptools>=64", +] + +[project] +name = "apstools" +dynamic = ["version"] +description = "Library of Python tools for use with the Bluesky Framework at the APS." +authors = [ + { name="Pete R. Jemian" }, + { name="Fanny Rodolakis" }, + { name="Max Wyman" }, + { name="Eric Codrea" }, +] +maintainers = [ + { name="Pete Jemian" }, + { name="Fanny Rodolakis" }, + { name="Max Wyman" }, + { name="Eric Codrea" }, +] +readme = "README.md" +requires-python = ">=3.8" +keywords = ["EPICS", "data acquisition", "diffraction", "NeXus", "HDF5", "SPEC", "MatPlotLib"] +license = {file = "LICENSE.txt"} +classifiers = [ + "Development Status :: 6 - Mature", + "Environment :: Console", + "Intended Audience :: Science/Research", + "License :: Freely Distributable", + "License :: Public Domain", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Astronomy", + "Topic :: Scientific/Engineering :: Bio-Informatics", + "Topic :: Scientific/Engineering :: Chemistry", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator", + "Topic :: Scientific/Engineering :: Mathematics", + "Topic :: Scientific/Engineering :: Physics", + "Topic :: Software Development :: Embedded Systems", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Scientific/Engineering :: Visualization", + "Topic :: Software Development", + "Topic :: Utilities", +] +dependencies = [ + "area-detector-handlers", + "bluesky>=1.6.2,!=1.11.0", + "databroker==1.2.5", + "databroker-pack", + "h5py", + "matplotlib", + "mongoquery>=1.3.6", + "numpy", + "ophyd>=1.5.1", + "openpyxl", + "pint", + "psutil", + "pyepics>=3.4.2", + "pyRestTable>=2020.0.8", + "pysumreg", + "spec2nexus>=2021.1.7", + "xlrd", +] + +[project.scripts] +spec2ophyd = "apstools.migration.spec2ophyd:main" + +[project.urls] +"Homepage" = "https://bcda-aps.github.io/apstools/latest/" +"Bug Tracker" = "https://github.com/bcda-aps/apstools/issues" [tool.black] line-length = 115 -target-version = ['py37'] +target-version = ['py311'] include = '\.pyi?$' exclude = ''' ( @@ -28,11 +104,143 @@ exclude = ''' ) ''' +[tool.copyright] +copyright = "2017-2024, UChicago Argonne, LLC" + +[tool.coverage.run] +concurrency = [ + "thread", + "multiprocessing" +] +omit = [ + # omit anything under the installed packages directory + "*/site-packages/*", + # omit these individual files +] +relative_files = true + +[tool.flake8] +max-line-length = 115 +exclude = [ + ".git", + "__pycache__", + "build", + "dist", + "docs/source", + "ideas/", + "resources/debug_findpv.py", +] +extend-ignore = [ + "E203", # See https://github.com/PyCQA/pycodestyle/issues/373 + "E226", + "E402", # module level import not at top of file (for cansas.py) + "E501", + "E741", + "F401", # imported but unused + "F403", + "F722", # allow Annotated[typ, some_func("some string")] + "F811", # support typing.overload decorator + "W503", + "W504", +] + [tool.isort] -profile = "black" force_single_line = "True" +include_trailing_comma = true multi_line_output = "NOQA" +profile = "black" src_paths = ["apstools"] +[tool.pytest.ini_options] +addopts = [ + "--import-mode=importlib", +] + +[tool.ruff] +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 115 +indent-width = 4 + +# Assume Python 3.8 +target-version = "py38" + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = ["E402", "E741", "F405"] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401", "F403"] +"**/{tests,docs,tools}/*" = ["E402"] + +[tool.ruff.format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" + +[tool.setuptools] +py-modules = ["apstools"] + [tool.setuptools_scm] write_to = "apstools/_version.py" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c9f7648a8..000000000 --- a/setup.cfg +++ /dev/null @@ -1,129 +0,0 @@ -[coverage:run] -concurrency= - thread - multiprocessing -omit = - # omit anything under the installed packages directory - */site-packages/* - # omit these individual files -relative_files = True - -[flake8] -max-line-length = 115 - - ; comments - ; E203, # See https://github.com/PyCQA/pycodestyle/issues/373 - ; F401, # imported but unused - ; E402, # module level import not at top of file (for cansas.py) - ; F722, # allow Annotated[typ, some_func("some string")] - ; F811, # support typing.overload decorator - -extend-ignore = - E203, E226, F401, E402, E501, E741, - F401, F403, F722, F811, - W503, W504, -exclude = - .git, - __pycache__, - build, - dist, - docs/source, - ideas/, - resources/debug_findpv.py - -[isort] -profile=black - -[metadata] -name = apstools -copyright = 2017-2023, UChicago Argonne, LLC -description = Various Python tools for use with the Bluesky Framework at the APS. -description_file = README.md -description_file_content_type = text/markdown -institution = Advanced Photon Source, Argonne National Laboratory -url = https://bcda-aps.github.io/apstools/latest/ -license = Free To Use But Restricted (see LICENSE.txt file) -license_url = "https://github.com/BCDA-APS/apstools/blob/main/LICENSE.txt" -long_description = file: README.md -long_description_content_type = text/markdown -keywords = ["SPEC", "diffraction", "data acquisition", "NeXus", "HDF5", "MatPlotLib"] -author = Pete R. Jemian -author_email = jemian@anl.gov -# https://pypi.org/classifiers/ -classifiers = - Development Status :: 6 - Mature - Environment :: Console - Intended Audience :: Science/Research - License :: Freely Distributable - License :: Public Domain - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Astronomy - Topic :: Scientific/Engineering :: Bio-Informatics - Topic :: Scientific/Engineering :: Chemistry - Topic :: Scientific/Engineering :: Information Analysis - Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator - Topic :: Scientific/Engineering :: Mathematics - Topic :: Scientific/Engineering :: Physics - Topic :: Software Development :: Embedded Systems - Topic :: Software Development :: Libraries :: Python Modules - Topic :: Scientific/Engineering :: Visualization - Topic :: Software Development - Topic :: Utilities - -[options] -# python_requires = >=3.8 -packages = find: -# setup_requires = -# setuptools_scm[toml]>=6.2 - -# Specify any package dependencies below. Examples shown -install_requires = - area-detector-handlers - bluesky>=1.6.2 - databroker==1.2.5 - databroker-pack - h5py - matplotlib - mongoquery>=1.3.6 - numpy - ophyd>=1.5.1 - openpyxl - pint - psutil - pyepics>=3.4.2 - pyRestTable>=2020.0.8 - pysumreg - spec2nexus>=2021.1.7 - xlrd - setuptools-scm - -[options.extras_require] -# For development tests/docs -dev = - coveralls - pytest - pytest-cov - setuptools-scm - -# Specify any package data to be included in the wheel below. -[options.package_data] -# Include our documentation helpers: md & rst -apstools = - *.rst - *.md - LICENSE.txt - CHANGES* - devices/*.db - devices/*.ui - devices/*.yml - migration/config - -[options.entry_points] -console_scripts = - spec2ophyd = apstools.migration.spec2ophyd:main diff --git a/setup.py b/setup.py deleted file mode 100755 index e644d6680..000000000 --- a/setup.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python - -import setuptools -import setuptools_scm - -setuptools.setup( - # https://github.com/pypa/setuptools_scm/#setuppy-usage-deprecated - version=setuptools_scm.get_version(), - use_scm_version=True, - setup_requires=["setuptools_scm"], - # confirm the version from command line: - # python -m setuptools_scm - # python setup.py --version -) - -# ----------------------------------------------------------------------------- -# :author: Pete R. Jemian -# :email: jemian@anl.gov -# :copyright: (c) 2017-2024, UChicago Argonne, LLC -# -# Distributed under the terms of the Argonne National Laboratory Open Source License. -# -# The full license is in the file LICENSE.txt, distributed with this software. -# ----------------------------------------------------------------------------- From 678cb3f2c0d2efb220d80aef3a0c199c47ee9a0c Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Tue, 19 Mar 2024 23:30:18 -0500 Subject: [PATCH 2/3] DOC #921 copyright year --- README.md | 4 ++-- docs/source/overview.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cd25a61a7..2f6c4474d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # apstools -Various Python tools for use with the Bluesky framework at the APS. +Library of Python tools for use with the Bluesky framework at the APS. GH tag | GH release | PyPI | conda-forge --- | --- | --- | --- @@ -17,7 +17,7 @@ item | description ------------------|-------------------------------- **author** | Pete R. Jemian **email** | jemian@anl.gov -**copyright** | 2017-2023, UChicago Argonne, LLC +**copyright** | 2017-2024, UChicago Argonne, LLC **documentation** | versions: [latest tagged release](https://bcda-aps.github.io/apstools/latest/) or [development (main branch)](https://bcda-aps.github.io/apstools/dev/) **source** | https://github.com/BCDA-APS/apstools diff --git a/docs/source/overview.rst b/docs/source/overview.rst index 72eaa9cd7..7f017b918 100644 --- a/docs/source/overview.rst +++ b/docs/source/overview.rst @@ -49,7 +49,7 @@ Package Information version |version| release |release| published |today| -copyright 2017-2022, UChicago Argonne, LLC +copyright 2017-2024, UChicago Argonne, LLC license ANL OPEN SOURCE LICENSE (see LICENSE.txt file) author Pete R. Jemian ============= ======================================== From 11995ec6f1907169fa2e059b68f743ee10ded3d5 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Tue, 19 Mar 2024 23:49:48 -0500 Subject: [PATCH 3/3] MNT #914 --- .github/workflows/docs.yml | 4 ++-- docs/source/install.rst | 12 ++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c09aa707f..3262c463d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -66,7 +66,7 @@ jobs: echo "SRC_DIR=$(pwd)" >> ${GITHUB_ENV} echo "TMP_DIR=$(mktemp -d)" >> ${GITHUB_ENV} # next step also creates _version.py file - echo "VERSION=$(./setup.py --version)" >> ${GITHUB_ENV} + echo "VERSION=$(python -m setuptools_scm)" >> ${GITHUB_ENV} - name: Show Environment variables run: | @@ -111,7 +111,7 @@ jobs: - name: Info run: | - set -vxeuo pipefail + set -vxeuo pipefail cd "${TMP_DIR}" echo "pwd=$(pwd)" ls -laFGh diff --git a/docs/source/install.rst b/docs/source/install.rst index 100c36bd2..502a46419 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -37,18 +37,10 @@ GitHub repository listed above:: $ git clone http://github.com/BCDA-APS/apstools.git -To install in the standard Python location:: +To install from the source directory using ``pip`` in editable mode:: $ cd apstools - $ python setup.py install - -To install in user's home directory:: - - $ python setup.py install --user - -To install in an alternate location:: - - $ python setup.py install --prefix=/path/to/installation/dir + $ python -m pip install -e . Required Libraries ##################