Portable python pip install

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Portable Python — No Installation Required!

oskaritimperi/portablepython

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Читайте также:  Decorators with arguments in python

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Portable Python — No Installation Required!

Have you ever had any problems installing multiple versions of Python on your machine?

Did you need multiple Python patch releases on your machine for some reason at the same time?

You uninstalled Python but it still showed up in installed apps?

If you answered yes at least once, then this project will have you covered!

This project contains a bunch of Python releases packaged in zip archives. The archives are created from files installed by the official Python installer, nothing else. Each version will have a 32-bit and 64-bit version available.

A normal Python installation can be configured to have a Scripts directory that contains pip and easy_install scripts that you can invoke directly.

The portable zip file does not contain this directory. If you need it, it is easy to recreate with the ensurepip package.

First, you need to uninstall pip and setuptools:

python -m pip uninstall setuptools pip 

Now you can run the ensurepip package to install pip and setuptools and to create the scripts:

python -m ensurepip --default-pip 

Make sure that the Python you are invoking, is the correct one! You can do this for example by specifying the full path to the Python executable when entering the commands above.

About

Portable Python — No Installation Required!

Источник

How to install portable-python via python pip

When you know about this project and you want to new install portable-python to support your project or you get trouble as ModuleNotFoundError: No module named «portable-python» or ImportError: cannot import name «portable-python» in your project, let follow this tutorial to install portable-python

Installation:

Step 1: First, ensure you installed pip in your os, to check pip has been installed on your computer

Ensure pip, setuptools, and wheel are up to date:

py -m pip install --upgrade pip setuptools wheel
python3 -m pip install --upgrade pip setuptools wheel

Optional — If you want to install

— Install virtualenv — if you installed it, please ignore

py -m pip install --user virtualenv

— Create a virtual environment

py -m venv test_portable-python_env

— Active the virtual environment

test_portable-python_env\Scripts\active

— Install virtualenv — if you installed it, please ignore

— Create a virtual environment

python3 -m venv test_portable-python_env

— Active the virtual environment

source test_portable-python_env/bin/active

Step 2: OK, now, let flow below content to start the installation portable-python

To install portable-python on Windows(CMD):

py -m pip install portable-python

To install portable-python on Unix/macOs:

pip install portable-python

Step 3: If you want to install a specific portable-python version, add == to the end command line

pip install portable-python==1.2.4

Please see the version list below table:

py -m pip install portable-python==1.5.5
pip install portable-python==1.5.5
py -m pip install portable-python==1.5.4
pip install portable-python==1.5.4
py -m pip install portable-python==1.5.3
pip install portable-python==1.5.3
py -m pip install portable-python==1.5.2
pip install portable-python==1.5.2
py -m pip install portable-python==1.5.1
pip install portable-python==1.5.1
py -m pip install portable-python==1.5.0
pip install portable-python==1.5.0
py -m pip install portable-python==1.4.5
pip install portable-python==1.4.5
py -m pip install portable-python==1.4.4
pip install portable-python==1.4.4
py -m pip install portable-python==1.4.3
pip install portable-python==1.4.3
py -m pip install portable-python==1.4.2
pip install portable-python==1.4.2
py -m pip install portable-python==1.4.1
pip install portable-python==1.4.1
py -m pip install portable-python==1.4.0
pip install portable-python==1.4.0
py -m pip install portable-python==1.3.10
pip install portable-python==1.3.10
py -m pip install portable-python==1.3.9
pip install portable-python==1.3.9
py -m pip install portable-python==1.3.8
pip install portable-python==1.3.8
py -m pip install portable-python==1.3.7
pip install portable-python==1.3.7
py -m pip install portable-python==1.3.6
pip install portable-python==1.3.6
py -m pip install portable-python==1.3.5
pip install portable-python==1.3.5
py -m pip install portable-python==1.3.4
pip install portable-python==1.3.4
py -m pip install portable-python==1.3.3
pip install portable-python==1.3.3
py -m pip install portable-python==1.3.2
pip install portable-python==1.3.2
py -m pip install portable-python==1.3.1
pip install portable-python==1.3.1
py -m pip install portable-python==1.3.0
pip install portable-python==1.3.0
py -m pip install portable-python==1.2.9
pip install portable-python==1.2.9
py -m pip install portable-python==1.2.8
pip install portable-python==1.2.8
py -m pip install portable-python==1.2.7
pip install portable-python==1.2.7
py -m pip install portable-python==1.2.6
pip install portable-python==1.2.6
py -m pip install portable-python==1.2.5
pip install portable-python==1.2.5
py -m pip install portable-python==1.2.4
pip install portable-python==1.2.4

Step 4: Otherwise, you can install portable-python from local archives:

Download the distribution file from portable-python-1.5.5.tar.gz or the specific portable-python version in the below list of distribution

After that, install by command:

Источник

portable-python 1.7.0

Portable-Python is a CLI (and a python library) for compiling python binaries from source than can be decompressed in any folder, and used from there without further ado (ie: no need to run an “installer”).

Motivation

The idea here is to allow for automated systems to:

  • Easily obtain a python binary, that can be used in sandboxes / workstations / laptops / instances…
  • Inspect any python installation, and point out how portable it is, which shared or non-standard libraries it is using

Installation

portable-python is a regular python CLI, it can be installed with:

pickley install portable-python portable-python --help portable-python inspect /usr/bin/python3
pipx install portable-python portable-python inspect /usr/bin/python3

Using pip install (a CI builder would probably do this):

/usr/bin/python3 -mvenv /tmp/pp /tmp/pp/bin/python -mpip install portable-python /tmp/pp/bin/portable-python --help /tmp/pp/bin/portable-python inspect /usr/bin/python3

Supported operating systems

Portable python binaries can be built for Linux and MacOS (Intel/M1/M2).

Currently Windows is NOT supported, contributions are welcome.

Python binaries can be produced as “portable” (statically linked, can run from any folder where the binary is unpacked in), or with a —prefix (build targeted to live in a pre-determined folder, like /apps/pythonM.m )

Building a portable cpython

Once portable-python is installed:

cd some-temp-folder portable-python build 3.9.7 ls -l dist/cpython-3.9.7-macos-arm64.tar.gz
tar -C ~/tmp/versions/ -xf dist/cpython-3.9.7-macos-arm64.tar.gz ls -l ~/tmp/versions/
~/tmp/versions/3.9.7/bin/python --version

Note that you can use —dryrun mode to inspect what would be done without doing it:

$ portable-python --dryrun build 3.9.7 INFO selected: xz openssl gdbm (3 modules) xz:5.2.5 openssl:1.1.1k gdbm:1.18.1 INFO Platform: macos-x86_64 . -------------- -- xz:5.2.5 -- -------------- Would download https://tukaani.org/xz/xz-5.2.5.tar.gz Would untar build/sources/xz-5.2.5.tar.gz -> build/components/xz INFO env PATH=build/deps/bin:/usr/bin:/bin INFO env MACOSX_DEPLOYMENT_TARGET=10.14 Would run: ./configure --prefix=build/deps --enable-shared=no --enable-static=yes . . ------------------- -- cpython:3.9.7 -- ------------------- Would download https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tar.xz Would untar build/sources/Python-3.9.7.tar.xz -> build/components/cpython . Would run: ./configure --prefix=/ppp-marker/3.9.7 --enable-optimizations . Would run: /usr/bin/make Would run: /usr/bin/make install DESTDIR=build . Would tar build/3.9.7 -> dist/cpython-3.9.7-macos-x86_64.tar.gz

Library

Portable Python can be used as a python library to invoke builds, or inspect an installation.

Invoke a build from python code:

from portable_python import BuildSetup setup = BuildSetup("cpython:3.9.7") setup.compile()

Invoke an inspection from python code:

from portable_python.inspector import PythonInspector inspector = PythonInspector("/usr/bin/python3") print(inspector.represented()) problem = inspector.full_so_report.get_problem(portable=True) if problem: print("oops, it is not portable!: %s" % problem)

From source, contributions welcome!:

git clone https://github.com/codrsquad/portable-python.git cd portable-python tox -e venv .venv/bin/portable-python --help .venv/bin/portable-python inspect /usr/bin/python3 tox -e py39 tox -e style

Build folder structure

portable-python uses this file structure (build/ and dist/ folders configurable):

build/ ppp-marker/3.9.7/ # Full installation (after build completes) components/ # Builds of statically compiled extension modules are here deps/ # --prefix=. /deps passed to all component ./configure scripts sources/ openssl-1.1.1k.tar.gz # Downloaded artifacts (downloaded only once) dist/ cpython-3.9.7-macos-arm64.tar.gz # Ready-to-go portable binary tarball

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
  • No patches: C compilation is done as simply as possible without modifying the upstream source code. Rely solely on the 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).
  • 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)
  • 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

    Источник

Оцените статью