Skip to content

Commit e4449df

Browse files
Publish new build of docs
1 parent d2edf36 commit e4449df

File tree

5 files changed

+139
-190
lines changed

5 files changed

+139
-190
lines changed

main/_sources/plugins/distributing.rst.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ like your plugin) or a package (a folder named like your plugin + ``__init.py__`
2323
Proper packages installable via pip
2424
-----------------------------------
2525

26-
You can have your users install it via ``pip`` and register it for the `entry point <http://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins>`_ ``octoprint.plugin`` via
27-
your plugin's ``setup.py``, this way it will be found automatically by OctoPrint upon initialization of the
28-
plugin subsystem [#f1]_.
26+
You can have your users install it via ``pip`` and register it for the `entry point <https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-package-metadata>`_ ``octoprint.plugin`` via
27+
your plugin's ``pyproject.toml``, this way it will be found automatically by OctoPrint upon initialization of the
28+
plugin subsystem [#f1]_:
29+
30+
.. code-block:: toml
31+
32+
[project.entry-points."octoprint.plugin"]
33+
<your plugin's identifier> = "<your plugin's package name>"
2934
3035
For an example of how the directory structure and related files would look like in this case, please take a
31-
look at the `helloworld example from OctoPrint's example plugins <https://github.com/OctoPrint/Plugin-Examples/tree/master/helloworld>`_.
36+
look at one of OctoPrint's bundled but externally maintained plugins, e.g. `OctoPrint-FileCheck <https://github.com/OctoPrint/OctoPrint-FileCheck/>`_.
3237

3338
This variant is highly recommended for pretty much any plugin besides the most basic ones since it also allows
3439
requirements management and pretty much any thing else that Python's setuptools provide to the developer.

main/_sources/plugins/gettingstarted.rst.txt

Lines changed: 57 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@ This will create a project structure in the ``OctoPrint-HelloWorld`` folder we j
206206
babel.cfg
207207
MANIFEST.in
208208
README.md
209+
pyproject.toml
209210
requirements.txt
210211
setup.py
211-
setup.cfg
212+
Taskfile.yml
212213

213214
While we'll need some of those folders later on, we'll now delete everything that we don't need right now first, that
214215
will make it easier to understand what folder does what later on. Delete the following folders and anything in them:
@@ -227,89 +228,62 @@ The final project structure should look like this for now::
227228
babel.cfg
228229
MANIFEST.in
229230
README.md
231+
pyproject.toml
230232
requirements.txt
231-
setup.cfg
232233
setup.py
234+
Taskfile.yml
233235

234-
Out of curiosity, take a look into the ``setup.py`` file. The cookiecutter template should have prefilled all the
236+
Out of curiosity, take a look into the ``pyproject.toml`` file. The cookiecutter template should have prefilled all the
235237
configuration parameters for you:
236238

237-
.. code-block:: python
238-
239-
# coding=utf-8
240-
241-
########################################################################################################################
242-
### Do not forget to adjust the following variables to your own plugin.
243-
244-
# The plugin's identifier, has to be unique
245-
plugin_identifier = "helloworld"
246-
247-
# The plugin's python package, should be "octoprint_<plugin identifier>", has to be unique
248-
plugin_package = "octoprint_helloworld"
249-
250-
# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the
251-
# plugin module
252-
plugin_name = "OctoPrint-Helloworld"
253-
254-
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
255-
plugin_version = "1.0.0"
256-
257-
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
258-
# module
259-
plugin_description = """A quick "Hello World" example plugin for OctoPrint"""
239+
.. code-block:: toml
260240
261-
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module
262-
plugin_author = "Your name"
241+
[build-system]
242+
requires = ["setuptools>=68", "wheel"]
243+
build-backend = "setuptools.build_meta"
263244
264-
# The plugin's author's mail address.
265-
plugin_author_email = "[email protected]"
245+
[project]
246+
name = "OctoPrint-Helloworld"
247+
version = "1.0.0"
248+
description = "A quick "Hello World" example plugin for OctoPrint"
249+
authors = [
250+
{name = "Your name", email = "[email protected]"}
251+
]
252+
readme = {file = "README.md", content-type = "text/markdown"}
253+
dynamic = [
254+
"license"
255+
]
266256
267-
# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module
268-
plugin_url = "https://github.com/yourGithubName/OctoPrint-Helloworld"
257+
requires-python = ">=3.7, <4"
269258
270-
# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module
271-
plugin_license = "AGPLv3"
259+
# any additional requirements (besides OctoPrint) should be listed here
260+
dependencies = []
272261
273-
# Any additional requirements besides OctoPrint should be listed here
274-
plugin_requires = []
262+
[tool.setuptools]
263+
include-package-data = true
275264
276-
### --------------------------------------------------------------------------------------------------------------------
277-
### More advanced options that you usually shouldn't have to touch follow after this point
278-
### --------------------------------------------------------------------------------------------------------------------
265+
[tool.setuptools.packages.find]
266+
include = [
267+
"octoprint_helloworld",
268+
"octoprint_helloworld.*"
269+
]
279270
280-
# Additional package data to install for this plugin. The subfolders "templates", "static" and "translations" will
281-
# already be installed automatically if they exist. Note that if you add something here you'll also need to update
282-
# MANIFEST.in to match to ensure that python setup.py sdist produces a source distribution that contains all your
283-
# files. This is sadly due to how python's setup.py works, see also http://stackoverflow.com/a/14159430/2028598
284-
plugin_additional_data = []
271+
[project.entry-points."octoprint.plugin"]
272+
helloworld = "octoprint_helloworld"
285273
286-
# Any additional python packages you need to install with your plugin that are not contained in <plugin_package>.*
287-
plugin_additional_packages = []
274+
[project.urls]
275+
Homepage = "https://github.com/yourGithubName/OctoPrint-Helloworld"
288276
289-
# Any python packages within <plugin_package>.* you do NOT want to install with your plugin
290-
plugin_ignored_packages = []
291-
292-
# Additional parameters for the call to setuptools.setup. If your plugin wants to register additional entry points,
293-
# define dependency links or other things like that, this is the place to go. Will be merged recursively with the
294-
# default setup parameters as provided by octoprint_setuptools.create_plugin_setup_parameters using
295-
# octoprint.util.dict_merge.
296-
#
297-
# Example:
298-
# plugin_requires = ["someDependency==dev"]
299-
# additional_setup_parameters = {"dependency_links": ["https://github.com/someUser/someRepo/archive/master.zip#egg=someDependency-dev"]}
300-
# "python_requires": ">=3,<4" blocks installation on Python 2 systems, to prevent confused users and provide a helpful error.
301-
# Remove it if you would like to support Python 2 as well as 3 (not recommended).
302-
additional_setup_parameters = {"python_requires": ">=3,<4"}
303-
304-
########################################################################################################################
305-
306-
# ... remaining setup.py content ...
277+
[project.optional-dependencies]
278+
develop = [
279+
"go-task-bin"
280+
]
307281
308282
Now all that's left to do is to move our ``helloworld.py`` into the ``octoprint_helloworld`` folder and renaming it to
309283
``__init__.py``. Make sure to delete the copy under ``~/.octoprint/plugins`` in the process, including the ``.pyc`` file!
310284

311-
The plugin is now ready to be installed via ``python setup.py install``. However, since we are still
312-
working on our plugin, it makes more sense to use ``python setup.py develop`` for now -- this way the plugin becomes
285+
The plugin is now ready to be installed via ``pip install .``. However, since we are still
286+
working on our plugin, it makes more sense to use ``pip install -e .`` for now -- this way the plugin becomes
313287
discoverable by OctoPrint, however we don't have to reinstall it after any changes we will still do. We can have the
314288
``octoprint dev plugin:install`` command do everything for us here, it will ensure to use the python binary belonging
315289
to your OctoPrint installation::
@@ -318,15 +292,11 @@ to your OctoPrint installation::
318292
>> /home/gina/.pyenv/versions/3.11.2/envs/octoprint-py311/bin/python -m pip install -e .
319293
Obtaining file:///home/gina/devel/OctoPrint-Helloworld
320294

321-
Preparing metadata (setup.py): started
322-
323-
Preparing metadata (setup.py): finished with status 'done'
324-
325295
[...]
326296

327297
Installing collected packages: OctoPrint-Helloworld
328298

329-
Running setup.py develop for OctoPrint-Helloworld
299+
[...]
330300

331301
Successfully installed OctoPrint-Helloworld-0.1.0
332302

@@ -346,7 +316,7 @@ Restart OctoPrint. Your plugin should still be properly discovered and the log l
346316

347317
Looks like it still works!
348318

349-
Something is still a bit ugly though. Take a look into ``__init__.py`` and ``setup.py``. It seems like we have a bunch
319+
Something is still a bit ugly though. Take a look into ``__init__.py`` and ``pyproject.toml``. It seems like we have a bunch
350320
of information now defined twice:
351321

352322
.. code-block:: python
@@ -357,25 +327,19 @@ of information now defined twice:
357327
__plugin_description__ = "A quick \"Hello World\" example plugin for OctoPrint"
358328
359329
.. code-block:: python
360-
:caption: setup.py
330+
:caption: pyproject.toml
361331
362332
# ...
363333
364-
# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the
365-
# plugin module
366-
plugin_name = "OctoPrint-Helloworld"
367-
368-
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
369-
plugin_version = "1.0.0"
370-
371-
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
372-
# module
373-
plugin_description = """A quick "Hello World" example plugin for OctoPrint"""
334+
[project]
335+
name = "OctoPrint-Helloworld"
336+
version = "1.0.0"
337+
description = "A quick "Hello World" example plugin for OctoPrint"
374338
375339
# ...
376340
377341
The nice thing about our plugin now being a proper Python package is that OctoPrint can and will access the metadata defined
378-
within ``setup.py``! So, we don't really need to define all this data twice. Remove ``__plugin_name__``, ``__plugin_version__``
342+
within ``pyproject.toml``! So, we don't really need to define all this data twice. Remove ``__plugin_name__``, ``__plugin_version__``
379343
and ``__plugin_description__`` from ``__init__.py``, but leave ``__plugin_implementation__`` and ``__plugin_pythoncompat__``:
380344

381345
.. code-block:: python
@@ -420,7 +384,7 @@ Restart OctoPrint again::
420384
| Hello World (1.0.0) = /home/gina/devel/OctoPrint-HelloWorld/octoprint_helloworld
421385
[...]
422386

423-
Much better! You can override pretty much all of the metadata defined within ``setup.py`` from within your Plugin itself --
387+
Much better! You can override pretty much all of the metadata defined within ``pyproject.toml`` from within your Plugin itself --
424388
take a look at :ref:`the available control properties <sec-plugins-controlproperties>` for all available
425389
overrides.
426390

@@ -476,9 +440,10 @@ Our plugin's directory structure should now look like this::
476440
babel.cfg
477441
MANIFEST.in
478442
README.md
443+
pyproject.toml
479444
requirements.txt
480445
setup.py
481-
setup.cfg
446+
Taskfile.yml
482447

483448
Restart OctoPrint and open the web interface in your browser (make sure to clear your browser's cache!).
484449

@@ -724,9 +689,10 @@ look like this::
724689
babel.cfg
725690
MANIFEST.in
726691
README.md
692+
pyproject.toml
727693
requirements.txt
728694
setup.py
729-
setup.cfg
695+
Taskfile.yml
730696

731697
We need to tell OctoPrint about this new static asset so that it will properly inject it into the page. For this we
732698
just need to subclass :class:`~octoprint.plugin.AssetPlugin` and override its method :func:`~octoprint.plugin.AssetPlugin.get_assets`
@@ -878,8 +844,10 @@ First we'll create a new folder within our plugin's ``static`` folder called ``c
878844
babel.cfg
879845
MANIFEST.in
880846
README.md
847+
pyproject.toml
881848
requirements.txt
882849
setup.py
850+
Taskfile.yml
883851

884852
Put something like the following into ``helloworld.css``:
885853

@@ -983,8 +951,10 @@ in the process. The folder structure of our plugin should now look like this::
983951
babel.cfg
984952
MANIFEST.in
985953
README.md
954+
pyproject.toml
986955
requirements.txt
987956
setup.py
957+
Taskfile.yml
988958

989959
Then adjust our returned assets to include our LESS file as well:
990960

main/plugins/distributing.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,15 @@
158158
</section>
159159
<section id="proper-packages-installable-via-pip">
160160
<span id="sec-plugins-distribution-pip"></span><h2><a class="toc-backref" href="#id4" role="doc-backlink">Proper packages installable via pip</a><a class="headerlink" href="#proper-packages-installable-via-pip" title="Link to this heading"></a></h2>
161-
<p>You can have your users install it via <code class="docutils literal notranslate"><span class="pre">pip</span></code> and register it for the <a class="reference external" href="http://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins">entry point</a> <code class="docutils literal notranslate"><span class="pre">octoprint.plugin</span></code> via
162-
your plugin’s <code class="docutils literal notranslate"><span class="pre">setup.py</span></code>, this way it will be found automatically by OctoPrint upon initialization of the
163-
plugin subsystem <a class="footnote-reference brackets" href="#f1" id="id1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>.</p>
161+
<p>You can have your users install it via <code class="docutils literal notranslate"><span class="pre">pip</span></code> and register it for the <a class="reference external" href="https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-package-metadata">entry point</a> <code class="docutils literal notranslate"><span class="pre">octoprint.plugin</span></code> via
162+
your plugin’s <code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code>, this way it will be found automatically by OctoPrint upon initialization of the
163+
plugin subsystem <a class="footnote-reference brackets" href="#f1" id="id1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>:</p>
164+
<div class="highlight-toml notranslate"><div class="highlight"><pre><span></span><span class="k">[project.entry-points.</span><span class="s2">&quot;octoprint.plugin&quot;</span><span class="k">]</span>
165+
<span class="err">&lt;</span><span class="n">your</span><span class="w"> </span><span class="n">plugin</span><span class="s1">&#39;s identifier&gt; = &quot;&lt;your plugin&#39;</span><span class="n">s</span><span class="w"> </span><span class="n">package</span><span class="w"> </span><span class="n">name</span><span class="err">&gt;</span><span class="s2">&quot;</span>
166+
</pre></div>
167+
</div>
164168
<p>For an example of how the directory structure and related files would look like in this case, please take a
165-
look at the <a class="reference external" href="https://github.com/OctoPrint/Plugin-Examples/tree/master/helloworld">helloworld example from OctoPrint’s example plugins</a>.</p>
169+
look at one of OctoPrint’s bundled but externally maintained plugins, e.g. <a class="reference external" href="https://github.com/OctoPrint/OctoPrint-FileCheck/">OctoPrint-FileCheck</a>.</p>
166170
<p>This variant is highly recommended for pretty much any plugin besides the most basic ones since it also allows
167171
requirements management and pretty much any thing else that Python’s setuptools provide to the developer.</p>
168172
<div class="admonition seealso">

0 commit comments

Comments
 (0)