diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dedf7eb..c2c0b76 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: run: | python3 --version - name: Checkout Current Repo - uses: actions/checkout@v1 + uses: actions/checkout@v3 with: submodules: true - name: Install deps diff --git a/README.rst b/README.rst index cdfe0e4..be12f94 100644 --- a/README.rst +++ b/README.rst @@ -43,7 +43,6 @@ Prompts If the library uses Register, enter ``y`` or ``yes`` to include. If the library doesn't use Register, all other entries including empty, will not include Register. * ``other_requirements`` - Adds any other module dependencies for PyPi. Enter a comma separated string of modules (e.g. ``adafruit-circuitpython-pca9685, adafruit-circuitpython-motor``). NOTE: ``Adafruit-Blinka`` is always included, so no need to include it here. -* ``pypi_release`` - Will this library be releaased on PyPI? If so, enter ``y`` or ``yes`` to include the setup.py. For Adafruit libraries this defaults to Yes. * ``sphinx_docs`` - Should the Sphinx based documentation be included in your repo? If so, enter ``y`` or ``yes`` to include the setup.py. For Adafruit libraries this defaults to Yes. @@ -65,6 +64,14 @@ the information requested, make sure the ``.. todo::`` text is removed. Like thi # After Cleanup This library talks to the AM4Z-1NG sensor. Typical use is for robot friends. +.. note:: + + If you are not uploading the repository for Adafruit (i.e., the Community bundle), and you + wish to use the Release feature on GitHub to upload libraries to PyPI, you will need to + add your PyPI token to the repository secrets. Set a secret named ``PYPI_USERNAME`` to + ``__token__`` and a secret named ``PYPI_PASSWORD`` to your API token with the proper scope. + Never share your API token anyone! + Windows Users ============== diff --git a/cookiecutter.json b/cookiecutter.json index c4515bd..e01637e 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -16,7 +16,6 @@ "requires_bus_device": "", "requires_register": "", "other_requirements": "", - "pypi_release": "{%- if cookiecutter.target_bundle == 'Adafruit' or cookiecutter.target_bundle == 'CircuitPython Org' -%} yes {%- else -%} no {%- endif -%}", "sphinx_docs": "{%- if cookiecutter.target_bundle == 'Adafruit' or cookiecutter.target_bundle == 'CircuitPython Org' -%} yes {%- else -%} no {%- endif -%}", "_extensions": ["jinja2.ext.do"], "__dirname": "{% if cookiecutter.target_bundle != 'CircuitPython Org' %}{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}_CircuitPython{% else %}CircuitPython{% endif %}_{{ cookiecutter.library_name|replace(' ', '_')}}{% else %}CircuitPython_Org_{{ cookiecutter.library_name|replace(' ', '_')}}{% endif %}", diff --git a/tests/test_make_cookies.py b/tests/test_make_cookies.py index 7d7b86b..8cf0a05 100644 --- a/tests/test_make_cookies.py +++ b/tests/test_make_cookies.py @@ -108,14 +108,9 @@ def test_new_cookiecutter_all_entries(): overwrite_workaround() test_context = {} - for key, value in cookie_json.items(): + for key in cookie_json: if not key.startswith('_'): - if key == "target_bundle": - test_context[key] = 'Community' - elif key == "pypi_release": - test_context[key] = 'yes' - else: - test_context[key] = 'test' + test_context[key] = "Community" if key == "target_bundle" else "test" new_cookie = cookiecutter( str(working_dir.resolve()), diff --git a/{{ cookiecutter.__dirname }}/.github/workflows/build.yml b/{{ cookiecutter.__dirname }}/.github/workflows/build.yml index b341551..3d1dbef 100644 --- a/{{ cookiecutter.__dirname }}/.github/workflows/build.yml +++ b/{{ cookiecutter.__dirname }}/.github/workflows/build.yml @@ -30,11 +30,11 @@ jobs: run: | python3 --version - name: Checkout Current Repo - uses: actions/checkout@v1 + uses: actions/checkout@v3 with: submodules: true - name: Checkout tools repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: adafruit/actions-ci-circuitpython-libs path: actions-ci diff --git a/{{ cookiecutter.__dirname }}/.github/workflows/release.yml b/{{ cookiecutter.__dirname }}/.github/workflows/release.yml index 6f30b5a..18b79cb 100644 --- a/{{ cookiecutter.__dirname }}/.github/workflows/release.yml +++ b/{{ cookiecutter.__dirname }}/.github/workflows/release.yml @@ -32,11 +32,11 @@ jobs: run: | python3 --version - name: Checkout Current Repo - uses: actions/checkout@v1 + uses: actions/checkout@v3 with: submodules: true - name: Checkout tools repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: adafruit/actions-ci-circuitpython-libs path: actions-ci @@ -55,12 +55,12 @@ jobs: uses: csexton/release-asset-action@master with: pattern: "bundles/*" - github-token: {% raw %}${{ secrets.GITHUB_TOKEN }} {% endraw %} + github-token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} upload-pypi: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Check For pyproject.toml id: need-pypi run: | diff --git a/{{ cookiecutter.__dirname }}/README.rst b/{{ cookiecutter.__dirname }}/README.rst index c1fbf5d..81b2802 100644 --- a/{{ cookiecutter.__dirname }}/README.rst +++ b/{{ cookiecutter.__dirname }}/README.rst @@ -79,8 +79,6 @@ image from the assets folder in the PCB's GitHub repo. `Purchase one from the Adafruit shop `_ {% endif -%} -{%- if cookiecutter.pypi_release in ["y", "yes"] %} - Installing from PyPI ===================== .. note:: This library is not available on PyPI yet. Install documentation is included @@ -111,8 +109,6 @@ To install in a virtual environment in your current project: source .env/bin/activate pip3 install {% if cookiecutter.library_prefix -%}{{ cookiecutter.library_prefix }}-{% endif -%}circuitpython-{{ pypi_name }} -{% endif %} - Installing to a Connected CircuitPython Device with Circup ========================================================== diff --git a/{{ cookiecutter.__dirname }}/docs/{% if cookiecutter.sphinx_docs in ['y', 'yes'] %}conf.py{% endif %} b/{{ cookiecutter.__dirname }}/docs/{% if cookiecutter.sphinx_docs in ['y', 'yes'] %}conf.py{% endif %} index f4cc618..ffb14f5 100644 --- a/{{ cookiecutter.__dirname }}/docs/{% if cookiecutter.sphinx_docs in ['y', 'yes'] %}conf.py{% endif %} +++ b/{{ cookiecutter.__dirname }}/docs/{% if cookiecutter.sphinx_docs in ['y', 'yes'] %}conf.py{% endif %} @@ -53,8 +53,14 @@ master_doc = "index" # General information about the project. project = "{% if cookiecutter.target_bundle != 'CircuitPython Org' %}{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }} {% endif %}{% endif %}CircuitPython {{ cookiecutter.library_name }} Library" +creation_year = "{% now 'utc', '%Y' %}" current_year = str(datetime.datetime.now().year) -copyright = current_year + " {{ cookiecutter.author_name }}" +year_duration = ( + current_year + if current_year == creation_year + else creation_year + " - " + current_year +) +copyright = year_duration + " {{ cookiecutter.author_name }}" author = "{{ cookiecutter.author_name }}" # The version info for the project you're documenting, acts as replacement for diff --git a/{{ cookiecutter.__dirname }}/pyproject.toml b/{{ cookiecutter.__dirname }}/pyproject.toml index f3c35ae..1fbd043 100644 --- a/{{ cookiecutter.__dirname }}/pyproject.toml +++ b/{{ cookiecutter.__dirname }}/pyproject.toml @@ -1,6 +1,64 @@ -# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò +# SPDX-FileCopyrightText: 2022 Alec Delaney, written for Adafruit Industries +# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %} # -# SPDX-License-Identifier: Unlicense +# SPDX-License-Identifier: MIT -[tool.black] -target-version = ['py35'] +{# put keywords into an iterable list, based on word wrapping #} +{%- set kw_list = namespace(kw_list=[], default=["adafruit", "blinka", "circuitpython", "micropython"]) -%} +{%- do kw_list.default.append(cookiecutter.library_name|lower|replace(" ", "-")) -%} +{%- do kw_list.default.extend(cookiecutter.library_keywords.split(" ")) -%} +{%- set wrapped = kw_list.default|unique|join(" ")|wordwrap(break_long_words=False) -%} +{%- do kw_list.kw_list.extend(wrapped.split("\n")) -%} +{# create repo and pypi names #} +{%- if cookiecutter.target_bundle != 'CircuitPython Org' -%} + {%- if cookiecutter.library_prefix -%} + {%- set repo_name = (cookiecutter.library_prefix | capitalize) -%} + {%- set repo_name = repo_name + '_CircuitPython_' -%} + {%- set repo_name = repo_name + cookiecutter.library_name | replace(" ", "_") -%} + {%- else -%} + {%- set repo_name = 'CircuitPython_' -%} + {%- set repo_name = repo_name + cookiecutter.library_name | replace(" ", "_") -%} + {%- endif -%} +{%- else -%} + {%- set repo_name = 'CircuitPython_Org_' + cookiecutter.library_name | replace(" ", "_") -%} +{%- endif -%} +{%- set pypi_name = repo_name|lower|replace("_", "-")|replace(" ", "-")|replace("circuitpython-org-", "circuitpython-") -%} +[build-system] +requires = [ + "setuptools", + "wheel", + "setuptools-scm", +] + +[project] +name = "{{ pypi_name }}" +description = "{{ cookiecutter.library_description }}" +version = "0.0.0+auto.0" +readme = "README.rst" +authors = [ + {name = "Adafruit Industries", email = "circuitpython@adafruit.com"} +] +urls = {Homepage = "https://github.com/{{ cookiecutter.github_user }}/{{ repo_name }}"} +keywords = [ +{% for kw_list_keyword in kw_list.default %} "{{ kw_list_keyword }}", +{% endfor -%} +] +license = {text = "MIT"} +classifiers = [ + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Embedded Systems", + "Topic :: System :: Hardware", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", +] +dynamic = ["dependencies", "optional-dependencies"] + +[tool.setuptools] +# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER, +# CHANGE `py_modules = ['...']` TO `packages = ['...']` +py-modules = ["{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | lower | replace(" ", "_") }}_{% endif %}{{ cookiecutter.library_name | lower | replace(" ", "_") }}"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} +optional-dependencies = {optional = {file = ["optional_requirements.txt"]}} diff --git a/{{ cookiecutter.__dirname }}/{% if cookiecutter.pypi_release in ['n', 'no'] %}pyproject.toml.disabled{% endif %} b/{{ cookiecutter.__dirname }}/{% if cookiecutter.pypi_release in ['n', 'no'] %}pyproject.toml.disabled{% endif %} deleted file mode 100644 index e5f4e91..0000000 --- a/{{ cookiecutter.__dirname }}/{% if cookiecutter.pypi_release in ['n', 'no'] %}pyproject.toml.disabled{% endif %} +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries -# SPDX-FileCopyrightText: Copyright (c) 2021 Foamyguy for Adafruit Industries -# -# SPDX-License-Identifier: MIT -# -# This library is not deployed to PyPI. It is either a board-specific helper library, or -# does not make sense for use on or is incompatible with single board computers and Linux. -# diff --git a/{{ cookiecutter.__dirname }}/{% if cookiecutter.pypi_release in ['y', 'yes'] %}pyproject.toml{% endif %} b/{{ cookiecutter.__dirname }}/{% if cookiecutter.pypi_release in ['y', 'yes'] %}pyproject.toml{% endif %} deleted file mode 100644 index a520763..0000000 --- a/{{ cookiecutter.__dirname }}/{% if cookiecutter.pypi_release in ['y', 'yes'] %}pyproject.toml{% endif %} +++ /dev/null @@ -1,66 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Alec Delaney, written for Adafruit Industries -# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %} -# -# SPDX-License-Identifier: MIT - -{# put keywords into an iterable list, based on word wrapping #} -{%- set kw_list = namespace(kw_list=[], default=["adafruit", "blinka", "circuitpython", "micropython"]) -%} -{%- do kw_list.default.append(cookiecutter.library_name|lower|replace(" ", "-")) -%} -{%- do kw_list.default.extend(cookiecutter.library_keywords.split(" ")) -%} -{%- set wrapped = kw_list.default|unique|join(" ")|wordwrap(break_long_words=False) -%} -{%- do kw_list.kw_list.extend(wrapped.split("\n")) -%} -{# create repo and pypi names #} -{%- if cookiecutter.target_bundle != 'CircuitPython Org' -%} - {%- if cookiecutter.library_prefix -%} - {%- set repo_name = (cookiecutter.library_prefix | capitalize) -%} - {%- set repo_name = repo_name + '_CircuitPython_' -%} - {%- set repo_name = repo_name + cookiecutter.library_name | replace(" ", "_") -%} - {%- else -%} - {%- set repo_name = 'CircuitPython_' -%} - {%- set repo_name = repo_name + cookiecutter.library_name | replace(" ", "_") -%} - {%- endif -%} -{%- else -%} - {%- set repo_name = 'CircuitPython_Org_' + cookiecutter.library_name | replace(" ", "_") -%} -{%- endif -%} -{%- set pypi_name = repo_name|lower|replace("_", "-")|replace(" ", "-")|replace("circuitpython-org-", "circuitpython-") -%} -[build-system] -requires = [ - "setuptools", - "wheel", - "setuptools-scm", -] - -[project] -name = "{{ pypi_name }}" -description = "{{ cookiecutter.library_description }}" -version = "0.0.0+auto.0" -readme = "README.rst" -authors = [ - {name = "Adafruit Industries", email = "circuitpython@adafruit.com"} -] -urls = {Homepage = "https://github.com/{{ cookiecutter.github_user }}/{{ repo_name }}"} -keywords = [ -{% for kw_list_keyword in kw_list.default %} "{{ kw_list_keyword }}", -{% endfor -%} -] -license = {text = "MIT"} -classifiers = [ - "Intended Audience :: Developers", - "Topic :: Software Development :: Libraries", - "Topic :: Software Development :: Embedded Systems", - "Topic :: System :: Hardware", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3", -] -dynamic = ["dependencies", "optional-dependencies"] - -[tool.setuptools] -# You can just specify the packages manually here if your project is -# simple. Or you can use find_packages(). -# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER, -# CHANGE `py_modules = ['...']` TO `packages = ['...']` -py-modules = ["{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | lower | replace(" ", "_") }}_{% endif %}{{ cookiecutter.library_name | lower | replace(" ", "_") }}"] - -[tool.setuptools.dynamic] -dependencies = {file = ["requirements.txt"]} -optional-dependencies = {optional = {file = ["optional_requirements.txt"]}}