Skip to content

Commit

Permalink
moving to pyproject.toml (#23)
Browse files Browse the repository at this point in the history
* moving to pyproject.toml

* fixing test job

* fixing tests

* fix local_scheme

* fetch-depth for tags
  • Loading branch information
pmaher86 authored Sep 24, 2023
1 parent 5b822fc commit 0470d95
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 137 deletions.
124 changes: 99 additions & 25 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,111 @@
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
on: [push]
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on: push

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
- uses: actions/checkout@v4
with:
python-version: 3.9
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install pypa/build
run: >-
python -m
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
# - name: Publish distribution 📦 to Test PyPI
# if: ${{ !startsWith(github.ref, 'refs/tags') }}
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.TEST_PYPI_KEY }}
# repository_url: https://test.pypi.org/legacy/
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/blacksquare # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/blacksquare

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_KEY }}
repository-url: https://test.pypi.org/legacy/
25 changes: 14 additions & 11 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install .
pip install --upgrade pip
pip install -r requirements.txt
- name: Install wkhtmltopdf
run: |
sudo apt-get -y update
sudo apt-get -y install wkhtmltopdf
run: sudo apt-get -y install wkhtmltopdf

- name: Install package
run: pip install .[dev]

- name: Test with pytest
run: |
pytest -vv
run: pytest -vv
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.vscode/
venv/
.venv/
**/__pycache__
dist/
build/
blacksquare.egg-info/
.python-version
.ipynb_checkpoints/
Expand Down
46 changes: 43 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
"setuptools>=42", "wheel", "setuptools-scm"
]
build-backend = "setuptools.build_meta"

[project]
name = "blacksquare"
description = "A package for creating crossword puzzles"
authors = [
{ name = "Patrick Maher", email = "[email protected]" }
]
readme = "README.md"
dependencies = [
"networkx",
"numpy",
"pandas",
"pdfkit",
"puzpy",
"pypdf",
"rich",
]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
requires-python = ">=3.9"
dynamic = ["version"]

[project.urls]
Source = "https://github.com/pmaher86/blacksquare"

[project.optional-dependencies]
dev = [
"pip-tools",
"pytest",
]

[tool.setuptools_scm]
local_scheme = "no-local-version"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
blacksquare = ["*.dict"]
94 changes: 40 additions & 54 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,80 +1,66 @@
#
# This file is autogenerated by pip-compile with python 3.8
# To update, run:
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --extra=test
# pip-compile --extra=dev pyproject.toml
#
attrs==22.1.0
# via pytest
black==22.10.0
# via blacksquare (setup.py)
build==0.8.0
build==1.0.3
# via pip-tools
click==8.1.3
# via
# black
# pip-tools
commonmark==0.9.1
# via rich
iniconfig==1.1.1
click==8.1.7
# via pip-tools
exceptiongroup==1.1.3
# via pytest
iniconfig==2.0.0
# via pytest
mypy-extensions==0.4.3
# via black
networkx==2.8.7
# via blacksquare (setup.py)
numpy==1.23.4
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
networkx==3.1
# via blacksquare (pyproject.toml)
numpy==1.26.0
# via
# blacksquare (setup.py)
# blacksquare (pyproject.toml)
# pandas
packaging==21.3
packaging==23.1
# via
# build
# pytest
pandas==1.5.1
# via blacksquare (setup.py)
pathspec==0.10.1
# via black
pandas==2.1.1
# via blacksquare (pyproject.toml)
pdfkit==1.0.0
# via blacksquare (setup.py)
pep517==0.13.0
# via build
pip-tools==6.9.0
# via blacksquare (setup.py)
platformdirs==2.5.2
# via black
pluggy==1.0.0
# via blacksquare (pyproject.toml)
pip-tools==7.3.0
# via blacksquare (pyproject.toml)
pluggy==1.3.0
# via pytest
puzpy==0.2.5
# via blacksquare (setup.py)
py==1.11.0
# via pytest
pygments==2.13.0
# via blacksquare (pyproject.toml)
pygments==2.16.1
# via rich
pyparsing==3.0.9
# via packaging
pypdf2==2.11.1
# via blacksquare (setup.py)
pytest==7.1.3
# via blacksquare (setup.py)
pypdf==3.16.2
# via blacksquare (pyproject.toml)
pyproject-hooks==1.0.0
# via build
pytest==7.4.2
# via blacksquare (pyproject.toml)
python-dateutil==2.8.2
# via pandas
pytz==2022.5
pytz==2023.3.post1
# via pandas
rich==12.6.0
# via blacksquare (setup.py)
rich==13.5.3
# via blacksquare (pyproject.toml)
six==1.16.0
# via python-dateutil
tomli==2.0.1
# via
# black
# build
# pip-tools
# pyproject-hooks
# pytest
typing-extensions==4.4.0
# via
# black
# pypdf2
# rich
wheel==0.37.1
tzdata==2023.3
# via pandas
wheel==0.41.2
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
Expand Down
35 changes: 0 additions & 35 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 0470d95

Please sign in to comment.