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

Add pyproject.toml, requirements.txt and tox.ini #563

Closed
Closed
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
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:

- name: Lint Python files
run: |
tox -e lint
tox run -e lint

- name: Typecheck Python files
run: |
tox -e check
tox run -e check

tests:
name: Tests
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Coverage
run: |
tox -e coverage
tox run -e coverage
codecov

- name: Integration
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ If you prefer live discussions, some of us also hang out in
<https://web.libera.chat/#lxd>`_ on irc.libera.chat.

LXD Documentation: `https://documentation.ubuntu.com/lxd/en/latest/
https://documentation.ubuntu.com/lxd/en/latest/`_
<https://documentation.ubuntu.com/lxd/en/latest/>`_

PyLXD API Documentation: `https://pylxd.readthedocs.io/en/latest/
<https://pylxd.readthedocs.io/en/latest/>`_
Expand Down
12 changes: 6 additions & 6 deletions doc/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ Code standards

pyLXD formats code with Black and isort. Verify the formatting with::

tox -e lint
tox run -e lint

If it fails, you can reformat the code with::

tox -e format
tox run -e format

Testing
-------

Testing pyLXD is in 3 parts:

1. Conformance with Black and isort, using the ``tox -e lint`` command.
2. Unit tests using ``tox -e py`` or ``tox -e coverage``.
3. Integration tests using the ``tox -e integration-in-lxd``.
1. Conformance with Black and isort, using the ``tox run -e lint`` command.
2. Unit tests using ``tox run -e py`` or ``tox run -e coverage``.
3. Integration tests using the ``tox run -e integration-in-lxd``.

.. note:: all of the tests can be run by just using the ``tox`` command on it's
own, with the exception of the integration tests. These are not
Expand All @@ -103,7 +103,7 @@ Integration Testing
^^^^^^^^^^^^^^^^^^^

Integration testing requires a running LXD system. They can be tested locally
in LXD container with nesting support; ``tox -e integration-in-lxd``.
in LXD container with nesting support; ``tox run -e integration-in-lxd``.

.. _Github: https://github.com/canonical/pylxd
.. _Tox: https://tox.wiki/en/latest/
Expand Down
2 changes: 1 addition & 1 deletion integration/run-integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ OLD_TRUST_LIST="$(mktemp)"
save_trust_list > "${OLD_TRUST_LIST}"

# finally run the integration tests
tox -e integration
tox run -e integration

# Remove any cert added to the trusted list by the integration tests
NEW_TRUST_LIST="$(mktemp)"
Expand Down
2 changes: 1 addition & 1 deletion migration/run_migration_integration_tests-18-04
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ lxc exec "$CONTAINER_ONE_NAME" -- mkdir -p /opt/pylxd
# NOTE: rockstar (13 Sep 2016) - --recursive is not supported in lxd <2.1, so
# until we have pervasive support for that, we'll do this tar hack.
tar cf - ./* .git | lxc exec "$CONTAINER_ONE_NAME" -- tar xf - -C /opt/pylxd
lxc exec "$CONTAINER_ONE_NAME" -- /bin/sh -c "cd /opt/pylxd && tox -emigration"
lxc exec "$CONTAINER_ONE_NAME" -- /bin/sh -c "cd /opt/pylxd && tox run -e migration"

lxc delete --force "$CONTAINER_ONE_NAME"
lxc delete --force "$CONTAINER_TWO_NAME"
Expand Down
2 changes: 1 addition & 1 deletion pylxd/models/storage_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def get(cls, storage_pool, _type, name):
volume = cls(
storage_pool.client,
storage_pool=storage_pool,
**response.json()["metadata"]
**response.json()["metadata"],
)
return volume

Expand Down
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[project]
name = "pylxd"
version = "2.3.2a"
description = "python library for LXD"
readme = "README.rst"
authors = [
{name = "Paul Hummer and others (see CONTRIBUTORS.rst"},
{email = "[email protected]"},
]
classifiers = [
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
]
license = {file = "LICENSE"}
requires-python = ">=3.8"
dependencies = [
"cryptography >= 3.2",
"python-dateutil >= 2.4.2",
"requests >= 2.20.0",
"requests-toolbelt >= 0.8.0",
"requests-unixsocket >= 0.1.5",
"urllib3 < 2",
"ws4py != 0.3.5, >= 0.3.4", # 0.3.5 is broken for websocket support
]

[project.urls]
Homepage = "https://ubuntu.com/lxd"
Documentation = "https://pylxd.readthedocs.io/en/latest/"
Repository = "https://github.com/canonical/pylxd"

[build-system]
requires = ["setuptools"]

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

[tool.mypy]
ignore_missing_imports = true
install_types = true
non_interactive = true
warn_return_any = true
warn_unused_configs = true
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cryptography >= 3.2
python-dateutil >= 2.4.2
requests >= 2.20.0
requests-toolbelt >= 0.8.0
requests-unixsocket >= 0.1.5
urllib3 < 2
ws4py != 0.3.5, >= 0.3.4 # 0.3.5 is broken for websocket support
130 changes: 0 additions & 130 deletions setup.cfg

This file was deleted.

16 changes: 0 additions & 16 deletions setup.py

This file was deleted.

77 changes: 77 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = lint,check,coverage

[vars]
src_path = {toxinidir}/pylxd/

# Define dependency groups
# https://tox.wiki/en/latest/config.html#substitution-for-values-from-other-sections
[testing]
deps =
-rrequirements.txt
ddt >= 0.7.0
mock-services >= 0.3
pytest-cov >= 2.10.1
pytest >= 6.1.2
# mock-services is old and unmaintained. Doesn't work with newer versions
# of requests-mock. Thus, we have to pin it down.
requests-mock < 1.2
# Python 3.12 no longer installs `setuptools` in venv
# but mock-services depends on it for `pkg_resources`
setuptools

[format]
deps =
black == 23.1.0
flake8 >= 2.5.0
isort == 5.6.4

[testenv]
basepython = python3
setenv =
PYLXD_WARNINGS=none
PYTHONPATH = {[vars]src_path}
PY_COLORS=1
package = editable
deps = {[testing]deps}
commands = pytest {posargs:pylxd}

[testenv:integration]
deps = {[testing]deps}
commands = pytest integration {posargs}

[testenv:integration-in-lxd]
deps = {[testing]deps}
commands = {toxinidir}/integration/run-integration-tests-in-lxd

[testenv:migration]
deps = {[testing]deps}
commands = pytest migration {posargs}

[testenv:format]
deps = {[format]deps}
commands =
isort --profile black {toxinidir}
black {toxinidir}

[testenv:lint]
deps = {[format]deps}
commands =
black --check {toxinidir}
isort --profile black --check-only --diff {toxinidir}
flake8 {toxinidir}

[testenv:check]
deps = mypy
commands = mypy -p pylxd {posargs}

[testenv:coverage]
deps = {[testing]deps}
commands = pytest --cov=pylxd pylxd {posargs}

[flake8]
show-source = True
ignore = E203, E266, E501, W503, W504
exclude = .git, .tox, dist, doc, *egg, build
Loading