build: migrate to poetry (#3)

This commit is contained in:
Robert Kaussow 2021-01-01 23:39:20 +01:00 committed by GitHub
parent 28feec7766
commit 5d82f47658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1693 additions and 249 deletions

View File

@ -1,16 +1,17 @@
local PythonVersion(pyversion='2.7') = {
local PythonVersion(pyversion='3.6') = {
name: 'python' + std.strReplace(pyversion, '.', ''),
image: 'python:' + pyversion,
environment: {
PY_COLORS: 1,
},
commands: [
'pip install -r dev-requirements.txt -qq',
'pip install -qq .',
'pytest tests --cov=certbot_dns_corenetworks --no-cov-on-fail',
'pip install poetry poetry-dynamic-versioning -qq',
'poetry install -q',
'poetry run pytest',
'poetry version',
],
depends_on: [
'clone',
'fetch',
],
};
@ -24,15 +25,29 @@ local PipelineLint = {
},
steps: [
{
name: 'flake8',
image: 'python:3.8',
name: 'yapf',
image: 'python:3.9',
environment: {
PY_COLORS: 1,
},
commands: [
'pip install -r dev-requirements.txt -qq',
'pip install -qq .',
'flake8 ./certbot_dns_corenetworks',
'git fetch -tq',
'pip install poetry poetry-dynamic-versioning -qq',
'poetry install -q',
'poetry run yapf -dr ./certbot_dns_corenetworks',
],
},
{
name: 'flake8',
image: 'python:3.9',
environment: {
PY_COLORS: 1,
},
commands: [
'git fetch -tq',
'pip install poetry poetry-dynamic-versioning -qq',
'poetry install -q',
'poetry run flake8 ./certbot_dns_corenetworks',
],
},
],
@ -50,14 +65,20 @@ local PipelineTest = {
arch: 'amd64',
},
steps: [
PythonVersion(pyversion='2.7'),
PythonVersion(pyversion='3.5'),
{
name: 'fetch',
image: 'python:3.9',
commands: [
'git fetch -tq',
],
},
PythonVersion(pyversion='3.6'),
PythonVersion(pyversion='3.7'),
PythonVersion(pyversion='3.8'),
PythonVersion(pyversion='3.9'),
{
name: 'codecov',
image: 'python:3.8',
image: 'python:3.9',
environment: {
PY_COLORS: 1,
CODECOV_TOKEN: { from_secret: 'codecov_token' },
@ -67,11 +88,10 @@ local PipelineTest = {
'codecov --required -X gcov',
],
depends_on: [
'python27',
'python35',
'python36',
'python37',
'python38',
'python39',
],
},
],
@ -94,14 +114,15 @@ local PipelineSecurity = {
steps: [
{
name: 'bandit',
image: 'python:3.8',
image: 'python:3.9',
environment: {
PY_COLORS: 1,
},
commands: [
'pip install -r dev-requirements.txt -qq',
'pip install -qq .',
'bandit -r ./certbot_dns_corenetworks -x ./certbot_dns_corenetworks/test',
'git fetch -tq',
'pip install poetry poetry-dynamic-versioning -qq',
'poetry install -q',
'poetry run bandit -r ./certbot_dns_corenetworks -x ./certbot_dns_corenetworks/test',
],
},
],
@ -124,12 +145,11 @@ local PipelineBuildPackage = {
steps: [
{
name: 'build',
image: 'python:3.8',
environment: {
SETUPTOOLS_SCM_PRETEND_VERSION: '${DRONE_TAG##v}',
},
image: 'python:3.9',
commands: [
'python setup.py sdist bdist_wheel',
'git fetch -tq',
'pip install poetry poetry-dynamic-versioning -qq',
'poetry build',
],
},
{
@ -155,12 +175,15 @@ local PipelineBuildPackage = {
},
{
name: 'publish-pypi',
image: 'plugins/pypi',
settings: {
username: { from_secret: 'pypi_username' },
password: { from_secret: 'pypi_password' },
repository: 'https://upload.pypi.org/legacy/',
skip_build: true,
image: 'python:3.9',
commands: [
'git fetch -tq',
'pip install poetry poetry-dynamic-versioning -qq',
'poetry publish -n',
],
environment: {
POETRY_HTTP_BASIC_PYPI_USERNAME: { from_secret: 'pypi_username' },
POETRY_HTTP_BASIC_PYPI_PASSWORD: { from_secret: 'pypi_password' },
},
when: {
ref: ['refs/tags/**'],

View File

@ -7,12 +7,23 @@ platform:
arch: amd64
steps:
- name: flake8
image: python:3.8
- name: yapf
image: python:3.9
commands:
- pip install -r dev-requirements.txt -qq
- pip install -qq .
- flake8 ./certbot_dns_corenetworks
- git fetch -tq
- pip install poetry poetry-dynamic-versioning -qq
- poetry install -q
- poetry run yapf -dr ./certbot_dns_corenetworks
environment:
PY_COLORS: 1
- name: flake8
image: python:3.9
commands:
- git fetch -tq
- pip install poetry poetry-dynamic-versioning -qq
- poetry install -q
- poetry run flake8 ./certbot_dns_corenetworks
environment:
PY_COLORS: 1
@ -34,63 +45,61 @@ platform:
arch: amd64
steps:
- name: python27
image: python:2.7
- name: fetch
image: python:3.9
commands:
- pip install -r dev-requirements.txt -qq
- pip install -qq .
- pytest tests --cov=certbot_dns_corenetworks --no-cov-on-fail
environment:
PY_COLORS: 1
depends_on:
- clone
- name: python35
image: python:3.5
commands:
- pip install -r dev-requirements.txt -qq
- pip install -qq .
- pytest tests --cov=certbot_dns_corenetworks --no-cov-on-fail
environment:
PY_COLORS: 1
depends_on:
- clone
- git fetch -tq
- name: python36
image: python:3.6
commands:
- pip install -r dev-requirements.txt -qq
- pip install -qq .
- pytest tests --cov=certbot_dns_corenetworks --no-cov-on-fail
- pip install poetry poetry-dynamic-versioning -qq
- poetry install -q
- poetry run pytest
- poetry version
environment:
PY_COLORS: 1
depends_on:
- clone
- fetch
- name: python37
image: python:3.7
commands:
- pip install -r dev-requirements.txt -qq
- pip install -qq .
- pytest tests --cov=certbot_dns_corenetworks --no-cov-on-fail
- pip install poetry poetry-dynamic-versioning -qq
- poetry install -q
- poetry run pytest
- poetry version
environment:
PY_COLORS: 1
depends_on:
- clone
- fetch
- name: python38
image: python:3.8
commands:
- pip install -r dev-requirements.txt -qq
- pip install -qq .
- pytest tests --cov=certbot_dns_corenetworks --no-cov-on-fail
- pip install poetry poetry-dynamic-versioning -qq
- poetry install -q
- poetry run pytest
- poetry version
environment:
PY_COLORS: 1
depends_on:
- clone
- fetch
- name: python39
image: python:3.9
commands:
- pip install poetry poetry-dynamic-versioning -qq
- poetry install -q
- poetry run pytest
- poetry version
environment:
PY_COLORS: 1
depends_on:
- fetch
- name: codecov
image: python:3.8
image: python:3.9
commands:
- pip install codecov -qq
- codecov --required -X gcov
@ -99,11 +108,10 @@ steps:
from_secret: codecov_token
PY_COLORS: 1
depends_on:
- python27
- python35
- python36
- python37
- python38
- python39
image_pull_secrets:
- docker_config
@ -127,11 +135,12 @@ platform:
steps:
- name: bandit
image: python:3.8
image: python:3.9
commands:
- pip install -r dev-requirements.txt -qq
- pip install -qq .
- bandit -r ./certbot_dns_corenetworks -x ./certbot_dns_corenetworks/test
- git fetch -tq
- pip install poetry poetry-dynamic-versioning -qq
- poetry install -q
- poetry run bandit -r ./certbot_dns_corenetworks -x ./certbot_dns_corenetworks/test
environment:
PY_COLORS: 1
@ -157,11 +166,11 @@ platform:
steps:
- name: build
image: python:3.8
image: python:3.9
commands:
- python setup.py sdist bdist_wheel
environment:
SETUPTOOLS_SCM_PRETEND_VERSION: ${DRONE_TAG##v}
- git fetch -tq
- pip install poetry poetry-dynamic-versioning -qq
- poetry build
- name: checksum
image: alpine
@ -184,13 +193,15 @@ steps:
- refs/tags/**
- name: publish-pypi
image: plugins/pypi
settings:
password:
image: python:3.9
commands:
- git fetch -tq
- pip install poetry poetry-dynamic-versioning -qq
- poetry publish -n
environment:
POETRY_HTTP_BASIC_PYPI_PASSWORD:
from_secret: pypi_password
repository: https://upload.pypi.org/legacy/
skip_build: true
username:
POETRY_HTTP_BASIC_PYPI_USERNAME:
from_secret: pypi_username
when:
ref:
@ -250,6 +261,6 @@ depends_on:
---
kind: signature
hmac: d107c344afb445a597ceee39eeb6ec40de5e7975391e23acd7c2b16d6c006025
hmac: 6ea9eef02934efbc69c11c53dabe8d0019ebc74e1a0f61348379ea2c30132438
...

19
.flake8
View File

@ -1,18 +1,3 @@
[flake8]
ignore = D103, D107, W503
max-line-length = 99
inline-quotes = double
exclude =
.git
.tox
__pycache__
build
dist
test*
*.pyc
*.egg-info
.cache
.eggs
env*
application-import-names = corenetworks
format = ${cyan}%(path)s:%(row)d:%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
# Requires `flake8-colors`. This is the formatting suggested by the package (and used in flake8 repository itself).
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s

View File

@ -20,11 +20,11 @@ pip install certbot-dns-corenetworks
To start using DNS authentication for the Core Networks DNS API, pass the following arguments on certbot's command line:
| Option | Description |
|----------------------------------------------------------------------|--------------------------------------------------|
| `--authenticator certbot-dns-corenetworks:dns-corenetworks` | select the authenticator plugin (Required) |
| `--certbot-dns-corenetworks:dns-corenetworks-credentials` | Hetzner DNS API credentials INI file. (Required) |
| `--certbot-dns-corenetworks:dns-corenetworks-propagation-seconds` | Seconds to wait for the TXT record to propagate |
| Option | Description |
| ----------------------------------------------------------------- | ------------------------------------------------ |
| `--authenticator certbot-dns-corenetworks:dns-corenetworks` | select the authenticator plugin (Required) |
| `--certbot-dns-corenetworks:dns-corenetworks-credentials` | Hetzner DNS API credentials INI file. (Required) |
| `--certbot-dns-corenetworks:dns-corenetworks-propagation-seconds` | Seconds to wait for the TXT record to propagate |
## Credentials
@ -38,18 +38,18 @@ certbot_dns_corenetworks:dns_corenetworks_password = secure_passwor
To acquire a certificate for `example.com`
```bash
certbot certonly \\
--authenticator certbot-dns-corenetworks:dns-corenetworks \\
--certbot-dns-corenetworks:dns-corenetworks-credentials /path/to/my/credentials.ini \\
certbot certonly \
--authenticator certbot-dns-corenetworks:dns-corenetworks \
--certbot-dns-corenetworks:dns-corenetworks-credentials /path/to/my/credentials.ini \
-d example.com
```
To acquire a certificate for ``*.example.com``
To acquire a certificate for `*.example.com`
```bash
certbot certonly \\
--authenticator certbot-dns-corenetworks:dns-corenetworks \\
--certbot-dns-corenetworks:dns-corenetworks-credentials /path/to/my/credentials.ini \\
certbot certonly \
--authenticator certbot-dns-corenetworks:dns-corenetworks \
--certbot-dns-corenetworks:dns-corenetworks-credentials /path/to/my/credentials.ini \
-d '*.example.com'
```

View File

@ -1,10 +1,4 @@
# -*- coding: utf-8 -*-
"""Default package."""
__author__ = "Robert Kaussow"
__project__ = "certbot_dns_corenetworks"
__license__ = "MIT"
__maintainer__ = "Robert Kaussow"
__email__ = "mail@thegeeklab.de"
__url__ = "https://github.com/thegeeklab/certbot-dns-corenetworks"
__version__ = "0.1.4"
__version__ = "0.0.0"

View File

@ -2,7 +2,7 @@
import logging
import re
import zope.interface # noqa
import zope.interface
from certbot import errors
from certbot import interfaces
from certbot.plugins import dns_common
@ -33,7 +33,7 @@ class Authenticator(dns_common.DNSAuthenticator):
self.credentials = None
@classmethod
def add_parser_arguments(cls, add): # noqa
def add_parser_arguments(cls, add):
super(Authenticator, cls).add_parser_arguments(add, default_propagation_seconds=60)
add(
"credentials",
@ -41,7 +41,7 @@ class Authenticator(dns_common.DNSAuthenticator):
default="/etc/letsencrypt/corenetworks.cfg"
)
def more_info(self): # noqa
def more_info(self):
return "This plugin configures a DNS TXT record to respond to a dns-01 challenge using " \
"the Core Networks DNS API."

View File

@ -34,7 +34,6 @@ class AuthenticatorTest(test_util.TempDirTestCase, dns_test_common.BaseAuthentic
self.auth = Authenticator(self.config, "corenetworks")
self.mock_client = mock.MagicMock()
# _get_corenetworks_client | pylint: disable=protected-access
self.auth._get_corenetworks_client = mock.MagicMock(return_value=self.mock_client)
def test_perform(self):
@ -46,7 +45,6 @@ class AuthenticatorTest(test_util.TempDirTestCase, dns_test_common.BaseAuthentic
self.assertEqual(expected, self.mock_client.mock_calls)
def test_cleanup(self):
# _attempt_cleanup | pylint: disable=protected-access
self.auth.nameCache["_acme-challenge." + DOMAIN] = "_acme-challenge." + DOMAIN
self.auth._attempt_cleanup = True
self.auth.cleanup([self.achall])

View File

@ -1,20 +0,0 @@
pydocstyle
flake8
flake8-colors
flake8-blind-except
flake8-builtins
flake8-docstrings
flake8-isort
flake8-logging-format
flake8-polyfill
flake8-quotes
flake8-pep3101
flake8-eradicate; python_version >= "3.6"
pep8-naming
wheel
mock
pytest
pytest-mock
pytest-cov
bandit
yapf

1445
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

94
pyproject.toml Normal file
View File

@ -0,0 +1,94 @@
[tool.poetry]
authors = ["Robert Kaussow <mail@thegeeklab.de>"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Plugins",
"Intended Audience :: System Administrators",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Security",
"Topic :: System :: Networking",
"Topic :: Utilities",
]
description = "Core Networks DNS Authenticator plugin for Certbot."
documentation = "https://github.com/thegeeklab/certbot-dns-corenetworks/"
homepage = "https://github.com/thegeeklab/certbot-dns-corenetworks/"
include = [
"LICENSE",
]
keywords = ["dns", "certbot", "automation", "corenetworks"]
license = "MIT"
name = "certbot-dns-corenetworks"
packages = [
{include = "certbot_dns_corenetworks"},
]
readme = "README.md"
repository = "https://github.com/thegeeklab/certbot-dns-corenetworks/"
version = "0.0.0"
[tool.poetry.plugins."certbot.plugins"]
dns-corenetworks = "certbot_dns_corenetworks.dns_corenetworks:Authenticator"
[tool.poetry.dependencies]
acme = "^1.10.1"
certbot = "^1.10.1 "
corenetworks = "^0.1.4"
parsedatetime = "^2.6"
python = "^3.6.0"
"zope.interface" = "^5.2.0"
[tool.poetry.dev-dependencies]
bandit = "^1.7.0"
flake8 = "^3.8.4"
flake8-blind-except = "^0.1.1"
flake8-builtins = "^1.5.3"
flake8-colors = "^0.1.9"
flake8-docstrings = "^1.5.0"
flake8-eradicate = "^1.0.0"
flake8-isort = "^4.0.0"
flake8-logging-format = "^0.6.0"
flake8-pep3101 = "^1.3.0"
flake8-polyfill = "^1.0.2"
flake8-quotes = "^3.2.0"
mock = "^4.0.3"
pep8-naming = "^0.11.1"
pydocstyle = "^5.1.1"
pytest = "^6.2.1"
pytest-cov = "^2.10.1"
pytest-mock = "^3.4.0"
yapf = "^0.30.0"
[tool.poetry-dynamic-versioning]
enable = true
style = "semver"
vcs = "git"
[tool.isort]
default_section = "THIRDPARTY"
force_single_line = true
line_length = 99
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
skip_glob = ["**/.env*", "**/env/*", "**/docs/*"]
[tool.pytest.ini_options]
addopts = "certbot_dns_corenetworks --cov=certbot_dns_corenetworks --cov-report=xml:coverage.xml --cov-report=term --cov-append --no-cov-on-fail"
filterwarnings = [
"ignore::FutureWarning",
"ignore:.*collections.*:DeprecationWarning",
"ignore:.*pep8.*:FutureWarning",
]
[tool.coverage.run]
omit = ["**/test/*"]
[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]

View File

@ -1,17 +1,20 @@
[metadata]
description-file = README.md
license_file = LICENSE
[bdist_wheel]
universal = 1
[isort]
default_section = THIRDPARTY
known_first_party = certbot_dns_corenetworks
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
force_single_line = true
line_length = 99
skip_glob = **/.env*,**/env/*,**/docs/*
[flake8]
# Explanation of errors
#
# D102: Missing docstring in public method
# D103: Missing docstring in public function
# D107: Missing docstring in __init__
# D202: No blank lines allowed after function docstring
# W503:Line break occurred before a binary operator
ignore = D102, D103, D107, D202, W503
max-line-length = 99
inline-quotes = double
exclude = .git, __pycache__, build, dist, test, *.pyc, *.egg-info, .cache, .eggs, env*
# NOTE: The format for flake8 output is set in the `.flake8` file. This is separate
# because `setup.cfg` is parsed on setup, but it would require flake8-colors
# to run successfully (which will only be available after install). So we define
# it in `.flake8`, and it seems to successfully combine the settings in the
# two files together.
[yapf]
based_on_style = google
@ -19,12 +22,3 @@ column_limit = 99
dedent_closing_brackets = true
coalesce_brackets = true
split_before_logical_operator = true
[tool:pytest]
filterwarnings =
ignore::FutureWarning
ignore:.*collections.*:DeprecationWarning
ignore:.*pep8.*:FutureWarning
[coverage:run]
omit = **/test/*

View File

@ -1,80 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Setup script for the package."""
import io
import os
import re
from setuptools import find_packages
from setuptools import setup
PACKAGE_NAME = "certbot_dns_corenetworks"
def get_property(prop, project):
current_dir = os.path.dirname(os.path.realpath(__file__))
result = re.search(
r'{}\s*=\s*[\'"]([^\'"]*)[\'"]'.format(prop),
open(os.path.join(current_dir, project, "__init__.py")).read(),
)
return result.group(1)
def get_readme(filename="README.md"):
this = os.path.abspath(os.path.dirname(__file__))
with io.open(os.path.join(this, filename), encoding="utf-8") as f:
long_description = f.read()
return long_description
setup(
name=get_property("__project__", PACKAGE_NAME),
description="Core Networks DNS Authenticator plugin for Certbot",
keywords="dns, certbot, automation, corenetworks",
version=get_property("__version__", PACKAGE_NAME),
author=get_property("__author__", PACKAGE_NAME),
author_email=get_property("__email__", PACKAGE_NAME),
url=get_property("__url__", PACKAGE_NAME),
license=get_property("__license__", PACKAGE_NAME),
long_description=get_readme(),
long_description_content_type="text/markdown",
packages=find_packages(exclude=["*.test", "test", "test.*"]),
include_package_data=True,
zip_safe=False,
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,<4",
entry_points={
"certbot.plugins": [
"dns-corenetworks = certbot_dns_corenetworks.dns_corenetworks:Authenticator"
],
},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Plugins",
"Intended Audience :: System Administrators",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: POSIX",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Security",
"Topic :: System :: Networking",
"Topic :: Utilities",
],
# FIXME: https://github.com/bear/parsedatetime/pull/247
install_requires=[
"acme",
'parsedatetime<2.6; python_version < "3"',
"certbot>=0.15",
"setuptools",
"zope.interface",
"corenetworks>=0.1.4",
],
dependency_links=[],
)