portable-python 1.4.4
This project is a python CLI that aims to make compiling portable python binaries automatable.
What is a “portable python”?
It’s a binary python distribution (.tar.gz or .zip) that can be decompressed in any folder, and used from there without further ado (ie: no need to run an “installer” and things like that).
The idea here is to allow for automated systems to:
- Easily obtain a python binary, that can be used in sandboxes / workstations / laptops / instances…
- Have an open source tool that can compile such portable pythons reliably, without having to worry about the compilation part.
- Be able to inspect any python installation, and point out how portable it is, which shared or non-standard libraries it is using
Guiding principles
- Focuses on just one thing: compile a portable python, and validate that it is indeed portable, produce outcome in (configurable) ./dist/ folder and that’s it
- Only the last few non-EOL versions of python are supported (no historical stuff)
- As time goes on, the code of this tool will evolve so that the latest pythons keep building (but won’t worry that older versions still keep building)
- C compilation is done as simply as possible: no “patching” of any sort, rely solely on the upstream make/configure scripts, typically via stuff like --enable-shared=no
- Builds are validated, an important part of the effort was to write up code that is able to inspect a python installation and detect whether it is portable or not (and why not if so).
- cpython is initially supported, but aiming to compile any python family in the future (pypy, conda, …)
- Cross-compilation would be cool, but only if upstream supports it (ie: only if doable via stuff like ./configure --host=. — no on-the-fly patching allowed)
For this repo itself:
- Code is pure python, it is a CLI with one entry-point called portable-python
- Can be ran in a debugger
- 100% test coverage, has a --dryrun mode to help with testing / debugging / seeing what would be done quickly
- No shell scripts (those are hard to maintain/test/debug)
- Can be pip install-ed and reused
Installation
portable-python is a regular python CLI, it can be installed with:
You can also run it directly (without explicit install) with pipx:
Using pip install (a CI builder would probably do this):
Invoke a build from python code:
Invoke an inspection from python code:
From source, contributions welcome!:
Building a portable cpython
Once you’ve installed portable-python , you can get going like so:
Note that you can use --dryrun mode to inspect what would be done without doing it:
Build folder structure
portable-python uses this file structure (build/ and dist/ folders configurable):
Как поставить на флешку python и pygame?
Так что мне нужно иметь возможность приносить Python в мою школу и обратно, и я подумал, что проще всего было бы поместить все это на одну флешку. Я бы загружал все на ноутбук, который дала нам школа, но я не думаю, что они хотели бы, чтобы я загружал вещи на их компьютеры.
Я не уверен, что делать с Python на флеш-накопителе, так что если кто-нибудь знает как, то это очень поможет.
2 ответа
Вы должны искать «портативный питон». Ниже приведены некоторые общие параметры:
Тем не менее, я не думаю, что школа будет против того, чтобы вы ставили питона на ноутбук. Это будет актив, если правильно установлен. При необходимости вы можете самостоятельно удалить его, прежде чем вернуть ноутбук в школу. Даже если вы не можете этого сделать, школьный компьютерный отдел должен иметь возможность отформатировать ноутбук и переустановить систему, если потребуется, хотя, скорее всего, они установят python на все ноутбуки!
Вы можете использовать Ninite для создания переносимой установки Python на флэш-накопитель, а затем скопировать файлы Pygame на флэш-накопитель. диск тоже.
Запуск питона с USB-накопителя
Я хочу загрузить Python на свой Ubuntu 12.04, но я запускаю его на USB-накопителе. У меня есть какой-либо выбор, чтобы загрузить Python на мою флешку? К вашему сведению, я впервые касаюсь Ubuntu, поэтому постарайтесь сделать это проще.
2 ответа
Если вы хотите запустить python в Ubuntu, просто откройте терминал с помощью Ctrl — Alt — T и выполните эту команду
Тогда у вас будет интерактивный интерпретатор python, работающий в термине.
Я предполагаю, что вы хотите запускать python с USB-накопителя и использовать его в любом месте с системой Linux. Вы можете добиться этого путем загрузки портативного питона с этого сайта
Установить это на ваш USB-накопитель
Я цитирую с сайта
Портативный Python может быть установлен на любое запоминающее устройство USB, локальный жесткий диск или сетевое расположение. Можно установить несколько разных дистрибутивов Portable Python на одном USB-устройстве хранения (или на локальном жестком диске) и запускать их рядом. Это делает Portable Python идеальной средой для тестирования вашего кода с различными движками Python.
Затем запустите его непосредственно с USB-порта и запрограммируйте python