|
| 1 | +Portable python binaries |
| 2 | +======================== |
| 3 | + |
| 4 | +.. image:: https://img.shields.io/pypi/v/portable-python.svg |
| 5 | + :target: https://pypi.org/project/portable-python/ |
| 6 | + :alt: Version on pypi |
| 7 | + |
| 8 | +.. image:: https://github.com/codrsquad/portable-python/workflows/Tests/badge.svg |
| 9 | + :target: https://github.com/codrsquad/portable-python/actions |
| 10 | + :alt: Tested with Github Actions |
| 11 | + |
| 12 | +.. image:: https://codecov.io/gh/codrsquad/portable-python/branch/main/graph/badge.svg |
| 13 | + :target: https://codecov.io/gh/codrsquad/portable-python |
| 14 | + :alt: Test code codecov |
| 15 | + |
| 16 | +.. image:: https://img.shields.io/pypi/pyversions/portable-python.svg |
| 17 | + :target: https://github.com/codrsquad/portable-python |
| 18 | + :alt: Python versions tested (link to github project) |
| 19 | + |
| 20 | + |
| 21 | +This project is a python CLI that aims to make compiling portable python binaries automatable. |
| 22 | + |
| 23 | +What is a "portable python"? |
| 24 | +---------------------------- |
| 25 | + |
| 26 | +It's a binary python distribution (``.tar.gz`` or ``.zip``) that can be decompressed |
| 27 | +in any folder, and used from there without further ado (ie: no need to run an "installer" |
| 28 | +and things like that). |
| 29 | + |
| 30 | +The idea here is to allow for automated systems to: |
| 31 | + |
| 32 | +- Easily obtain a python binary, and use it in their sandbox. |
| 33 | + |
| 34 | +- Install versions of python from binary distributions on laptops/workstations, |
| 35 | + similarly to how pyenv_ does it, but without having to compile on target system. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +How it works |
| 41 | +------------ |
| 42 | + |
| 43 | +``portable-python`` is a regular python CLI, it can be installed with: |
| 44 | + |
| 45 | +- With pickley_:: |
| 46 | + |
| 47 | + pickley install portable-python |
| 48 | + portable-python --help |
| 49 | + |
| 50 | +- Using ``pip install``:: |
| 51 | + |
| 52 | + /usr/bin/python3 -mvenv pp |
| 53 | + ./pp/bin/portable-python --help |
| 54 | + |
| 55 | +- From source:: |
| 56 | + |
| 57 | + git clone https://github.com/codrsquad/portable-python.git |
| 58 | + cd portable-python |
| 59 | + tox -e venv |
| 60 | + .venv/bin/portable-python --help |
| 61 | + |
| 62 | + |
| 63 | +Once you've installed ``portable-python``, you can get going like so:: |
| 64 | + |
| 65 | + # Build a binary (for current platform) |
| 66 | + cd some-temp-folder |
| 67 | + portable-python build 3.9.6 |
| 68 | + ls -l dist/3.9.6.tar.gz |
| 69 | + |
| 70 | + # Unpack it somewhere |
| 71 | + tar -C ~/.pyenv/versions/ -xf dist/3.9.6.tar.gz |
| 72 | + ls -l ~/.pyenv/versions/ |
| 73 | + |
| 74 | + # It's ready to be used |
| 75 | + ~/.pyenv/versions/3.9.6/bin/python --version |
| 76 | + |
| 77 | + |
| 78 | +Note that you can use ``--dryrun`` mode to inspect what would be done without doing it:: |
| 79 | + |
| 80 | + $ portable-python --dryrun build 3.9.6 |
| 81 | + |
| 82 | + Would create build/cpython-3.9.2 |
| 83 | + ... |
| 84 | + Would untar build/downloads/readline-8.1.tar.gz -> build/cpython-3.9.2/build/readline |
| 85 | + INFO CFLAGS=-fPIC |
| 86 | + ... |
| 87 | + Would run: ./configure --prefix=/deps --disable-shared --with-curses |
| 88 | + Would run: /usr/bin/make |
| 89 | + Would run: /usr/bin/make install DESTDIR=build/cpython-3.9.2 |
| 90 | + ... |
| 91 | + |
| 92 | + |
| 93 | +Build folder structure |
| 94 | +---------------------- |
| 95 | + |
| 96 | +``portable-python`` uses this file structure (build/ and dist/ folders configurable):: |
| 97 | + |
| 98 | + build/ |
| 99 | + cpython-3.9.6/ # Build artifacts for corresponding version are here |
| 100 | + 3.9.6/ # Full installation (after build completes) |
| 101 | + build/ # Source code of various modules are here |
| 102 | + deps/ # --prefix=/deps passed to all ./configure scripts |
| 103 | + logs/ # Logs for each module build are here, in order of build |
| 104 | + downloads/ |
| 105 | + openssl-1.1.1k.tar.gz # Downloaded artifacts (downloaded only once) |
| 106 | + dist/ |
| 107 | + 3.9.6.tar.gz # Ready-to-go binary tarball |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +.. _pyenv: https://github.com/pyenv/pyenv |
| 112 | + |
| 113 | +.. _pickley: https://pypi.org/project/pickley/ |
0 commit comments