A small tool to bundle a python file and all its imports into a single file.
Project description
compyner
ComPYner is a small tool to bundle a python file and all its imports into a single file. This was created due to the limitations of the micropython implementation on the spike prime, where there is no filesystem to store multiple files. We are aware that there are better ways to implement what we have done, but this is the least ugly code that will run on spike primes micropython.
Installation
Install compyner
with pip, or another tool using PyPI:
pip install compyner
Usage
[!WARNING] This tool is not extensively tested and may not work as expected. Use at your own risk. Feel free to open an issue if you encounter any problems.
compyner <input> -o <output>
This command will read the file at <input>
, "compyne" it and writes the result to <output>
If the -o/--output
argument is not used, the result will be printed to stdout
.
If you want to read from stdin
, you can do this by omitting the input
argument and using the --stdin
flag.
If any modules are imported that are in the standard library, these need to be excluded.
Normally, the script detects these imports and excludes them automatically, but this does not work for some, like the collections
module.
Also, modules that are only availible in the standard library of the target environment should be excluded.
Modules that should be excluded should be passed as a space-seperated list to the --exclude
argument.
Example
compyner main.py --exclude math -o output.py
This will combine the file main.py
with all the files it imports, except for math
, and output the result to output.py
.
The spike_prime_compyne
script
This script is a wrapper around the compyner.py
script that is designed to be used with the spike prime.
It will automatically exclude all known standard library modules and add a comment for the Spike Prime VSCode extension to upload the file to the spike prime.
python3 spike_prime_compyne.py <input_file> [<slot>] > <output_file>
The input_file
and output_file
behave the same as mentioned for the compyner.py
script.
The slot
is the slot number on the spike prime the program is supposed to be uploaded to. This is an optional argument and defaults to 0.
Known issues
None at the moment.
Authors
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file compyner-0.1.4.tar.gz
.
File metadata
- Download URL: compyner-0.1.4.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.5 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 099817e032ff2877c67e6eacede31bd4f4363b0a6e99251b3c07d4fe44199e48 |
|
MD5 | dc93a189cab0f432687c44546fc38a42 |
|
BLAKE2b-256 | d90b9a4470c8ec5dae36c5cab32ba79da6d66ab45b408d8823eb071aecac88d7 |
File details
Details for the file compyner-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: compyner-0.1.4-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.5 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca95ccaca1cab54309d429b8675c8d8d5e1176bf8e60759e15df681fd5365712 |
|
MD5 | 927127bda9c328dd0c96aeb9bb7f127c |
|
BLAKE2b-256 | 3cc4ee355a5a4b91d1dc8b6de20afd51fd28e2388b9d6cd1b48621939bf4c267 |