Skip to content

Commit bf73ee1

Browse files
committed
docs/packages: mpy_bin2res no longer required to create resources.
Everything happens automagically with overridden "sdist" from sdist_upip.py.
1 parent 3233537 commit bf73ee1

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

docs/reference/packages.rst

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ an extra intermediate step when packaging application - creation of
259259

260260
The idea of this module is to convert binary data to a Python bytes
261261
object, and put it into the dictionary, indexed by the resource name.
262-
This conversion is done using ``tools/mpy_bin2res.py`` script from
263-
the MicroPython distribution.
262+
This conversion is done automatically using overridden ``sdist`` command
263+
described in the previous section.
264264

265265
Let's trace the complete process using the following example. Suppose
266266
your application has the following structure::
@@ -281,17 +281,28 @@ following calls::
281281
pkg_resources.resource_stream(__name__, "data/image.png")
282282

283283
You can develop and debug using the `MicroPython Unix port` as usual.
284-
When times come to make a distribution package out of it, you would
285-
need to run following command, with ``my_app/`` being the current
286-
directory (and assuming ``mpy_bin2res.py`` is in your path)::
284+
When time comes to make a distribution package out of it, just use
285+
overridden "sdist" command from sdist_upip.py module as described in
286+
the previous section.
287287

288-
mpy_bin2res.py data/page.html data/image.png
288+
This will create a Python resource module named ``R.py``, based on the
289+
files declared in ``MANIFEST`` or ``MANIFEST.in`` files (any non-``.py``
290+
file will be considered a resource and added to ``R.py``) - before
291+
proceeding with the normal packaging steps.
289292

290-
This will produce a Python resource module named ``R.py``. Afterwards,
291-
you package the project for distribution as usual (using ``setup.py sdist``).
292293
Prepared like this, your application will work both when deployed to
293294
filesystem and as frozen bytecode.
294295

296+
If you would like to debug ``R.py`` creation, you can run::
297+
298+
python3 setup.py sdist --manifest-only
299+
300+
Alternatively, you can use tools/mpy_bin2res.py script from the
301+
MicroPython distribution, in which can you will need to pass paths
302+
to all resource files::
303+
304+
mpy_bin2res.py data/page.html data/image.png
305+
295306
References
296307
----------
297308

0 commit comments

Comments
 (0)