The Python community has been slowly evolving since the first Python packages were published in 2001, with more and more people coming to the Python ecosystem as a result.
In this article, we’ll cover the steps that we use to get a new Python package into a Docker container.
The goal is to be as minimal as possible and still be able to install and use the Python software on a wide variety of platforms.
The process of installing and using Python packages will be a bit different from the other methods we’ll outline in this article.
We’ll first take a look at how to get your first Python package in a container.
Installing a new version of Python¶ Python 2.7 and later are released in two flavors: Standard (SVN) and Python 2 and 3 (PIP).
When installing a new release, there are two major components: a package and a source code repository.
The package is a collection of Python source code that can be installed directly into a running Python virtual machine.
A source code package is not a Python binary, but it does contain code for a set of modules (a Python package includes a source tree for the Python package), which are bundled with the package.
The source code repositories are maintained by the Python Package Index (CPI), a group of volunteer maintainers.
The Python Package List (PPL) is a registry of Python packages, which can be searched by package names.
The PyPI site also contains a collection to track new versions of Python, including the latest and greatest versions.
Both packages are downloaded and installed as part of the Python installation.
Installs of Python 2 or later can be performed by running the pip install command in a command prompt.
The pip install is not required to install Python 2, as Python 2 is built from the same sources as Python 3.
However, it can be helpful if you’re building from the Python 3 source code, since it can provide an easy way to get Python 3 packages installed.
When installing Python 2 (or Python 3) from source, a special environment variable is set up for the python executable that will be executed if the Python 2 version of the package is installed.
The environment variable can be set to whatever value you’d like: setuptools_env=PATH=/usr/bin/python3 install The PyPi repository is not installed, but we’ll get there shortly.
The PPL repository is required.
This is where the actual Python binary comes from.
A PyPI package has a Python file named “__init__.py” inside the package directory.
This file contains a copy of the PyPi package, and it contains the PyPI binary.
The directory structure for a PyPi Package is stored in a PyPI file called the PyPip file.
PyPips contains a reference to the PyPUCL file, which is the Python binary itself.
The name PyPIP is set to the path to the source code folder that contains the Python code.
For example, the Py PIP file contains the code that will run in a virtual machine (the PyPUL file contains this code) when the PyPy module is installed: #!/usr/local/bin/_python3/include/pyPip.h import sys import time from pylons import app,py import argparse def install_source_code ( source_code_path ): “””Get a copy from PyPI’s PyPipp file.
Argparse takes a path as an argument.
The first argument is the directory to get the PyPMi source code file from, the second is the PyPKIN file.
pyPIP takes no parameters, so you can pass a number of them to get this result.
This should work on both Python 2/3 and Python 3.””” source_path = sys.argv[ 1 :] pyPip = argparse.
ArgumentParser( source_name = source_file , ** pyPips ) app = argparser.
Arguments( source = source, ** pyApp ) app.add_argument( “–version” , “–python-version” ) app