Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Move to poetry and automated relases via Github UI
Browse files Browse the repository at this point in the history
  • Loading branch information
samj1912 committed Jan 2, 2023
1 parent f1dc7be commit f0976d2
Show file tree
Hide file tree
Showing 13 changed files with 211 additions and 115 deletions.
18 changes: 0 additions & 18 deletions .bumpversion.cfg

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Test PyPI publish

on:
release:
types: [prereleased]

jobs:
build:
runs-on: ubuntu-latest
environment: pypi-dev
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.7"
cache: "poetry"

- name: Install dependencies
run: |
poetry env use "3.7"
poetry install
- name: Bump version number
run: poetry version ${{ github.event.release.tag_name }}

- name: Build package
run: poetry build

- name: Publish package
run: poetry publish -r testpypi -u __token__ -p ${{ secrets.TEST_PYPI_PASSWORD }}
62 changes: 28 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,37 @@
name: Release
---
name: PyPI publish

on:
release:
types:
- published

env:
DEFAULT_PYTHON: "3.11"

permissions:
contents: read
types: [released]

jobs:
release-pypi:
name: Upload release to PyPI
build:
runs-on: ubuntu-latest
environment:
name: pypi-prod
url: https://pypi.org/project/pydocstyle/
environment: pypi-prod
steps:
- name: Check out code from Github
uses: actions/checkout@v3.2.0
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v4.4.0
- name: Checkout code
uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Install requirements
run: |
python -m pip install twine build
- name: Build distributions
run: |
python -m build
- name: Upload to PyPI
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
env:
TWINE_REPOSITORY: pypi
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
python-version: "3.7"
cache: "poetry"

- name: Install dependencies
run: |
twine upload --verbose dist/*
poetry env use "3.7"
poetry install
- name: Bump version number
run: poetry version ${{ github.event.release.tag_name }}

- name: Build package
run: poetry build

- name: Publish package
run: poetry publish -u __token__ -p ${{ secrets.PYPI_PASSWORD }}
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: Run tests

on: [push, pull_request]

on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test-latest:
runs-on: ${{ matrix.os }}
Expand Down
82 changes: 82 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
[tool.poetry]
name = "pydocstyle"
version = "0.0.0-dev"
description = "Python docstring style checker"
authors = ["Amir Rachum <amir@rachum.com>", "Sambhav Kothari <sambhavs.email@gmail.com"]
license = "MIT"
readme = "README.rst"
documentation = "https://www.pydocstyle.org/en/stable/"
homepage = "https://www.pydocstyle.org/en/stable/"
repository = "https://github.com/PyCQA/pydocstyle"
classifiers = [
"Intended Audience :: Developers",
"Environment :: Console",
"Development Status :: 5 - Production/Stable",
"Operating System :: OS Independent"
]

[tool.poetry.urls]
"Release Notes" = "https://www.pydocstyle.org/en/stable/release_notes.html"

[tool.poetry.dependencies]
python = ">=3.6"
snowballstemmer = ">=2.2.0"
toml = {version = ">=0.10.2", optional = true}
importlib-metadata = {version = ">=2.0.0,<5.0.0", python = "<3.8"}

[tool.poetry.extras]
toml = ["toml"]

[tool.poetry.scripts]
pydocstyle = "pydocstyle.cli:main"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 79
target-version = ['py36']
Expand Down
5 changes: 3 additions & 2 deletions requirements/runtime.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
snowballstemmer==1.2.1
toml==0.10.2
snowballstemmer>=1.2.1
toml>=0.10.2
importlib-metadata<5.0.0,>=2.0.0; python_version < "3.8"
53 changes: 0 additions & 53 deletions setup.py

This file was deleted.

3 changes: 2 additions & 1 deletion src/pydocstyle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ._version import __version__

# Temporary hotfix for flake8-docstrings
from .checker import ConventionChecker, check
from .parser import AllError
from .utils import __version__
from .violations import Error, conventions
13 changes: 13 additions & 0 deletions src/pydocstyle/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sys

if sys.version_info[:2] >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata # pragma: no cover

# Used to automatically set version number from github actions
# as well as not break when being tested locally
try:
__version__ = metadata.version(__package__)
except metadata.PackageNotFoundError: # pragma: no cover
__version__ = "0.0.0"
3 changes: 2 additions & 1 deletion src/pydocstyle/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from functools import reduce
from re import compile as re

from .utils import __version__, log
from ._version import __version__
from .utils import log
from .violations import ErrorRegistry, conventions

try:
Expand Down
2 changes: 0 additions & 2 deletions src/pydocstyle/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""General shared utilities."""
import ast
import logging
import re
from itertools import tee, zip_longest
from typing import Any, Iterable, Tuple

# Do not update the version manually - it is managed by `bumpversion`.
__version__ = '6.1.2rc'
log = logging.getLogger(__name__)

#: Regular expression for stripping non-alphanumeric characters
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ deps =
[testenv:install]
skip_install = True
commands =
python setup.py bdist_wheel
pip wheel . -w dist --no-deps
pip install --no-index --find-links=dist pydocstyle
pydocstyle --help

Expand Down Expand Up @@ -64,4 +64,3 @@ commands = {[testenv:install]commands}
[testenv:py310-install]
skip_install = {[testenv:install]skip_install}
commands = {[testenv:install]commands}

0 comments on commit f0976d2

Please sign in to comment.