Skip to content

Commit 26068ae

Browse files
authored
Merge pull request #195 from tekktrik/dev/use-pyproject-toml
Update for pyproject.toml migration
2 parents acfc4fc + 445f7e3 commit 26068ae

9 files changed

+96
-126
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ _build
2121

2222
# Virtual environment-specific files
2323
.env
24+
.venv
2425

2526
# MacOS-specific files
2627
*.DS_Store

{{ cookiecutter.__dirname }}/.github/workflows/build.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ jobs:
6767
if: contains(steps.need-docs.outputs.docs, 'docs')
6868
working-directory: docs
6969
run: sphinx-build -E -W -b html . _build/html
70-
- name: Check For setup.py
70+
- name: Check For pyproject.toml
7171
id: need-pypi
7272
run: |
73-
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
73+
echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' )
7474
- name: Build Python package
75-
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
75+
if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml')
7676
run: |
77-
pip install --upgrade setuptools wheel twine readme_renderer testresources
78-
python setup.py sdist
79-
python setup.py bdist_wheel --universal
77+
pip install --upgrade build twine
78+
for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do
79+
sed -i -e "s/0.0.0+auto.0/1.2.3/" $file;
80+
done;
81+
python -m build
8082
twine check dist/*

{{ cookiecutter.__dirname }}/.github/workflows/release.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,28 @@ jobs:
6161
runs-on: ubuntu-latest
6262
steps:
6363
- uses: actions/checkout@v1
64-
- name: Check For setup.py
64+
- name: Check For pyproject.toml
6565
id: need-pypi
6666
run: |
67-
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
67+
echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' )
6868
- name: Set up Python
69-
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
69+
if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml')
7070
uses: actions/setup-python@v2
7171
with:
7272
python-version: '3.x'
7373
- name: Install dependencies
74-
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
74+
if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml')
7575
run: |
7676
python -m pip install --upgrade pip
77-
pip install setuptools wheel twine
77+
pip install --upgrade build twine
7878
- name: Build and publish
79-
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
79+
if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml')
8080
env:
8181
TWINE_USERNAME: {% raw %}${{ secrets.pypi_username }}{% endraw %}
8282
TWINE_PASSWORD: {% raw %}${{ secrets.pypi_password }}{% endraw %}
8383
run: |
84-
for file in $(find -not -path "./.*" -not -path "./docs*" -name "*.py"); do
85-
{% raw %}sed -i -e "s/0.0.0-auto.0/${{github.event.release.tag_name}}/" $file;{% endraw %}
84+
for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do
85+
{% raw %}sed -i -e "s/0.0.0+auto.0/${{github.event.release.tag_name}}/" $file;{% endraw %}
8686
done;
87-
python setup.py sdist
87+
python -m build
8888
twine upload dist/*
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2+
# SPDX-FileCopyrightText: Copyright (c) 2021 Foamyguy for Adafruit Industries
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
# This library is not deployed to PyPI. It is either a board-specific helper library, or
7+
# does not make sense for use on or is incompatible with single board computers and Linux.
8+
#

{{ cookiecutter.__dirname }}/{% if cookiecutter.pypi_release in ['n', 'no'] %}setup.py.disabled{% endif %}

Lines changed: 0 additions & 9 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# SPDX-FileCopyrightText: 2022 Alec Delaney, written for Adafruit Industries
2+
# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
3+
#
4+
# SPDX-License-Identifier: MIT
5+
6+
{# put keywords into an iterable list, based on word wrapping #}
7+
{%- set kw_list = namespace(kw_list=[], default=["adafruit", "blinka", "circuitpython", "micropython"]) -%}
8+
{%- do kw_list.default.append(cookiecutter.library_name|lower|replace(" ", "-")) -%}
9+
{%- do kw_list.default.extend(cookiecutter.library_keywords.split(" ")) -%}
10+
{%- set wrapped = kw_list.default|unique|join(" ")|wordwrap(break_long_words=False) -%}
11+
{%- do kw_list.kw_list.extend(wrapped.split("\n")) -%}
12+
{# create repo and pypi names #}
13+
{%- if cookiecutter.target_bundle != 'CircuitPython Org' -%}
14+
{%- if cookiecutter.library_prefix -%}
15+
{%- set repo_name = (cookiecutter.library_prefix | capitalize) -%}
16+
{%- set repo_name = repo_name + '_CircuitPython_' -%}
17+
{%- set repo_name = repo_name + cookiecutter.library_name | replace(" ", "_") -%}
18+
{%- else -%}
19+
{%- set repo_name = 'CircuitPython_' -%}
20+
{%- set repo_name = repo_name + cookiecutter.library_name | replace(" ", "_") -%}
21+
{%- endif -%}
22+
{%- else -%}
23+
{%- set repo_name = 'CircuitPython_Org_' + cookiecutter.library_name | replace(" ", "_") -%}
24+
{%- endif -%}
25+
{%- set pypi_name = repo_name|lower|replace("_", "-")|replace(" ", "-")|replace("circuitpython-org-", "circuitpython-") -%}
26+
[build-system]
27+
requires = [
28+
"setuptools",
29+
"wheel",
30+
"setuptools-scm",
31+
]
32+
33+
[project]
34+
name = "{{ pypi_name }}"
35+
description = "{{ cookiecutter.library_description }}"
36+
version = "0.0.0+auto.0"
37+
readme = "README.rst"
38+
authors = [
39+
{name = "Adafruit Industries", email = "[email protected]"}
40+
]
41+
urls = {Homepage = "https://github.com/{{ cookiecutter.github_user }}/{{ repo_name }}"}
42+
keywords = [
43+
{% for kw_list_keyword in kw_list.default %} "{{ kw_list_keyword }}",
44+
{% endfor -%}
45+
]
46+
license = {text = "MIT"}
47+
classifiers = [
48+
"Intended Audience :: Developers",
49+
"Topic :: Software Development :: Libraries",
50+
"Topic :: Software Development :: Embedded Systems",
51+
"Topic :: System :: Hardware",
52+
"License :: OSI Approved :: MIT License",
53+
"Programming Language :: Python :: 3",
54+
]
55+
dynamic = ["dependencies", "optional-dependencies"]
56+
57+
[tool.setuptools]
58+
# You can just specify the packages manually here if your project is
59+
# simple. Or you can use find_packages().
60+
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
61+
# CHANGE `py_modules = ['...']` TO `packages = ['...']`
62+
py-modules = ["{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | lower | replace(" ", "_") }}_{% endif %}{{ cookiecutter.library_name | lower | replace(" ", "_") }}"]
63+
64+
[tool.setuptools.dynamic]
65+
dependencies = {file = ["requirements.txt"]}
66+
optional-dependencies = {optional = {file = ["optional_requirements.txt"]}}

{{ cookiecutter.__dirname }}/{% if cookiecutter.pypi_release in ['y', 'yes'] %}setup.py{% endif %}

Lines changed: 0 additions & 101 deletions
This file was deleted.

{{ cookiecutter.__dirname }}/{{ cookiecutter.__libprefix }}{{ cookiecutter.__libname }}.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@
4949
{%- set repo_name = 'CircuitPython_Org_' + cookiecutter.library_name | replace(" ", "_") -%}
5050
{% endif -%}
5151

52-
__version__ = "0.0.0-auto.0"
52+
__version__ = "0.0.0+auto.0"
5353
__repo__ = "https://github.com/{{ cookiecutter.github_user }}/{{ repo_name }}.git"

0 commit comments

Comments
 (0)