From 4b03b9e73bb4663a02a27e4d668ecdff237e463d Mon Sep 17 00:00:00 2001 From: Jacopo Abramo Date: Mon, 13 Oct 2025 17:54:36 +0200 Subject: [PATCH 1/4] BLD: migrate building to pyproject.toml --- pyproject.toml | 126 +++++++++++++++++++++++++++++++++++++++++++++++- setup.cfg | 128 ------------------------------------------------- setup.py | 7 --- 3 files changed, 125 insertions(+), 136 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml index 88c92c35f..5a4071114 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,83 @@ requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"] build-backend = "setuptools.build_meta" +[project] +name = "ophyd" +description = "Bluesky hardware abstraction with an emphasis on EPICS" +dynamic = ["version"] +readme = "README.rst" +requires-python = ">=3.8" +license = {text = "BSD-3-Clause"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +dependencies = [ + "networkx>=2.0", + "numpy", + "opentelemetry-api", + "packaging", + "pint", +] + +[project.optional-dependencies] +dev = [ + "attrs>=19.3.0", + "black==22.3.0", + "bluesky>=1.11.0", + "caproto[standard] >=0.4.2rc1,!=1.2.0", + "pytest-codecov", + "databroker>=1.0.0b1", + "doctr", + "epics-pypdb", + "flake8", + "flake8-isort", + "h5py", + "inflection", + "ipython", + "ipywidgets", + "matplotlib", + "mypy", + "myst-parser", + "numpydoc", + "pre-commit", + "pydata-sphinx-theme", + "pyepics>=3.4.2,<3.5.7", + "pytest", + "pytest-asyncio", + "pytest-cov", + "pytest-faulthandler", + "pytest-rerunfailures", + "pytest-timeout", + "pipdeptree", + "setuptools>=64", + "setuptools_scm[toml]>=6.2", + "sphinx-autobuild", + "sphinx-design", + "tox-direct", +] + +[project.urls] +Homepage = "https://github.com/bluesky/ophyd" +Documentation = "https://blueskyproject.io/ophyd/" +Repository = "https://github.com/bluesky/ophyd.git" +Issues = "https://github.com/bluesky/ophyd/issues" +Changelog = "https://github.com/bluesky/ophyd/blob/main/docs/user/reference/release_notes.rst" + +[project.entry-points."databroker.handlers"] +NPY_SEQ = "ophyd.sim:NumpySeqHandler" + +[tool.setuptools] +packages = ["ophyd"] + +[tool.setuptools.package-data] +ophyd = ["*.rst"] + [tool.setuptools_scm] write_to = "ophyd/_version.py" @@ -20,4 +97,51 @@ markers = [ asyncio_mode = "auto" # https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings # filterwarnings = "error" -python_files = "test_*.py" \ No newline at end of file +python_files = "test_*.py" + +[tool.isort] +profile = "black" + +[tool.flake8] +max-line-length = 115 +extend-ignore = [ + "W504", + "W503", + "E203", + "F811", + "F722", +] +exclude = [ + "ui_*", + ".tox", + ".venv", + "docs/source", + "ophyd/areadetector/docs.py", +] + +[tool.coverage.run] +concurrency = [ + "thread", + "multiprocessing", +] +data_file = "/tmp/ophyd.coverage" + +[tool.tox] +legacy_tox_ini = """ +[tox] +skipsdist = True + +[testenv:pytest] +allowlist_externals = pytest +commands = pytest {posargs} + +[testenv:pre-commit] +allowlist_externals = pre-commit +commands = pre-commit run --all-files {posargs} + +[testenv:docs] +allowlist_externals = + sphinx-build + sphinx-autobuild +commands = sphinx-{posargs:build -EW --keep-going} -T docs build/html +""" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 1a33deeea..000000000 --- a/setup.cfg +++ /dev/null @@ -1,128 +0,0 @@ -[metadata] -name = ophyd -description = Bluesky hardware abstraction with an emphasis on EPICS -url = https://github.com/bluesky/ophyd -license = BSD -long_description = file: README.rst -long_description_content_type = text/x-rst -classifiers = - License :: OSI Approved :: BSD License - Development Status :: 5 - Production/Stable - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: 3.13 - -[options] -python_requires = >=3.8 -packages = find: -setup_requires = - setuptools_scm[toml]>=6.2 - -# Specify any package dependencies below. -install_requires = - networkx>=2.0 - numpy - opentelemetry-api - packaging - pint - -[options.extras_require] -# For development tests/docs -dev = - attrs>=19.3.0 - black==22.3.0 - bluesky>=1.11.0 - caproto[standard] >=0.4.2rc1,!=1.2.0 - pytest-codecov - databroker>=1.0.0b1 - doctr - epics-pypdb - # Upper bound on flake8 while flake8-isort catches up - # https://github.com/gforcada/flake8-isort/issues/115 - flake8 - flake8-isort - h5py - inflection - ipython - ipywidgets - matplotlib - mypy - myst-parser - numpydoc - pre-commit - pydata-sphinx-theme - pyepics>=3.4.2,<3.5.7 - pytest - pytest-asyncio - pytest-cov - pytest-faulthandler - pytest-rerunfailures - pytest-timeout - pipdeptree - setuptools>=64 - setuptools_scm[toml]>=6.2 - sphinx-autobuild - sphinx-design - tox-direct - -# Specify any package data to be included in the wheel below. -[options.package_data] -ophyd = - # Include our documentation helpers: - "*.rst" - -[options.entry_points] -databroker.handlers = - NPY_SEQ = ophyd.sim:NumpySeqHandler - -[isort] -profile=black - -[flake8] -max-line-length = 115 -extend-ignore = - W504, - W503, - # See https://github.com/PyCQA/pycodestyle/issues/373 - E203, - # support typing.overload decorator - F811, - # allow Annotated[typ, some_func("some string")] - F722, -exclude = - ui_* - .tox - .venv - docs/source, - ophyd/areadetector/docs.py - -[coverage:run] -concurrency= - thread - multiprocessing -data_file = /tmp/ophyd.coverage - -# Use tox to provide parallel linting and testing -# NOTE that we pre-install all tools in the dev dependencies (including tox). -# Hence the use of allowlist_externals instead of using the tox virtualenvs. -# This ensures a match between developer time tools in the IDE and tox tools. -# Setting TOX_DIRECT=1 in the environment will make this even faster -[tox:tox] -skipsdist = True - -[testenv:pytest] -allowlist_externals = pytest -commands = pytest {posargs} - -[testenv:pre-commit] -allowlist_externals = pre-commit -commands = pre-commit run --all-files {posargs} - -[testenv:docs] -allowlist_externals = - sphinx-build - sphinx-autobuild -commands = sphinx-{posargs:build -EW --keep-going} -T docs build/html diff --git a/setup.py b/setup.py deleted file mode 100644 index 6b13f70e8..000000000 --- a/setup.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python -from setuptools import setup - -# NOTE: This file must remain Python 2 compatible for the foreseeable future, -# to ensure that we error out properly for people with outdated setuptools -# and/or pip. -setup() From 106fcdab650cbc735c0b4d2af13b5298ab8d8244 Mon Sep 17 00:00:00 2001 From: Jacopo Abramo Date: Thu, 16 Oct 2025 09:17:21 +0200 Subject: [PATCH 2/4] STY: disable flake8 in pre-commit - future PR will remove it entirely and move to ruff instead --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 812280964..623a97ded 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,9 +15,9 @@ repos: entry: black --check --diff types: [python] - - id: flake8 - name: Run flake8 - stages: [pre-commit] - language: system - entry: flake8 - types: [python] + # - id: flake8 + # name: Run flake8 + # stages: [pre-commit] + # language: system + # entry: flake8 + # types: [python] From f8085c28fbbacebe9537ba54b2591556199d7436 Mon Sep 17 00:00:00 2001 From: Jacopo Abramo Date: Thu, 16 Oct 2025 09:18:02 +0200 Subject: [PATCH 3/4] STY: add comment about future flake8 removal --- .pre-commit-config.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 623a97ded..a9f230b42 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,9 @@ repos: language: system entry: black --check --diff types: [python] - + # temporarily disable; + # a follow-up PR will replace + # flake8 with ruff entirely # - id: flake8 # name: Run flake8 # stages: [pre-commit] From 5eced93af88217d9a9705c8ece46dca7c0d8882e Mon Sep 17 00:00:00 2001 From: Jacopo Abramo Date: Thu, 16 Oct 2025 19:43:02 +0200 Subject: [PATCH 4/4] BLD: replace flake8 and black with ruff --- .pre-commit-config.yaml | 15 +++------------ pyproject.toml | 14 ++++---------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a9f230b42..e71f7daa4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,18 +8,9 @@ repos: - repo: local hooks: - - id: black - name: Run black + - id: ruff + name: Run ruff stages: [pre-commit] language: system - entry: black --check --diff + entry: ruff check types: [python] - # temporarily disable; - # a follow-up PR will replace - # flake8 with ruff entirely - # - id: flake8 - # name: Run flake8 - # stages: [pre-commit] - # language: system - # entry: flake8 - # types: [python] diff --git a/pyproject.toml b/pyproject.toml index 5a4071114..48d3ed0d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,15 +29,13 @@ dependencies = [ [project.optional-dependencies] dev = [ "attrs>=19.3.0", - "black==22.3.0", "bluesky>=1.11.0", "caproto[standard] >=0.4.2rc1,!=1.2.0", "pytest-codecov", "databroker>=1.0.0b1", "doctr", "epics-pypdb", - "flake8", - "flake8-isort", + "ruff", "h5py", "inflection", "ipython", @@ -99,18 +97,14 @@ asyncio_mode = "auto" # filterwarnings = "error" python_files = "test_*.py" -[tool.isort] -profile = "black" - -[tool.flake8] -max-line-length = 115 +[tool.ruff] +line-length = 115 extend-ignore = [ - "W504", - "W503", "E203", "F811", "F722", ] + exclude = [ "ui_*", ".tox",