Visitors: 17882461

Latest Articles

Blogs

Python Wheels and AIX - Part 1 PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Michael Felt   

Getting started with python wheels on AIX


A Python wheel is a "pre-compiled" module for a platform. Pure-Python wheels are the easiest as most have been written to be portable with both Python2 and Python3. (This is likely to change real soon now as Python2 is reaching end-of-support in early 2020).

Wheels are really convienient when there are parts that need to be compiled (e.g., cffi needs a C compiler to build parts of it). As a wheel, these Pyhton modules can just be installed without the need for the compiler - pre-compiled! FTW!!

An additional advantage to wheels is the abililty to install pre-compiled packages in a virtual nvironment (created using the python module virtualenv). I add this because previously, as aixtools did package modules - pre-compiled! - but as installp packages. This has two drawbacks:
1) must be root to run installp
2) any pre-packaging in this form (RPM, installp, etc.)
means they can ONLY be installed in the SYSTEM Python environment.

Chapter 1 - Setup a virtualenv for safe testing

 

a) prepare SYSTEM python to support virtualenv and wheels

  • add virtualenv and wheel to system level python

  # pip3 install virtualenv wheel
  # pip3 install --upgrade pip # just to be sure
  # root@x066:[/]pip3 list
Package    Version
---------- -------
pip        19.3.1
setuptools 40.6.2
virtualenv 16.7.7
wheel      0.33.6

b) create virtual environment for a non-root user (e.g., michael)

  • new (non-root user)

  # mkuser michael

  • login and verify python3 environment

  $ michael@x066:[/home/michael]pip3 list
Package    Version
---------- -------
pip        19.3.1
setuptools 40.6.2
virtualenv 16.7.7
wheel      0.33.6

  • I am going to place my virtual environment in ${HOME}/pve

  $ virtualenv --help # for info about the arguments
  $ virtualenv --clear --never-download ${HOME}/pve
Not deleting /home/michael/pve/bin
Using base prefix '/opt'
New python executable in /home/michael/pve/bin/python3.6
Also creating executable in /home/michael/pve/bin/python
Installing setuptools, pip, wheel...
done.

  • Note: why say "--never-download"?

as we are testing our own wheels (actually, no "AIX" wheels exist in the PyPi system, so there is nothing to download. This is one of the other reasons I am getting started with this).

c) Verify and Test the virtual environment

  • start the virtual environment (update current shell environment)

  $ . pve/bin/activate
(pve) michael@x066:[/home/michael]

  • Note: virtualenv has made both pip and pip3 (and pip3.6)

(pve) michael@x066:[/home/michael]which pip
/home/michael/pve/bin/pip
(pve) michael@x066:[/home/michael]which pip3
/home/michael/pve/bin/pip3
(pve) michael@x066:[/home/michael]ls -l pve/bin/pip*
-rwxr-xr-x    1 michael  staff           235 Oct 31 07:31 pve/bin/pip
-rwxr-xr-x    1 michael  staff           235 Oct 31 07:31 pve/bin/pip3
-rwxr-xr-x    1 michael  staff           235 Oct 31 07:31 pve/bin/pip3.6

  • Our starting point does not have virtualenv!

(pve) michael@x066:[/home/michael]pip list
Package    Version
---------- -------
pip        19.3.1
setuptools 41.4.0
wheel      0.33.6

  • However, as non-root - we can update our environment

(pve) michael@x066:[/home/michael]pip install six
Collecting six
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: six
Successfully installed six-1.12.0
(pve) michael@x066:[/home/michael]id
uid=203(michael) gid=1(staff)

(pve) michael@x066:[/home/michael]pip list
Package    Version
---------- -------
pip        19.3.1
setuptools 41.4.0
six        1.12.0
wheel      0.33.6

  • And the system level python does NOT have six installed.

root@x066:[/]pip3 list
Package    Version
---------- -------
pip        19.3.1
setuptools 40.6.2
virtualenv 16.7.7
wheel      0.33.6


In closing

  • Have updated Python to include virtualenv and wheel
  • Have ensured that latest pip is installed (for debug!)
  • Have created a non-root virtualenv
  • Have modified (as non-root) the virtualenv

Coming up! (Part 2)

Getting started with wheels!

 
< Prev   Next >

Legacy PDFs

AIX 5.2
AIX 5.1