Skip to content

Only package the main source for PyPI #62

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 1 commit into from
Nov 26, 2021

Conversation

wnienhaus
Copy link
Collaborator

This PR changes MANIFEST.in to exclude everything other than the main source of py-esp32-ulp, such as documentation and tests.

The approach used here is to exclude all files from the root (since the main source lives in esp32_ulp/) and also exclude all other directories by name. (i.e. include all, and then remove most things)

Semantically, I would have wanted to express the opposite: "exclude all, and only include esp32_ulp/". However, this also ended up excluding metadata files that setuptools put in the archive. I could include them again explicitly, but I think this could cause unexpected (hard-to-debug) behaviour in the future, if for example a future version of setuptools added more metadata files, or changed the name of this metadata file. It feels like something that could easily go by unnoticed.

In contrast, if a future change in py-esp32-ulp added a new directory of file, it would be quite noticeable (and understandable) if those files ended up in the package, because MAINFEST.in was not updated to specifically exclude them.

This is why I chose the approach I did.

Footnote

With the opposite approach, MANIFEST.in would have looked like this:

exclude *
prune *
include esp32_ulp/*.py
include micropython_py_esp32_ulp.egg-info/PKG-INFO

(notice having the specifically also include the PKG-INFO file)

Maybe there are other / cleaner ways of achieving the "only package esp32_ulp/*.py" intention?

The MANIFEST.in will exclude documentation, examples and tests
and all files in the repo root. This way only the main source
in esp32_ulp/ will be packaged by sdist.

Since we're packaging to upip format, which can only be installed
by MicroPython/upip, we leave out all files that are not strictly
needed to run on the ESP32, so we save space on the device.

If anyone needs the other files on a more capable device (aka PC),
simply do a git clone.
@wnienhaus wnienhaus mentioned this pull request Nov 24, 2021
# to not waste space on the esp32
# (upip packages are not installable by pip on a PC, so on a PC one
# would git clone anyway and get all the other files)
exclude * # exclude all files in repo root
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do to the setup.py?

@wnienhaus
Copy link
Collaborator Author

That rules does exclude setup.py, but in the upip format, setup.py is not included in the package anyway. The MicroPython documentation writes this:

Besides the small compression dictionary size, MicroPython distribution packages also have other optimizations, like removing any files from the archive which aren’t used by the installation process. In particular, upip package manager doesn’t execute setup.py during installation (see below), and thus that file is not included in the archive.

The exclusion happens in sdist_upip.py with this FILTERS rule: https://github.com/ThomasWaldmann/py-esp32-ulp/blob/master/sdist_upip.py#L48 (each tuple is an "(include, exclude)" pattern).

I could perhaps add a comment into the MANIFEST.in file to make this conscious choice (that exclude all is ok to exclude setup.py) clear? Or maybe I should rather change to excluding files one-by-one rather than using such a broad wildcard (for the same reason I defined above, why I exclude directories one-by-one)?

@ThomasWaldmann
Copy link
Collaborator

ah, sorry, i did not know that the setup.py isn't used at all.

guess we can keep it as is for now and if we ever need to add files from root, we can still remove the wildcard.

@ThomasWaldmann ThomasWaldmann merged commit c5d802b into micropython:master Nov 26, 2021
@wnienhaus wnienhaus deleted the manifest-in branch November 28, 2021 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants