Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 4: Setup tox #72

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ htmlcov/
.coverage
.coverage.*
.cache
coverage/
nosetests.xml
coverage.xml
*,cover
.hypothesis/
*.lock

# Translations
*.mo
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SPHINXBUILD ?= uv run sphinx-build
SOURCEDIR = .
BUILDDIR = _build

Expand Down
128 changes: 117 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ build-backend = "setuptools.build_meta"
name = "firefly_client"
version = "3.3.0"
description = "Python API for Firefly: display astronomical data as tables, images, charts, and more!"
authors = [
{name = "IPAC LSST SUIT"}
]
authors = [{ name = "IPAC LSST SUIT" }]
readme = "README.md"
license = {file = "License.txt"}
license = { file = "License.txt" }
requires-python = ">=3.10"
dependencies = [
"websocket-client",
"requests"
]
dependencies = ["websocket-client", "requests"]
keywords = [
"jupyter",
"firefly",
Expand All @@ -25,7 +20,7 @@ keywords = [
"visualization",
"images",
"charts",
"tables"
"tables",
]
classifiers = [
"Intended Audience :: Developers",
Expand All @@ -35,7 +30,7 @@ classifiers = [
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Scientific/Engineering :: Visualization",
"Programming Language :: Python",
"Programming Language :: Python :: 3"
"Programming Language :: Python :: 3",
]

[project.urls]
Expand All @@ -48,5 +43,116 @@ docs = [
"Sphinx~=7.1.0",
"sphinx-automodapi",
"pydata-sphinx-theme",
"myst-parser"
"myst-parser",
]
test = [
"pytest>=8.3.4",
"pytest-container>=0.4.3",
"pytest-cov>=6.0.0",
"pytest-doctestplus>=1.4.0",
"pytest-mock>=3.14.0",
"pytest-xdist>=3.6.1",
"tox>=4.0",
"tox-uv>=1.20",
]
astropy = ["astropy>=6"]

[tool.setuptools]
packages = ["firefly_client"]

[tool.pytest.ini_options]
testpaths = ["firefly_client", "docs", "test"]
doctest_plus = "enabled"
text_file_format = "rst"
addopts = [
"--doctest-rst",
"--numprocesses=4",
"--import-mode=importlib",
"--cov=firefly_client",
"--cov-append",
"--cov-report=term-missing",
"--cov-report=xml:coverage.xml",
"--cov-report=html:coverage",
"--doctest-modules",
]

[tool.coverage.run]
omit = [
"firefly_client/conftest.py",
"firefly_client/*setup_package*",
"firefly_client/tests/*",
"firefly_client/*/tests/*",
"firefly_client/extern/*",
"firefly_client/version*",
"*/firefly_client/conftest.py",
"*/firefly_client/*setup_package*",
"*/firefly_client/tests/*",
"*/firefly_client/*/tests/*",
"*/firefly_client/extern/*",
"*/firefly_client/version*",
]

[tool.coverage.report]
exclude_lines = [
# Have to re-enable the standard pragma
"pragma: no cover",
# Don't complain about packages we have installed
"except ImportError",
# Don't complain if tests don't hit assertions
"raise AssertionError",
"raise NotImplementedError",
# Don't complain about script hooks
"def main(.*):",
# Ignore branches that don't pertain to this version of Python
"pragma: py{ignore_python_version}",
# Don't complain about IPython completion helper
"def _ipython_key_completions_",
# typing.TYPE_CHECKING is False at runtime
"if TYPE_CHECKING:",
# Ignore typing overloads
"@overload",
]

[tool.tox]
env_list = ["clean", "3.10", "3.11", "3.12", "3.13", "3.14", "build_docs"]
requires = ["tox>=4.0", "tox-uv>=1.20"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is subject to change if we decide to go with uv or not or something else


[tool.tox.env_run_base]
commands = [
[
"pytest",
"--doctest-rst",
"--numprocesses=4",
"--import-mode=importlib",
"--cov=firefly_client",
"--cov-append",
"--cov-report=term-missing",
"--cov-report=xml:coverage.xml",
"--cov-report=html:coverage",
"--doctest-modules",
"{posargs}",
],
]
runner = "uv-venv-lock-runner"
description = "run tests with the oldest supported version of key dependencies on {base_python}"
pass_env = ["TOXENV", "CI", "CC", "LOCALE_ARCHIVE", "LC_ALL"]
set_env = { MPLBACKEND = "agg" }
extras = ["test", "astropy"]
uv_python_preference = "only-managed"
allowlist_externals = ["python"]

[tool.tox.env.clean]
description = "Clean artifacts before testing"
commands = [["coverage", "erase"]]
runner = "uv-venv-lock-runner"
extras = ["test", "astropy"]
uv_python_preference = "only-managed"
allowlist_externals = ["python"]

[tool.tox.env.build_docs]
description = "invoke sphinx-build to build the HTML docs"
change_dir = "docs"
extras = ["docs"]
commands = [["make", "html"]]
uv_python_preference = "only-managed"
allowlist_externals = ["python", "make", "uv"]
Empty file added test/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from pytest_container import add_logging_level_options, set_logging_level_from_cli_args


def pytest_addoption(parser):
add_logging_level_options(parser)


def pytest_configure(config):
set_logging_level_from_cli_args(config)
19 changes: 19 additions & 0 deletions test/container.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import random

from pytest_container.inspect import PortForwarding, NetworkProtocol
from pytest_container.container import Container, EntrypointSelection


FIREFLY_CONTAINER = Container(
url="docker.io/ipac/firefly:latest",
extra_launch_args=["--memory=4g"],
entry_point=EntrypointSelection.AUTO,
forwarded_ports=[
PortForwarding(
container_port=8080,
protocol=NetworkProtocol.TCP,
host_port=random.randint(8000, 65534),
bind_ip="127.0.0.1",
)
],
)
Loading