Skip to content

Instantly share code, notes, and snippets.

@askpatrickw
Last active January 11, 2022 09:54
Show Gist options
  • Save askpatrickw/e69eacd2c60c8e27f255d976ab5e8820 to your computer and use it in GitHub Desktop.
Save askpatrickw/e69eacd2c60c8e27f255d976ab5e8820 to your computer and use it in GitHub Desktop.
Thoughts on Package Management for CircuitPython

Package Management for CircuitPython

Nothing formal written up on this yet, but I think we're seeing the download the zip file approach start to become brittle. Already there are two different bundles. My initial thought is why not have a cpip (or modify circup) and use PyPi. One thing I like about this is that it teaches new programmers things they need to learn if they also do Python programming. I've not done any real research into the technical parts of this yet, but in an ideal world, a fork of pip or some modular components of pip could be used to drive the core logic of version checking and install and the CP specific parts that deal with the board would be the additional functionality.

@dglaude
Copy link

dglaude commented Apr 5, 2021

Wait, you are using pip to install CP library on a CP board mounted on the Linux host?
That is ... impressive? Mind blowing?

For the *.py vs *.mpy then maybe it could be downloaded to a temporary location and then mpy-cross to have the mpy and then only copy to the device.

Not sure what kind of wrapper that would require, but it might be a good trick.

@askpatrickw
Copy link
Author

@dglaude, I'm not, but it looks like you could. ;-)

That's a great idea as an interim step.
I've not used MPY-Cross. When I look at it, it sounds like it's target OS specific. Am I misunderstanding that?

I notice this issue in CP Build Tools... maybe the mpy-cross referenced there could be used.
adafruit/circuitpython-build-tools#55

@dglaude
Copy link

dglaude commented Apr 7, 2021

I think that while MPY-Cross exist on multiple platform, it always generate the same output MPY file for the same input PY file.
It is "just" cross compiling, or doing the parsing from Python file to file that can be executed in the CircuitPython virtual machine.

Yes the mpy-cross for Windows/Mac/??? are build and available from there, so there is no need to compile MPY-Cross yourself.

@askpatrickw
Copy link
Author

Could pip --implementation have mpy added?

--implementation
Only use wheels compatible with Python implementation , e.g. 'pp', 'jy', 'cp', or
'ip'. If not specified, then the current interpreter implementation is used. Use 'py' to force
implementation-agnostic wheels.

@askpatrickw
Copy link
Author

Or a CP PyPi...

Package Index Options:
-i, --index-url Base URL of the Python Package Index (default https://pypi.org/simple). This should point to a
repository compliant with PEP 503 (the simple repository API) or a local directory laid out in the
same format.
--extra-index-url Extra URLs of package indexes to use in addition to --index-url. Should follow the same rules as
--index-url.
--no-index Ignore package index (only looking at --find-links URLs instead).
-f, --find-links If a URL or path to an html file, then parse for links to archives such as sdist (.tar.gz) or wheel
(.whl) files. If a local path or file:// URL that's a directory, then look for archives in the
directory listing. Links to VCS project URLs are not supported.

@aivarannamaa
Copy link

aivarannamaa commented Jun 28, 2021

@askpatrickw, Here is my investigation concerning --implementation: aivarannamaa/minipip#6

You may also find aivarannamaa/minipip#5 and https://github.com/aivarannamaa/packaging_experiment interesting

@askpatrickw
Copy link
Author

@Thynix
Copy link

Thynix commented Jan 11, 2022

I haven't seen mention of it, so I'll offer that Mu Editor support for whatever the package management ends up looking like would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment