Skip to content

Always generate PyPI infrastructure #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand All @@ -64,6 +63,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
==============
Expand Down
1 change: 0 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}",
Expand Down
9 changes: 2 additions & 7 deletions tests/test_make_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
4 changes: 0 additions & 4 deletions {{ cookiecutter.__dirname }}/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ image from the assets folder in the PCB's GitHub repo.
`Purchase one from the Adafruit shop <http://www.adafruit.com/products/{{cookiecutter.adafruit_product_id}}>`_
{% endif -%}

{%- if cookiecutter.pypi_release in ["y", "yes"] %}

Installing from PyPI
=====================
.. note:: This library is not available on PyPI yet. Install documentation is included
Expand Down Expand Up @@ -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
==========================================================

Expand Down
66 changes: 62 additions & 4 deletions {{ cookiecutter.__dirname }}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"}
]
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"]}}

This file was deleted.

This file was deleted.