diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..f2476624 --- /dev/null +++ b/pyproject.toml @@ -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 = "lxd@lists.canonical.com"}, +] +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 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..03b9afb4 --- /dev/null +++ b/requirements.txt @@ -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 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5d0a4570..00000000 --- a/setup.cfg +++ /dev/null @@ -1,130 +0,0 @@ -[metadata] -name = pylxd -version = 2.3.2a -description = python library for LXD -long_description = file: README.rst -author = Paul Hummer and others (see CONTRIBUTORS.rst) -author_email = lxd@lists.canonical.com -home_page = https://ubuntu.com/lxd -classifier = - Intended Audience :: Information Technology - Intended Audience :: System Administrators - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Programming Language :: Python :: 3 - -[options] -python_requires = >= 3.8 -packages = find: -install_requires = - 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 - -[options.extras_require] -testing = - 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 = - black == 23.1.0 - flake8 >= 2.5.0 - isort == 5.6.4 -check = - mypy -doc = - Sphinx - -[flake8] -show-source = True -ignore = E203, E266, E501, W503, W504 -exclude = .git, .tox, dist, doc, *egg, build - -[mypy] -ignore_missing_imports = True -install_types = True -non_interactive = True -warn_return_any = True -warn_unused_configs = True - -[build_sphinx] -source-dir = doc/source -build-dir = doc/build -all_files = 1 - -[upload_sphinx] -upload-dir = doc/build/html - -[tox:tox] -minversion = 1.6 -envlist = lint,check,coverage -skipsdist = True - -[testenv] -usedevelop = True -setenv = - PYLXD_WARNINGS=none -deps = - .[testing] -commands = - pytest {posargs:pylxd} - -[testenv:integration] -commands = - pytest integration {posargs} - -[testenv:integration-in-lxd] -commands = - {toxinidir}/integration/run-integration-tests-in-lxd - -[testenv:migration] -commands = pytest migration {posargs} - -[testenv:format] -deps = - .[format] -commands= - isort --profile black {toxinidir} - black {toxinidir} - -[testenv:lint] -deps = - .[format] -commands = - black --check {toxinidir} - isort --profile black --check-only --diff {toxinidir} - flake8 {toxinidir} - -[testenv:check] -deps = - .[check] -commands = - mypy -p pylxd {posargs} - -[testenv:coverage] -deps = - .[testing] -commands = pytest --cov=pylxd pylxd {posargs} - -[testenv:i18n] -deps = - .[i18n] -commands = - {envpython} setup.py {posargs} - -[testenv:doc] -deps = - .[doc] -commands = - {envpython} setup.py build_sphinx diff --git a/setup.py b/setup.py deleted file mode 100644 index d44f073a..00000000 --- a/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from setuptools import setup - -setup() diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..651ad6cb --- /dev/null +++ b/tox.ini @@ -0,0 +1,71 @@ +[tox] +minversion = 1.6 +skipsdist = True +envlist = lint,check,coverage + +# 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] +package = editable +setenv = + PYLXD_WARNINGS=none +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