Skip to content

Commit

Permalink
Migrate to poetry.
Browse files Browse the repository at this point in the history
  • Loading branch information
dajiaji committed Dec 11, 2021
1 parent 9d9b488 commit 881eac9
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 166 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.6", "3.7", "3.8", "3.9"]

steps:
- uses: actions/checkout@v2
Expand All @@ -29,8 +29,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade coverage[toml] virtualenv tox tox-gh-actions
python -m pip install --upgrade coverage[toml] virtualenv tox tox-gh-actions poetry
- name: Run tox targets for ${{ matrix.python-version }}
run: python -m tox
Expand Down Expand Up @@ -63,11 +62,12 @@ jobs:
with:
python-version: "3.8"

- name: Install pep517 and twine
run: python -m pip install pep517 twine
- name: Install poetry
run: python -m pip install poetry twine

- name: Build package
run: python -m pep517.build --source --binary .
run: |
python -m poetry build
- name: List result
run: ls -l dist
Expand All @@ -90,7 +90,7 @@ jobs:
python-version: "3.8"

- name: Install in dev mode
run: python -m pip install -e .[dev]
run: python -m pip install .

- name: Import package
run: python -c 'import cwt; print(cwt.__version__)'
13 changes: 7 additions & 6 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout sources
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install poetry
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
POETRY_USERNAME: ${{ secrets.PYPI_USERNAME }}
POETRY_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
poetry build
poetry publish -u $POETRY_USERNAME -p $POETRY_PASSWORD
22 changes: 9 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
repos:
- repo: https://github.com/psf/black
rev: 21.10b0
rev: 21.12b0
hooks:
- id: black
args: ["--target-version=py36"]
args: [--line-length, "128"]

- repo: https://github.com/asottile/blacken-docs
rev: v1.11.0
rev: v1.12.0
hooks:
- id: blacken-docs
args: ["--target-version=py36"]

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
language_version: python3.8
args: [--ignore, "E203,E501,B006,W503"]
additional_dependencies: [flake8-bugbear]

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: [--profile, "black"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements

- repo: https://github.com/mgedmin/check-manifest
rev: "0.47"
hooks:
- id: check-manifest
args: [--no-build-isolation]
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: trailing-whitespace
9 changes: 8 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
version: 2

python:
setup_py_install: true
version: "3.8"
install:
- method: pip
path: .
extra_requirements:
- docs
12 changes: 0 additions & 12 deletions MANIFEST.in

This file was deleted.

55 changes: 49 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "cwt"
version = "1.4.2"
description = "A Python implementation of CWT/COSE."
authors = ["Ajitomi Daisuke <[email protected]>"]
readme = "README.md"
repository = "https://github.com/dajiaji/cwt"

include = [
".pre-commit-config.yaml",
"CHANGES.rst",
"CODE_OF_CONDUCT.md",
"LICENSE",
"tox.ini",
"cwt/py.typed",
]

[tool.poetry.dependencies]
python = "^3.6.1"
asn1crypto = "^1.4.0"
cbor2 = "^5.4.2"
certvalidator = "^0.11.1"
cryptography = "^36.0.0"
Sphinx = {version = "^4.3.1", extras = ["docs"]}
sphinx-autodoc-typehints = {version = "^1.12.0", extras = ["docs"]}
sphinx-rtd-theme = {version = "^1.0.0", extras = ["docs"]}

[tool.poetry.extras]
docs = [
"Sphinx",
"sphinx-rtd-theme",
"sphinx-autodoc-typehints",
]

[tool.poetry.dev-dependencies]
pytest = "^5.2"
pytest-cov = "^3.0.0"
coverage = {extras = ["toml"], version = "^6.2"}
tox = "^3.24.4"
pre-commit = "^2.15.0"
mypy = "^0.910"
Sphinx = "^4.3.1"

[tool.coverage.run]
parallel = true
Expand All @@ -13,8 +56,8 @@ source = ["cwt", ".tox/*/site-packages"]
[tool.coverage.report]
show_missing = true

[tool.flake8]
ignore = "E203,E501,"

[tool.isort]
profile = "black"
atomic = true
combine_as_imports = true
[tool.mypy]
ignore_missing_imports = true
69 changes: 0 additions & 69 deletions setup.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

87 changes: 38 additions & 49 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,76 +1,65 @@
[pytest]
addopts = -ra
testpaths = tests
filterwarnings =
once::Warning
ignore:::pympler[.*]
[tox]
envlist =
lint
typing
py{36,37,38,39,310}
docs
pypi
coverage
isolated_build = True


[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38, docs, typing
3.8: py38, lint, typing, docs, pypi
3.9: py39
3.10: py310


[tox]
envlist =
lint
typing
py{36,37,38,39,310}
docs
pypi-description
coverage-report
isolated_build = True


[testenv]
# Prevent random setuptools/pip breakages like
# https://github.com/pypa/setuptools/issues/1042 from breaking our builds.
setenv =
VIRTUALENV_NO_DOWNLOAD=1
extras =
tests
commands = {envpython} -b -m coverage run -m pytest {posargs}
whitelist_externals = poetry
commands =
poetry install
poetry run coverage run -m pytest -ra tests


[testenv:docs]
basepython = python3.8
extras = docs
[testenv:lint]
whitelist_externals = poetry
skip_install = true
commands =
sphinx-build -n -T -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
poetry install
poetry run pre-commit run --all-files


[testenv:typing]
basepython = python3.8
extras = dev
commands = mypy cwt
whitelist_externals = poetry
skip_install = true
commands =
poetry install
poetry run mypy cwt


[testenv:lint]
basepython = python3.8
extras = dev
passenv = HOMEPATH # needed on Windows
commands = pre-commit run --all-files
[testenv:docs]
whitelist_externals = poetry
skip_install = true
commands =
poetry install -E docs
sphinx-build -n -T -W -b html -d {envtmpdir}/doctrees docs docs/_build/html


[testenv:pypi-description]
basepython = python3.8
[testenv:pypi]
whitelist_externals = poetry
skip_install = true
deps =
twine
pip >= 18.0.0
commands =
pip wheel -w {envtmpdir}/build --no-deps .
twine check {envtmpdir}/build/*
poetry build


[testenv:coverage-report]
basepython = python3.8
[testenv:coverage]
whitelist_externals = poetry
skip_install = true
deps = coverage[toml]==5.0.4
commands =
coverage combine
coverage report
poetry install
poetry run coverage combine
poetry run coverage report

0 comments on commit 881eac9

Please sign in to comment.