|
1 |
| -Introduction |
2 |
| -============ |
3 |
| - |
4 |
| -.. image :: https://img.shields.io/discord/327254708534116352.svg |
5 |
| - :target: https://adafru.it/discord |
6 |
| - :alt: Discord |
7 |
| -
|
8 |
| -This cookiecutter creates a project structure for a Adafruit CircuitPython |
9 |
| -library. |
10 |
| - |
11 |
| -See this Adafruit Learn Guide for an explanation of creating a CircuitPython library: `Creating and sharing a CircuitPython library <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/overview>`_ The section for using cookiecutter is `here <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/creating-a-library#cookie-cutter>`_. |
12 |
| - |
13 |
| -.. note:: |
14 |
| - |
15 |
| - The above Learn Guide is directed towards creating a library for the Community Bundle. For libraries meant for the Adafruit Bundle, contact the CircuitPython Helpers (@circuitpython helpers) on Discord or put in a new issue on the Adafruit_CircuitPython_Bundle GitHub repository. |
16 |
| - |
17 |
| -Cookiecutter Usage |
18 |
| -=================== |
19 |
| - |
20 |
| -.. code-block:: bash |
21 |
| -
|
22 |
| - # The first time |
23 |
| - pip install cookiecutter |
24 |
| -
|
25 |
| - cookiecutter gh:adafruit/cookiecutter-adafruit-circuitpython |
26 |
| -
|
27 |
| -Then, fill in the prompts and accomplish some post generation cleanup: |
28 |
| - |
29 |
| -Prompts |
30 |
| --------- |
31 |
| - |
32 |
| -* ``target_bundle`` - Adafruit bundle or Community library bundle |
33 |
| -* ``github_user`` - GitHub user or organization which will host this repo. For example, Adafruit funded libraries should say "adafruit" here. |
34 |
| -* ``author_name`` - Who you are! Sets the copyright to you. |
35 |
| -* ``company`` - Used to give Copyright credit to the company funding the library. For example, Adafruit funded libraries should say "Adafruit Industries" here. |
36 |
| -* ``library_name`` - Shortest name for the library. Usually a chip name such as LIS3DH. |
37 |
| -* ``library_description`` - Write a sentence describing the purpose of this library (e.g. ``CircuitPython helper library for the DC & Stepper Motor FeatherWing, Shield and Pi Hat kits.``). |
38 |
| -* ``library_keywords`` - Used to populate keywords for PyPi. Enter a string of keywords (e.g ``dht temp humidity``) NOTE: The following are included by default: ``adafruit``, ``blinka``, ``circuitpython``, ``micropython``, and the ``library_name`` you enter. |
39 |
| -* ``library_prefix`` - Used to prefix the code to the organization creating the library. For example, Adafruit supported libraries should say "adafruit" here. Do not add a - or _. |
40 |
| -* ``adafruit_product_id`` - The product ID for the Adafruit product includes a link to the product in the README. Only applies to Adafruit Bundle. |
41 |
| -* ``requires_bus_device`` - Determines whether to add comments about a dependency on `BusDevice <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_. |
42 |
| - If the library uses BusDevice, enter ``y`` or ``yes`` to include. If the library doesn't use BusDevice, all other entries including empty, will not include BusDevice. |
43 |
| -* ``requires_register`` - Determines whether to add comments about a dependency on `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_. |
44 |
| - 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. |
45 |
| -* ``other_requirements`` - Adds any other module dependencies for PyPi. Enter a comma separated string of modules |
46 |
| - (e.g. ``adafruit-circuitpython-pca9685, adafruit-circuitpython-motor``). NOTE: ``Adafruit-Blinka`` is always included, so no need to include it here. |
47 |
| -* ``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. |
48 |
| -* ``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. |
49 |
| - |
50 |
| - |
51 |
| -Post Generation Cleanup |
52 |
| ------------------------- |
53 |
| - |
54 |
| -After generation, make sure to glance over the files to make sure they |
55 |
| -autogenerated as you expect (such as capitalization). There are a few places |
56 |
| -with ``.. todo::`` that should also be taken care of. After adding or updating |
57 |
| -the information requested, make sure the ``.. todo::`` text is removed. Like this: |
58 |
| - |
59 |
| -.. code:: |
60 |
| -
|
61 |
| - # Before Cleanup |
62 |
| - .. todo:: Describe what the module does |
63 |
| -
|
64 |
| -.. code:: |
65 |
| -
|
66 |
| - # After Cleanup |
67 |
| - This library talks to the AM4Z-1NG sensor. Typical use is for robot friends. |
68 |
| -
|
69 |
| -Windows Users |
70 |
| -============== |
71 |
| - |
72 |
| -Due to the development nature of cookiecutter, there are some limitations when using with Windows. |
73 |
| - |
74 |
| -Cookiecutter Installation |
75 |
| --------------------------- |
76 |
| - |
77 |
| -The Python enviornment can be tricky sometimes in Windows. Use this documentation page for steps and tips on Windows installation: `Cookiecutter Installation - Windows <https://cookiecutter.readthedocs.io/en/latest/installation.html#windows>`_ |
78 |
| - |
79 |
| - |
80 |
| -<library>.py & /examples/<library>_simpletest.py File Generation |
81 |
| ------------------------------------------------------------------- |
82 |
| - |
83 |
| -Cookiecutter was developed for use in \*\nix/OSX enviornments. When implementing prompt based configuration for things like filenames, special characters were used for programmatic detection and formatting. |
84 |
| - |
85 |
| -.. code-block:: |
86 |
| -
|
87 |
| - {% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | lower }}_{% endif %}{{ cookiecutter.library_name | lower }}.py |
88 |
| -
|
89 |
| -As such, Windows will block the use of these special characters in filenames. So when cookiecutter pulls the Adafruit CircuitPython template, the <library>.py and /examples/<library>_simpletest.py files are not created. This adds an extra step. Simply copy an existing library's .py files (and structure if making a "package"), and change the prompted values (e.g. author name, library name, documentation information, etc). |
90 |
| - |
91 |
| -.. note:: |
92 |
| - The above is from experience with using cookiecutter within a Windows native setup. This may not be applicable when using Windows Subsystem for Linux (WSL) or any *nix-For-Windows utilities. |
93 |
| -
|
94 |
| - We are always exploring ways to make things easier, so this workflow may change. Also, ideas and solutions are always welcome! |
| 1 | +Introduction |
| 2 | +============ |
| 3 | + |
| 4 | +.. image :: https://img.shields.io/discord/327254708534116352.svg |
| 5 | + :target: https://adafru.it/discord |
| 6 | + :alt: Discord |
| 7 | +
|
| 8 | +This cookiecutter creates a project structure for an Adafruit CircuitPython library. |
| 9 | + |
| 10 | +See this Adafruit Learn Guide for an explanation of creating a CircuitPython library: `Creating and sharing a CircuitPython library <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/overview>`_ The section for using cookiecutter is `here <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/creating-a-library#cookie-cutter>`_. |
| 11 | + |
| 12 | +.. note:: |
| 13 | + |
| 14 | + The above Learn Guide is directed towards creating a library for the Community Bundle. For libraries meant for the Adafruit Bundle, contact the CircuitPython Helpers (@circuitpython helpers) on Discord or put in a new issue on the Adafruit_CircuitPython_Bundle GitHub repository. |
| 15 | + |
| 16 | +Cookiecutter Usage |
| 17 | +=================== |
| 18 | + |
| 19 | +.. code-block:: bash |
| 20 | +
|
| 21 | + # The first time |
| 22 | + pip install cookiecutter~=2.1 |
| 23 | +
|
| 24 | + cookiecutter gh:adafruit/cookiecutter-adafruit-circuitpython |
| 25 | +
|
| 26 | +Then, fill in the prompts and accomplish some post generation cleanup: |
| 27 | + |
| 28 | +Prompts |
| 29 | +-------- |
| 30 | + |
| 31 | +* ``target_bundle`` - Adafruit bundle or Community library bundle |
| 32 | +* ``github_user`` - GitHub user or organization which will host this repo. For example, Adafruit funded libraries should say "adafruit" here. |
| 33 | +* ``author_name`` - Who you are! Sets the copyright to you. |
| 34 | +* ``company`` - Used to give Copyright credit to the company funding the library. For example, Adafruit funded libraries should say "Adafruit Industries" here. |
| 35 | +* ``library_name`` - Shortest name for the library. Usually a chip name such as LIS3DH. |
| 36 | +* ``library_description`` - Write a sentence describing the purpose of this library (e.g. ``CircuitPython helper library for the DC & Stepper Motor FeatherWing, Shield and Pi Hat kits.``). |
| 37 | +* ``library_keywords`` - Used to populate keywords for PyPi. Enter a string of keywords (e.g ``dht temp humidity``) NOTE: The following are included by default: ``adafruit``, ``blinka``, ``circuitpython``, ``micropython``, and the ``library_name`` you enter. |
| 38 | +* ``library_prefix`` - Used to prefix the code to the organization creating the library. For example, Adafruit supported libraries should say "adafruit" here. Do not add a - or _. |
| 39 | +* ``adafruit_product_id`` - The product ID for the Adafruit product includes a link to the product in the README. Only applies to Adafruit Bundle. |
| 40 | +* ``requires_bus_device`` - Determines whether to add comments about a dependency on `BusDevice <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_. |
| 41 | + If the library uses BusDevice, enter ``y`` or ``yes`` to include. If the library doesn't use BusDevice, all other entries including empty, will not include BusDevice. |
| 42 | +* ``requires_register`` - Determines whether to add comments about a dependency on `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_. |
| 43 | + 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. |
| 44 | +* ``other_requirements`` - Adds any other module dependencies for PyPi. Enter a comma separated string of modules |
| 45 | + (e.g. ``adafruit-circuitpython-pca9685, adafruit-circuitpython-motor``). NOTE: ``Adafruit-Blinka`` is always included, so no need to include it here. |
| 46 | +* ``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. |
| 47 | + |
| 48 | + |
| 49 | +Post Generation Cleanup |
| 50 | +------------------------ |
| 51 | + |
| 52 | +After generation, make sure to glance over the files to make sure they |
| 53 | +autogenerated as you expect (such as capitalization). There are a few places |
| 54 | +with ``.. todo::`` that should also be taken care of. After adding or updating |
| 55 | +the information requested, make sure the ``.. todo::`` text is removed. Like this: |
| 56 | + |
| 57 | +.. code:: |
| 58 | +
|
| 59 | + # Before Cleanup |
| 60 | + .. todo:: Describe what the module does |
| 61 | +
|
| 62 | +.. code:: |
| 63 | +
|
| 64 | + # After Cleanup |
| 65 | + This library talks to the AM4Z-1NG sensor. Typical use is for robot friends. |
| 66 | +
|
| 67 | +.. note:: |
| 68 | + |
| 69 | + If you are not uploading the repository for Adafruit (i.e., the Community bundle), and you |
| 70 | + wish to use the Release feature on GitHub to upload libraries to PyPI, you will need to |
| 71 | + add your PyPI token to the repository secrets. Set a secret named ``PYPI_USERNAME`` to |
| 72 | + ``__token__`` and a secret named ``PYPI_PASSWORD`` to your API token with the proper scope. |
| 73 | + Never share your API token anyone! |
| 74 | + |
| 75 | +Windows Users |
| 76 | +============== |
| 77 | + |
| 78 | +Due to the development nature of cookiecutter, there are some limitations when using with Windows. |
| 79 | + |
| 80 | +Cookiecutter Installation |
| 81 | +-------------------------- |
| 82 | + |
| 83 | +The Python enviornment can be tricky sometimes in Windows. Use this documentation page for steps and tips on Windows installation: `Cookiecutter Installation - Windows <https://cookiecutter.readthedocs.io/en/latest/installation.html#windows>`_ |
| 84 | + |
| 85 | + |
| 86 | +<library>.py & /examples/<library>_simpletest.py File Generation |
| 87 | +------------------------------------------------------------------ |
| 88 | + |
| 89 | +Cookiecutter was developed for use in \*\nix/OSX enviornments. When implementing prompt based configuration for things like filenames, special characters were used for programmatic detection and formatting. |
| 90 | + |
| 91 | +.. code-block:: |
| 92 | +
|
| 93 | + {% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | lower }}_{% endif %}{{ cookiecutter.library_name | lower }}.py |
| 94 | +
|
| 95 | +As such, Windows will block the use of these special characters in filenames. So when cookiecutter pulls the Adafruit CircuitPython template, the <library>.py and /examples/<library>_simpletest.py files are not created. This adds an extra step. Simply copy an existing library's .py files (and structure if making a "package"), and change the prompted values (e.g. author name, library name, documentation information, etc). |
| 96 | + |
| 97 | +.. note:: |
| 98 | + The above is from experience with using cookiecutter within a Windows native setup. This may not be applicable when using Windows Subsystem for Linux (WSL) or any *nix-For-Windows utilities. |
| 99 | +
|
| 100 | + We are always exploring ways to make things easier, so this workflow may change. Also, ideas and solutions are always welcome! |
0 commit comments