Skip to content

Commit

Permalink
migrate from setup.py to pyproject.toml and build (#18)
Browse files Browse the repository at this point in the history
* migrate from setup.py to pyproject.toml and build

* use strings for version numbers

* use importlibs backport for python 3.7
  • Loading branch information
tsamaras authored Nov 10, 2023
1 parent 6ab3d72 commit 2717751
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 59 deletions.
5 changes: 3 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[flake8]
count = True
ignore = F401,C901,F811,E203,W503,E501
exclude = .git,.github,examples,__pycache__,docs,venv,env,.venv,build,examples
max-complexity = 10
max-line-length = 120
max-line-length = 127
builtins = unicode
tee = True
tee = True
12 changes: 4 additions & 8 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand All @@ -26,19 +26,15 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install wheel
pip install codecov
pip install -r requirements.txt
pip install -r requirements-test.txt
pip install -r requirements.txt -r requirements-test.txt
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 . --exit-zero --statistics
- name: Test with pytest
run: |
pip install pytest
pip install pytest-cov
pytest --ignore=docs_src/ --cov=./
codecov --token=${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[build-system]
requires = ["setuptools>=64", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "pyterraformer"
dynamic = ["version"]
authors = [{ name = "", email = "pyterraformer@gmail.com" }]
description = "Enjoyable terraform manipulation from python."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]

[tool.setuptools.packages.find]
exclude = [
"dist",
"build",
"*.tests",
"*.tests.*",
"tests.*",
"tests",
"docs",
".github",
"",
"examples",
]

[tool.sestuptools.package-data]
"*" = ["*.tf", "*.jinja", "py.typed"]

[tool.setuptools_scm]

#TODO: convert scripts into actual entrypoint scripts
11 changes: 10 additions & 1 deletion pyterraformer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
try:
from importlib.metadata import PackageNotFoundError, version
except ImportError:
from importlib_metadata import PackageNotFoundError, version # type: ignore

from .config import Config
from .core.workspace import TerraformWorkspace
from .serializer import HumanSerializer
from .terraform.backends import LocalBackend
from .terraform.terraform import Terraform

__version__ = "0.0.1-rc.3"
try:
__version__ = version("pyterraformer")
except PackageNotFoundError:
# package is not installed
pass

__all__ = [
"HumanSerializer",
Expand Down
5 changes: 4 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pytest
codecov
pytest
pytest-cov
flake8
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
jinja2
lark
click
click
importlib_metadata; python_version < '3.8'
44 changes: 0 additions & 44 deletions setup.py

This file was deleted.

0 comments on commit 2717751

Please sign in to comment.