From 35499f415db3e3f8d444b8574cafb4aaca763310 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 22 Nov 2024 15:50:52 +0900 Subject: [PATCH 1/9] chore: simpler tox.ini --- pyproject.toml | 11 ++++++++++- setup.py | 12 +++++++++++- tox.ini | 34 +++++----------------------------- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 47c22809..3ce3cd69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,8 +34,17 @@ dependencies = [ "hvac", "packaging", "typing-extensions>=4.5.0", - "backports.strenum>=1.3.1", + 'backports.strenum>=1.3.1; python_version < "3.11"', ] +[project.optional-dependencies] +dev = [ + "typing-inspect", + "pytest", + "pytest-asyncio", + "Twine", + "setuptools", # ? + "pylxd", + ] [project.urls] "Homepage" = "https://juju.is/docs/sdk" diff --git a/setup.py b/setup.py index 5b845661..655a450b 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,18 @@ "hvac", "packaging", "typing-extensions>=4.5.0", - "backports.strenum", + 'backports.strenum>=1.3.1; python_version < "3.11"', ], + extras_require={ + "dev": [ + "typing-inspect", + "pytest", + "pytest-asyncio", + "Twine", + "setuptools", # ? + "pylxd", + ] + }, include_package_data=True, maintainer="Juju Ecosystem Engineering", maintainer_email="juju@lists.ubuntu.com", diff --git a/tox.ini b/tox.ini index 43abbec2..89c8bcc3 100644 --- a/tox.ini +++ b/tox.ini @@ -9,31 +9,15 @@ envlist = py3,py38,py39,py310,py311,docs skipsdist=True [testenv] -usedevelop=True -commands = - pip install urllib3<2 - pip install pylxd - pytest --tb native -s -k 'not integration' -m 'not serial' {posargs} +use_develop = True +# This should work, but doesn't. Hence the deps= below +# extras = dev +deps = + .[dev] passenv = HOME TEST_AGENTS LXD_DIR -# FIXME would it be easier to `pip install -e .`? -deps = - macaroonbakery - toposort - typing-inspect - paramiko - ipdb - pytest - pytest-asyncio - Twine - websockets<14.0 - kubernetes<31.0.0 - hvac - packaging - setuptools - backports.strenum [testenv:docs] deps = @@ -47,8 +31,6 @@ commands = [testenv:integration] envdir = {toxworkdir}/py3 commands = - pip install urllib3<2 - pip install pylxd pytest \ --tb native \ -k 'integration' \ @@ -60,8 +42,6 @@ commands = [testenv:integration-quarantine] envdir = {toxworkdir}/py3 commands = - pip install urllib3<2 - pip install pylxd pytest \ --tb native \ -m 'not serial' \ @@ -72,8 +52,6 @@ commands = [testenv:unit] envdir = {toxworkdir}/py3 commands = - pip install urllib3<2 - pip install pylxd pytest {toxinidir}/tests/unit {posargs} [testenv:serial] @@ -82,8 +60,6 @@ commands = # it doesn't get run in CI envdir = {toxworkdir}/py3 commands = - pip install urllib3<2 - pip install pylxd pytest --tb native -s {posargs:-m 'serial'} [testenv:validate] From 3784fe8a432dfbe5e96e98dc850eea80e041ccaa Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 22 Nov 2024 16:07:40 +0900 Subject: [PATCH 2/9] chore: try building in a newer environment --- .readthedocs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index f861b63a..e4ee7e57 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -5,9 +5,9 @@ python: - requirements: docs/requirements.txt build: - os: ubuntu-22.04 + os: ubuntu-24.04 tools: - python: "3.10" + python: "3.13" sphinx: configuration: docs/conf.py From 2f078064f1304facc7385639245a90b3d1924f49 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 22 Nov 2024 16:12:06 +0900 Subject: [PATCH 3/9] chore: rely on pyproject.toml when building docs --- docs/requirements.txt | 16 ---------------- tox.ini | 5 ++++- 2 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 docs/requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 2ee6d200..00000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,16 +0,0 @@ -pytz -pymacaroons -sphinx==5.3.0 -sphinxcontrib-asyncio -sphinx_rtd_theme -websockets -typing-inspect -pyyaml -pyasn1 -pyrfc3339 -paramiko -macaroonbakery -toposort -python-dateutil -kubernetes -packaging diff --git a/tox.ini b/tox.ini index 89c8bcc3..f3e80d42 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,10 @@ passenv = [testenv:docs] deps = - -r docs/requirements.txt + .[dev] + sphinx==5.3.0 + sphinxcontrib-asyncio + sphinx_rtd_theme allowlist_externals = rm commands = From fbe1e63a6f75669b4ae5712969215cf0daee9b09 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 22 Nov 2024 17:09:54 +0900 Subject: [PATCH 4/9] chore: make pylxd optional, as it brings in ws4py from 2018 --- pyproject.toml | 1 - setup.py | 1 - tests/integration/test_model.py | 14 +++++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3ce3cd69..82fcfbe9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,6 @@ dev = [ "pytest-asyncio", "Twine", "setuptools", # ? - "pylxd", ] [project.urls] diff --git a/setup.py b/setup.py index 655a450b..d7af9560 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,6 @@ "pytest-asyncio", "Twine", "setuptools", # ? - "pylxd", ] }, include_package_data=True, diff --git a/tests/integration/test_model.py b/tests/integration/test_model.py index e843a774..e4659480 100644 --- a/tests/integration/test_model.py +++ b/tests/integration/test_model.py @@ -10,7 +10,6 @@ from unittest import mock import paramiko -import pylxd import pytest from juju import jasyncio, tag, url @@ -29,6 +28,11 @@ from ..utils import GB, INTEGRATION_TEST_DIR, MB, OVERLAYS_DIR, SSH_KEY, TESTS_DIR +@pytest.fixture +def pylxd(): + return pytest.importorskip("pylxd") + + @base.bootstrapped async def test_model_name(): model = Model() @@ -532,7 +536,7 @@ async def test_add_machine(): assert len(model.machines) == 0 -async def add_manual_machine_ssh(is_root=False): +async def add_manual_machine_ssh(pylxd, is_root=False): # Verify controller is localhost async with base.CleanController() as controller: cloud = await controller.get_cloud() @@ -677,7 +681,7 @@ def wait_for_network(container, timeout=30): @base.bootstrapped -async def test_add_manual_machine_ssh(): +async def test_add_manual_machine_ssh(pylxd): """Test manual machine provisioning with a non-root user. Tests manual machine provisioning using a randomized username with @@ -687,9 +691,9 @@ async def test_add_manual_machine_ssh(): @base.bootstrapped -async def test_add_manual_machine_ssh_root(): +async def test_add_manual_machine_ssh_root(pylxd): """Test manual machine provisioning with the root user.""" - await add_manual_machine_ssh(is_root=True) + await add_manual_machine_ssh(pylxd, is_root=True) @base.bootstrapped From 2fdcaef9096e6aa7f53199974454660d2f0d3fc7 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 22 Nov 2024 17:14:42 +0900 Subject: [PATCH 5/9] chore: dedent, drop setuptools in dev --- pyproject.toml | 11 +++++------ setup.py | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 82fcfbe9..a2721bf5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,12 +38,11 @@ dependencies = [ ] [project.optional-dependencies] dev = [ - "typing-inspect", - "pytest", - "pytest-asyncio", - "Twine", - "setuptools", # ? - ] + "typing-inspect", + "pytest", + "pytest-asyncio", + "Twine", +] [project.urls] "Homepage" = "https://juju.is/docs/sdk" diff --git a/setup.py b/setup.py index d7af9560..5ee1fe8c 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,6 @@ "pytest", "pytest-asyncio", "Twine", - "setuptools", # ? ] }, include_package_data=True, From 08b0e0b05aaa6fda02ae69edf0595e88acbb7b86 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 22 Nov 2024 17:18:01 +0900 Subject: [PATCH 6/9] chore: readthedocs by trial and error --- .readthedocs.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index e4ee7e57..103a5ea2 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -2,7 +2,15 @@ version: 2 python: install: - - requirements: docs/requirements.txt + - method: pip + path: . + extra_requirements: + - dev + - method: pip + packages: + - sphinx==5.3.0 + - sphinxcontrib-asyncio + - sphinx_rtd_theme build: os: ubuntu-24.04 From 9f45c063a4d80a1fc862df9d81e9c8ae5c99a8dd Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 22 Nov 2024 17:21:03 +0900 Subject: [PATCH 7/9] chore: readthedocs by trial and error --- .readthedocs.yaml | 6 +----- pyproject.toml | 5 +++++ tox.ini | 5 +---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 103a5ea2..f51d87e3 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -6,11 +6,7 @@ python: path: . extra_requirements: - dev - - method: pip - packages: - - sphinx==5.3.0 - - sphinxcontrib-asyncio - - sphinx_rtd_theme + - docs build: os: ubuntu-24.04 diff --git a/pyproject.toml b/pyproject.toml index a2721bf5..f3c1118e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,11 @@ dev = [ "pytest-asyncio", "Twine", ] +docs = [ + "sphinx==5.3.0", + "sphinxcontrib-asyncio", + "sphinx_rtd_theme", +] [project.urls] "Homepage" = "https://juju.is/docs/sdk" diff --git a/tox.ini b/tox.ini index f3e80d42..1e6071c0 100644 --- a/tox.ini +++ b/tox.ini @@ -21,10 +21,7 @@ passenv = [testenv:docs] deps = - .[dev] - sphinx==5.3.0 - sphinxcontrib-asyncio - sphinx_rtd_theme + .[dev,docs] allowlist_externals = rm commands = From f2c6c5098f0a056d30d9b1922e57c96e142b5533 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 22 Nov 2024 17:23:03 +0900 Subject: [PATCH 8/9] chore: readthedocs by trial and error --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index f51d87e3..d573c32b 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -11,7 +11,7 @@ python: build: os: ubuntu-24.04 tools: - python: "3.13" + python: "3.12" sphinx: configuration: docs/conf.py From 39ca34c703a1cf3f0a7407e70c6fb3acac36dc1f Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 22 Nov 2024 17:25:36 +0900 Subject: [PATCH 9/9] chore: note the sphinx issue --- .readthedocs.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index d573c32b..4da2dbd7 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -11,6 +11,8 @@ python: build: os: ubuntu-24.04 tools: + # Older Shpinx uses imghdr that was removed in Python 3.13 + # See e.g. https://github.com/python/cpython/issues/104818 python: "3.12" sphinx: