SlideShare una empresa de Scribd logo
1 de 22
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company,
for the United States Department of Energy’s National Nuclear Security Administration
under contract DE-AC04-94AL85000.
Installing Python Software Packages:
The Good, The Bad and the Ugly
William E. Hart
Sandia National Laboratories
wehart@sandia.gov
Overview
This talks focuses on installing on Python packages
– Installing Python itself is usually a no-brainer
The Good
1. Installing on Windows with an installer executable
2. Installing with Linux application utility
3. Installing a Python package from the PyPI repository
4. Installing a Python package from source
The Bad
5. Using a virtual environment to isolate package installations
6. Using an installer executable on Windows with a virtual environment
The Ugly
7. Installing a Python extension package from source
8. PyCoinInstall – Managing builds for Python extension packages
Slide 2
About Python
Recent releases:
– 2.5 Very stable
– 2.6 Very stable
– 2.7 Recently released. Supports transition to Python 3.x
– 3.0 Includes changes that are not backwards compatible.
– 3.1 Stable 3.x release. Resolves 3.0 performance issues.
Package management for 3.x is still a bit snarky. We’ll focus on examples for
2.x
Slide 3
Python Packages
Package distributions
– Include one or more *.py files
– May include compiled source files (e.g. C++)
– Include a top-level setup.py file to coordinate installation
Three categories:
– Pure-Python packages
• Only include Python *.py files
– Independent extension packages
• Include compiled source files only on standard system libraries
– Dependent extension packages
• Include compiled source files that rely on third-party libraries
Slide 4
The Good
Assumption: you have administrative privileges
– Windows administrator group
– Linux super-user
Impact: you can install Python in system directories!
Idea:
– Install packages in the system Python directories
• Specifically, the site-packages directory is used
– Can easily install pure-Python packages or pre-compiled extension
packages
Slide 5
Example 1
Installing on Windows with an installer executable
Steps:
1.Download installer executable from package website
2.Execute installer
Notes:
– This uses the registry to find the Python installation
– The installer can contain pre-compiled extension packages
• These may differ for 32- and 64-bit installations
– The installer will likely be specific to the Python version
– This may work OK for dependent extension packages if the dependent
libraries are stored in a standard location
Slide 6
Example 2
Installing with Linux application utility
Idea: use a standard Linux package manager
– Ubuntu (and other Debian-based Linux variants)
• apt-get install packagename
– Fedora
• yum install packagename
Notes:
– The package manager can install pre-compiled extension packages
– The package manager handles package dependencies automatically
– Not all Python packages are available within these managers
– It’s unclear whether these packages are updated frequently
Slide 7
Example 3
Installing a Python package from the PyPI repository
PyPI:
– A web-based service for hosting Python packages
– Includes some pre-compiled extension packages
– Several Python packages are used to install from PyPI
• setuptools, distribute, pip
Installing with pip:
– pip install packagename
Notes:
– The package manager handles package dependencies automatically
– Most Python packages are available from PyPI, including most releases
– PyPI does not include many pre-compiled extension packages
– The PyPI service has become a bit overloaded in the past year
– You need to specify the HTTP_PROXY environment to talk to proxy servers
Slide 8
Example 3 (cont)
Problem: pip is not a standard Python package!
Installing pip:
– wget http://peak.telecommunity.com/dist/ez_setup.py
– python ez_setup.py
– easy_install pip
Notes:
– pip is now generally recommended over setuptools and distribute
– The wget command is not a standard MS Windows utility
• Download from http://users.ugent.be/~bpuype/wget/
Slide 9
Example 4
Installing a Python package from source
Steps:
– Download package source from PyPI or project website
– Extract package from tarball or zipfile
– python setup.py install
Notes:
– This process avoids the need to install pip
– This is useful for packages that are not available on PyPI
– This installation process can build and install some extension packages
• Configuration of the compiler may be a problem
• Configuration of extension package dependencies is a problem
– This installation does not handle package dependencies
• Package dependencies may cause an install to fail
Slide 10
The Bad
Problem: users do not have administrative privileges
– This is not uncommon in industry
Problem: different users on a computer need different package versions
Idea:
– A user can create a virtual Python environment
– The user installs packages in this virtual Python directories
Impact:
– Users have complete control over their Python environment
• Can even have multiple environments (e.g. for developers)
– Can install both pure-Python packages or pre-compiled extension
packages
Slide 11
Virtual Python
Idea: create an isolated Python environment
virtualenv:
– Creates a directory structure that mimics the system Python installation
– Works on MS Windows, Linux and Mac OS
Installing virtualenv (with administrative privileges)
– Debian Linux
• apt-get install python-virtualenv
– Other
• wget http://peak.telecommunity.com/dist/ez_setup.py
• python ez_setup.py
• easy_install virtualenv
Slide 12
Virtual Python (cont)
Creating a virtual Python environment:
– virtualenv directory
Virtual Python executable:
– MS Windows: directory/Scripts/python.exe
– Linux: directory/bin/python
Notes:
– On MS Windows the executables are installed in the Scripts directory
• For simplicity, all subsequent examples will use the bin directory
– The setuptools package is installed in a virtual environment
• Can use the easy_install command to install packages
Example:
– directory/bin/easy_install pip
Slide 13
Virtual Python (cont)
Problem: setup a virtual environment without administrative privileges
vpy_install:
– Bootstrap a virtualenv installation from a script
Steps:
– wget http://doiop.com/pyutilib/vpy_install
– python vpy_install directory
Notes:
– Standard tools like setuptools and pip are installed by vpy_install
– The specified directory is a virtualenv Python environment
– On Linux, you can use a simpler command-line:
• vpy_install directory
– The –-site-packages option can be used to expose packages that are
installed in the system Python installation
• This is particularly useful when using precompiled extension packages,
which are installed in system Python directories
Slide 14
Example 5
Using a virtual environment to isolate package installations
Idea:
– Create a virtual python installation with vpy_install
– Install packages with pip
Example (Linux):
– wget http://doiop.com/pyutilib/vpy_install
– vpy_install mypy
– mypy/bin/pip install packagename
Notes:
– Within the virtual environment, pip is installed as an executable
• You do not need to execute it with the Python executable
Slide 15
Example 5 (cont)
Using a virtual environment to isolate package installations
Note: source package installations using a virtual Python executable are
installed in the virtual environment
Example (Linux):
– wget http://doiop.com/pyutilib/vpy_install
– vpy_install mypy
– cd packagename
– ../mypy/bin/python setup.py install
Slide 16
Example 6
Using an installer executable on Windows with a virtual environment
Problem:
– MS Windows installers use the system Python installation
– If a user does not have administrative privileges, then an installer cannot
be used directly!
Idea:
– “Install” the executable with the easy_install command
Example:
– easy_install.exe matplotlib-1.0.0.win32-py2.6.exe
Note: this only works if the executable was created by the Python distutils
package!
Slide 17
Example 6 (cont)
Using an installer executable on Windows with a virtual environment
Idea:
– Modify the MS Windows registry to register the virtual python executable
Steps:
1.Download the the_python.py script that is described at
http://doiop.com/nedbatchelder/register_python.html
2.Register the virtual python executable (as administrator)
• mypyScriptspython.exe the_python.py
1.Execute the MS Windows installer
2.Reregister the original python executable (as administrator)
Slide 18
The Ugly
Problem:
– you need to use an extension package that has dependencies
– prebuilt packages are not available
Observation:
– There is very little consistency between installation setup for different
packages
– Few packages use configuration management tools like autotools or
cmake
– Build instructions can be very different for different platforms
There are few options beyond diving deep into the package build process!
Slide 19
Example 7
Installing a Python extension package from source
Note: there is no standard way for doing this
Example: SciPy documentation
– General build instructions
– Separate instructions for Linux, Mac OS, Windows, and Solaris
Recommendations:
– Make sure that this package is going to be worth your time
– Don’t hesitate to ask the developer team for help
– Have patience ...
Slide 20
Example 8
PyCoinInstall – Managing builds for Python extension packages
Note: this script is a relatively new project within CoinBazaar
– https://projects.coin-or.org/CoinBazaar/wiki/Projects/PyCoinInstall
Idea:
– Create a virtual environment with virtualenv
– Define package installation with a simple plugin system
• Packages define download, build and/or install operations
– A user creates a simple configuration file to specify the packages that will be
installed
– The pci command is used to manage the installation
Notes:
– Current development is focused on COIN-OR related packages
– Current plugins are tailored for building under Linux
Slide 21
Final Thoughts
Installing and distributing pure-Python packages is quite easy.
Installing extension packages is much more difficult.
– Try to leverage pre-compiled extension packages!
Virtual Python environments offer a flexible paradigm for managing different
Python configurations
– These are worth using even if you have administrative privileges!
Slide 22

Más contenido relacionado

La actualidad más candente

Contributing to OpenStack
Contributing to OpenStackContributing to OpenStack
Contributing to OpenStackdevkulkarni
 
OSGi Enablement For Apache Tuscany
OSGi Enablement For Apache TuscanyOSGi Enablement For Apache Tuscany
OSGi Enablement For Apache TuscanyRaymond Feng
 
Uyuni, the solution to manage your IT infrastructure
Uyuni, the solution to manage your IT infrastructure Uyuni, the solution to manage your IT infrastructure
Uyuni, the solution to manage your IT infrastructure Pau Garcia Quiles
 
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...Anne Nicolas
 
Virtualenv
VirtualenvVirtualenv
VirtualenvWEBdeBS
 
Uyuni Community Hours 29.05.2020
Uyuni Community Hours 29.05.2020Uyuni Community Hours 29.05.2020
Uyuni Community Hours 29.05.2020Pau Garcia Quiles
 
Yocto Project introduction
Yocto Project introductionYocto Project introduction
Yocto Project introductionYi-Hsiu Hsu
 
Uyuni: Introduction & how to do systems management
Uyuni: Introduction & how to do systems managementUyuni: Introduction & how to do systems management
Uyuni: Introduction & how to do systems managementPau Garcia Quiles
 
Embedded Recipes 2017 - Long-Term Maintenance, or How to (Mis-)Manage Embedde...
Embedded Recipes 2017 - Long-Term Maintenance, or How to (Mis-)Manage Embedde...Embedded Recipes 2017 - Long-Term Maintenance, or How to (Mis-)Manage Embedde...
Embedded Recipes 2017 - Long-Term Maintenance, or How to (Mis-)Manage Embedde...Anne Nicolas
 
Kernel Recipes 2017 - Linux Kernel Release Model - Greg KH
Kernel Recipes 2017 - Linux Kernel Release Model - Greg KHKernel Recipes 2017 - Linux Kernel Release Model - Greg KH
Kernel Recipes 2017 - Linux Kernel Release Model - Greg KHAnne Nicolas
 
Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Justin James
 
Hudson@java one2010
Hudson@java one2010Hudson@java one2010
Hudson@java one2010InfraDNA
 
Introduction, deployment and hybrid clouds
Introduction, deployment and hybrid cloudsIntroduction, deployment and hybrid clouds
Introduction, deployment and hybrid cloudsFlavio Percoco Premoli
 
Flatpak and AppImage usage on openSUSE
Flatpak and AppImage usage on openSUSEFlatpak and AppImage usage on openSUSE
Flatpak and AppImage usage on openSUSEKukuh Syafaat
 
NLLUG 2012 - XPages Extensibility API - going deep!
NLLUG 2012 - XPages Extensibility API - going deep!NLLUG 2012 - XPages Extensibility API - going deep!
NLLUG 2012 - XPages Extensibility API - going deep!René Winkelmeyer
 
Yocto and IoT - a retrospective
Yocto and IoT - a retrospectiveYocto and IoT - a retrospective
Yocto and IoT - a retrospectiveOpen-RnD
 
Getting Started with EasyBuild - Tutorial Part 2
Getting Started with EasyBuild - Tutorial Part 2Getting Started with EasyBuild - Tutorial Part 2
Getting Started with EasyBuild - Tutorial Part 2inside-BigData.com
 

La actualidad más candente (20)

Contributing to OpenStack
Contributing to OpenStackContributing to OpenStack
Contributing to OpenStack
 
OSGi Enablement For Apache Tuscany
OSGi Enablement For Apache TuscanyOSGi Enablement For Apache Tuscany
OSGi Enablement For Apache Tuscany
 
Uyuni, the solution to manage your IT infrastructure
Uyuni, the solution to manage your IT infrastructure Uyuni, the solution to manage your IT infrastructure
Uyuni, the solution to manage your IT infrastructure
 
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
 
Uyuni Community Hours 29.05.2020
Uyuni Community Hours 29.05.2020Uyuni Community Hours 29.05.2020
Uyuni Community Hours 29.05.2020
 
Tizen platform-dev-tds14sh
Tizen platform-dev-tds14shTizen platform-dev-tds14sh
Tizen platform-dev-tds14sh
 
Yocto Project introduction
Yocto Project introductionYocto Project introduction
Yocto Project introduction
 
Uyuni: Introduction & how to do systems management
Uyuni: Introduction & how to do systems managementUyuni: Introduction & how to do systems management
Uyuni: Introduction & how to do systems management
 
Embedded Recipes 2017 - Long-Term Maintenance, or How to (Mis-)Manage Embedde...
Embedded Recipes 2017 - Long-Term Maintenance, or How to (Mis-)Manage Embedde...Embedded Recipes 2017 - Long-Term Maintenance, or How to (Mis-)Manage Embedde...
Embedded Recipes 2017 - Long-Term Maintenance, or How to (Mis-)Manage Embedde...
 
[OSS Upstream Training] 9 kirigami contribution_simulation
[OSS Upstream Training] 9 kirigami contribution_simulation[OSS Upstream Training] 9 kirigami contribution_simulation
[OSS Upstream Training] 9 kirigami contribution_simulation
 
Kernel Recipes 2017 - Linux Kernel Release Model - Greg KH
Kernel Recipes 2017 - Linux Kernel Release Model - Greg KHKernel Recipes 2017 - Linux Kernel Release Model - Greg KH
Kernel Recipes 2017 - Linux Kernel Release Model - Greg KH
 
Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...
 
Hudson@java one2010
Hudson@java one2010Hudson@java one2010
Hudson@java one2010
 
Introduction, deployment and hybrid clouds
Introduction, deployment and hybrid cloudsIntroduction, deployment and hybrid clouds
Introduction, deployment and hybrid clouds
 
AtoM feature development
AtoM feature developmentAtoM feature development
AtoM feature development
 
Flatpak and AppImage usage on openSUSE
Flatpak and AppImage usage on openSUSEFlatpak and AppImage usage on openSUSE
Flatpak and AppImage usage on openSUSE
 
NLLUG 2012 - XPages Extensibility API - going deep!
NLLUG 2012 - XPages Extensibility API - going deep!NLLUG 2012 - XPages Extensibility API - going deep!
NLLUG 2012 - XPages Extensibility API - going deep!
 
Yocto and IoT - a retrospective
Yocto and IoT - a retrospectiveYocto and IoT - a retrospective
Yocto and IoT - a retrospective
 
Getting Started with EasyBuild - Tutorial Part 2
Getting Started with EasyBuild - Tutorial Part 2Getting Started with EasyBuild - Tutorial Part 2
Getting Started with EasyBuild - Tutorial Part 2
 

Destacado

What does an online facilitator do?
What does an online facilitator do?What does an online facilitator do?
What does an online facilitator do?Carolina Piacenti
 
如何攻佔Hacker News前十名
如何攻佔Hacker News前十名如何攻佔Hacker News前十名
如何攻佔Hacker News前十名仁乾 陳
 
Does social media drive customer engagement?
Does social media drive customer engagement?Does social media drive customer engagement?
Does social media drive customer engagement?Ilona Hitel
 
4ตาราง ความสัมพันธ์loหน่วยการเรียนกับการใช้สื่อในคอมพิวเตอร์พกพา
4ตาราง  ความสัมพันธ์loหน่วยการเรียนกับการใช้สื่อในคอมพิวเตอร์พกพา4ตาราง  ความสัมพันธ์loหน่วยการเรียนกับการใช้สื่อในคอมพิวเตอร์พกพา
4ตาราง ความสัมพันธ์loหน่วยการเรียนกับการใช้สื่อในคอมพิวเตอร์พกพาชนิกานต์ ปั้นแก้ว
 
Search-based BI. Getting ready for the next wave of innovation in Business In...
Search-based BI. Getting ready for the next wave of innovation in Business In...Search-based BI. Getting ready for the next wave of innovation in Business In...
Search-based BI. Getting ready for the next wave of innovation in Business In...grauw
 
Community Management Overview
Community Management OverviewCommunity Management Overview
Community Management OverviewMatt Warburton
 
Taking Communities Offline
Taking Communities Offline Taking Communities Offline
Taking Communities Offline Matt Warburton
 
Knjiga o-dijeti-hrononutricija-najnovije
Knjiga o-dijeti-hrononutricija-najnovijeKnjiga o-dijeti-hrononutricija-najnovije
Knjiga o-dijeti-hrononutricija-najnovijeSrdjan Tomic
 
Presentation of the Czech Republic
Presentation of the Czech RepublicPresentation of the Czech Republic
Presentation of the Czech RepublicKateřina Pelánová
 
3ตารางการวิเคราะห์ความสัมพันธ์ผลการเรียนรู้กับตัวชี้วัดรายสัปดาห์
3ตารางการวิเคราะห์ความสัมพันธ์ผลการเรียนรู้กับตัวชี้วัดรายสัปดาห์3ตารางการวิเคราะห์ความสัมพันธ์ผลการเรียนรู้กับตัวชี้วัดรายสัปดาห์
3ตารางการวิเคราะห์ความสัมพันธ์ผลการเรียนรู้กับตัวชี้วัดรายสัปดาห์ชนิกานต์ ปั้นแก้ว
 
Desktop publishing (power point)
Desktop publishing (power point)Desktop publishing (power point)
Desktop publishing (power point)kuromi12
 

Destacado (20)

Polarræven
PolarrævenPolarræven
Polarræven
 
Powerpoint.
Powerpoint.Powerpoint.
Powerpoint.
 
Pipininspect
PipininspectPipininspect
Pipininspect
 
Asu pitchdecktemplate
Asu pitchdecktemplateAsu pitchdecktemplate
Asu pitchdecktemplate
 
Revitedjoints 130105160529-phpapp01
Revitedjoints 130105160529-phpapp01Revitedjoints 130105160529-phpapp01
Revitedjoints 130105160529-phpapp01
 
What does an online facilitator do?
What does an online facilitator do?What does an online facilitator do?
What does an online facilitator do?
 
如何攻佔Hacker News前十名
如何攻佔Hacker News前十名如何攻佔Hacker News前十名
如何攻佔Hacker News前十名
 
Does social media drive customer engagement?
Does social media drive customer engagement?Does social media drive customer engagement?
Does social media drive customer engagement?
 
4ตาราง ความสัมพันธ์loหน่วยการเรียนกับการใช้สื่อในคอมพิวเตอร์พกพา
4ตาราง  ความสัมพันธ์loหน่วยการเรียนกับการใช้สื่อในคอมพิวเตอร์พกพา4ตาราง  ความสัมพันธ์loหน่วยการเรียนกับการใช้สื่อในคอมพิวเตอร์พกพา
4ตาราง ความสัมพันธ์loหน่วยการเรียนกับการใช้สื่อในคอมพิวเตอร์พกพา
 
6รายชื่อคณะกรรมการเขียนแผน
6รายชื่อคณะกรรมการเขียนแผน6รายชื่อคณะกรรมการเขียนแผน
6รายชื่อคณะกรรมการเขียนแผน
 
Search-based BI. Getting ready for the next wave of innovation in Business In...
Search-based BI. Getting ready for the next wave of innovation in Business In...Search-based BI. Getting ready for the next wave of innovation in Business In...
Search-based BI. Getting ready for the next wave of innovation in Business In...
 
Gastos
GastosGastos
Gastos
 
Community Management Overview
Community Management OverviewCommunity Management Overview
Community Management Overview
 
Linkedin Groups Guide
Linkedin Groups GuideLinkedin Groups Guide
Linkedin Groups Guide
 
The Czech Republic
The Czech RepublicThe Czech Republic
The Czech Republic
 
Taking Communities Offline
Taking Communities Offline Taking Communities Offline
Taking Communities Offline
 
Knjiga o-dijeti-hrononutricija-najnovije
Knjiga o-dijeti-hrononutricija-najnovijeKnjiga o-dijeti-hrononutricija-najnovije
Knjiga o-dijeti-hrononutricija-najnovije
 
Presentation of the Czech Republic
Presentation of the Czech RepublicPresentation of the Czech Republic
Presentation of the Czech Republic
 
3ตารางการวิเคราะห์ความสัมพันธ์ผลการเรียนรู้กับตัวชี้วัดรายสัปดาห์
3ตารางการวิเคราะห์ความสัมพันธ์ผลการเรียนรู้กับตัวชี้วัดรายสัปดาห์3ตารางการวิเคราะห์ความสัมพันธ์ผลการเรียนรู้กับตัวชี้วัดรายสัปดาห์
3ตารางการวิเคราะห์ความสัมพันธ์ผลการเรียนรู้กับตัวชี้วัดรายสัปดาห์
 
Desktop publishing (power point)
Desktop publishing (power point)Desktop publishing (power point)
Desktop publishing (power point)
 

Similar a 10 11-hart installing pythonsoftware

Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesLarry Cai
 
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)Aaron Meurer
 
PyCourse - Self driving python course
PyCourse - Self driving python coursePyCourse - Self driving python course
PyCourse - Self driving python courseEran Shlomo
 
Using the pip package manager for Odoo
Using the pip package manager for OdooUsing the pip package manager for Odoo
Using the pip package manager for OdooOdoo
 
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014Daniel Reis
 
Python setup for dummies
Python setup for dummiesPython setup for dummies
Python setup for dummiesRajesh Rajamani
 
Effectively using Open Source with conda
Effectively using Open Source with condaEffectively using Open Source with conda
Effectively using Open Source with condaTravis Oliphant
 
5 minute intro to virtualenv
5 minute intro to virtualenv5 minute intro to virtualenv
5 minute intro to virtualenvamenasse
 
How to Install Odoo 17 on Ubuntu.pdf
How to Install Odoo 17 on Ubuntu.pdfHow to Install Odoo 17 on Ubuntu.pdf
How to Install Odoo 17 on Ubuntu.pdfCanditRoot
 
NI Package Manager
NI Package ManagerNI Package Manager
NI Package ManagerDMC, Inc.
 
469-Porting the build system of a commercial RCP Application from Europa to G...
469-Porting the build system of a commercial RCP Application from Europa to G...469-Porting the build system of a commercial RCP Application from Europa to G...
469-Porting the build system of a commercial RCP Application from Europa to G...gustavoeliano
 
Installing Software, Part 3: Command Line
Installing Software, Part 3: Command LineInstalling Software, Part 3: Command Line
Installing Software, Part 3: Command LineKevin OBrien
 
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUG
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUGWelcome to the Cheese Shop: setuptools, virtualenv and PyPUG
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUGdwvisser
 
Introduction To Python.pdf
Introduction To Python.pdfIntroduction To Python.pdf
Introduction To Python.pdfArpana Awasthi
 
Nh php may 2014 - composer
Nh php   may 2014 - composerNh php   may 2014 - composer
Nh php may 2014 - composerDavid Weingart
 
Yocto Project : Custom Embedded Linux Distribution
Yocto Project : Custom Embedded Linux DistributionYocto Project : Custom Embedded Linux Distribution
Yocto Project : Custom Embedded Linux Distributionemertxemarketing
 
Build and deploy scientific Python Applications
Build and deploy scientific Python Applications  Build and deploy scientific Python Applications
Build and deploy scientific Python Applications Ramakrishna Reddy
 
Ansible Workshop for Pythonistas
Ansible Workshop for PythonistasAnsible Workshop for Pythonistas
Ansible Workshop for PythonistasMihai Criveti
 
PyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 TutorialPyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 TutorialJustin Lin
 
Embedded linux build systems
Embedded linux build systems  Embedded linux build systems
Embedded linux build systems Mender.io
 

Similar a 10 11-hart installing pythonsoftware (20)

Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
 
PyCourse - Self driving python course
PyCourse - Self driving python coursePyCourse - Self driving python course
PyCourse - Self driving python course
 
Using the pip package manager for Odoo
Using the pip package manager for OdooUsing the pip package manager for Odoo
Using the pip package manager for Odoo
 
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
 
Python setup for dummies
Python setup for dummiesPython setup for dummies
Python setup for dummies
 
Effectively using Open Source with conda
Effectively using Open Source with condaEffectively using Open Source with conda
Effectively using Open Source with conda
 
5 minute intro to virtualenv
5 minute intro to virtualenv5 minute intro to virtualenv
5 minute intro to virtualenv
 
How to Install Odoo 17 on Ubuntu.pdf
How to Install Odoo 17 on Ubuntu.pdfHow to Install Odoo 17 on Ubuntu.pdf
How to Install Odoo 17 on Ubuntu.pdf
 
NI Package Manager
NI Package ManagerNI Package Manager
NI Package Manager
 
469-Porting the build system of a commercial RCP Application from Europa to G...
469-Porting the build system of a commercial RCP Application from Europa to G...469-Porting the build system of a commercial RCP Application from Europa to G...
469-Porting the build system of a commercial RCP Application from Europa to G...
 
Installing Software, Part 3: Command Line
Installing Software, Part 3: Command LineInstalling Software, Part 3: Command Line
Installing Software, Part 3: Command Line
 
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUG
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUGWelcome to the Cheese Shop: setuptools, virtualenv and PyPUG
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUG
 
Introduction To Python.pdf
Introduction To Python.pdfIntroduction To Python.pdf
Introduction To Python.pdf
 
Nh php may 2014 - composer
Nh php   may 2014 - composerNh php   may 2014 - composer
Nh php may 2014 - composer
 
Yocto Project : Custom Embedded Linux Distribution
Yocto Project : Custom Embedded Linux DistributionYocto Project : Custom Embedded Linux Distribution
Yocto Project : Custom Embedded Linux Distribution
 
Build and deploy scientific Python Applications
Build and deploy scientific Python Applications  Build and deploy scientific Python Applications
Build and deploy scientific Python Applications
 
Ansible Workshop for Pythonistas
Ansible Workshop for PythonistasAnsible Workshop for Pythonistas
Ansible Workshop for Pythonistas
 
PyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 TutorialPyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 Tutorial
 
Embedded linux build systems
Embedded linux build systems  Embedded linux build systems
Embedded linux build systems
 

Último

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Último (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

10 11-hart installing pythonsoftware

  • 1. Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear Security Administration under contract DE-AC04-94AL85000. Installing Python Software Packages: The Good, The Bad and the Ugly William E. Hart Sandia National Laboratories wehart@sandia.gov
  • 2. Overview This talks focuses on installing on Python packages – Installing Python itself is usually a no-brainer The Good 1. Installing on Windows with an installer executable 2. Installing with Linux application utility 3. Installing a Python package from the PyPI repository 4. Installing a Python package from source The Bad 5. Using a virtual environment to isolate package installations 6. Using an installer executable on Windows with a virtual environment The Ugly 7. Installing a Python extension package from source 8. PyCoinInstall – Managing builds for Python extension packages Slide 2
  • 3. About Python Recent releases: – 2.5 Very stable – 2.6 Very stable – 2.7 Recently released. Supports transition to Python 3.x – 3.0 Includes changes that are not backwards compatible. – 3.1 Stable 3.x release. Resolves 3.0 performance issues. Package management for 3.x is still a bit snarky. We’ll focus on examples for 2.x Slide 3
  • 4. Python Packages Package distributions – Include one or more *.py files – May include compiled source files (e.g. C++) – Include a top-level setup.py file to coordinate installation Three categories: – Pure-Python packages • Only include Python *.py files – Independent extension packages • Include compiled source files only on standard system libraries – Dependent extension packages • Include compiled source files that rely on third-party libraries Slide 4
  • 5. The Good Assumption: you have administrative privileges – Windows administrator group – Linux super-user Impact: you can install Python in system directories! Idea: – Install packages in the system Python directories • Specifically, the site-packages directory is used – Can easily install pure-Python packages or pre-compiled extension packages Slide 5
  • 6. Example 1 Installing on Windows with an installer executable Steps: 1.Download installer executable from package website 2.Execute installer Notes: – This uses the registry to find the Python installation – The installer can contain pre-compiled extension packages • These may differ for 32- and 64-bit installations – The installer will likely be specific to the Python version – This may work OK for dependent extension packages if the dependent libraries are stored in a standard location Slide 6
  • 7. Example 2 Installing with Linux application utility Idea: use a standard Linux package manager – Ubuntu (and other Debian-based Linux variants) • apt-get install packagename – Fedora • yum install packagename Notes: – The package manager can install pre-compiled extension packages – The package manager handles package dependencies automatically – Not all Python packages are available within these managers – It’s unclear whether these packages are updated frequently Slide 7
  • 8. Example 3 Installing a Python package from the PyPI repository PyPI: – A web-based service for hosting Python packages – Includes some pre-compiled extension packages – Several Python packages are used to install from PyPI • setuptools, distribute, pip Installing with pip: – pip install packagename Notes: – The package manager handles package dependencies automatically – Most Python packages are available from PyPI, including most releases – PyPI does not include many pre-compiled extension packages – The PyPI service has become a bit overloaded in the past year – You need to specify the HTTP_PROXY environment to talk to proxy servers Slide 8
  • 9. Example 3 (cont) Problem: pip is not a standard Python package! Installing pip: – wget http://peak.telecommunity.com/dist/ez_setup.py – python ez_setup.py – easy_install pip Notes: – pip is now generally recommended over setuptools and distribute – The wget command is not a standard MS Windows utility • Download from http://users.ugent.be/~bpuype/wget/ Slide 9
  • 10. Example 4 Installing a Python package from source Steps: – Download package source from PyPI or project website – Extract package from tarball or zipfile – python setup.py install Notes: – This process avoids the need to install pip – This is useful for packages that are not available on PyPI – This installation process can build and install some extension packages • Configuration of the compiler may be a problem • Configuration of extension package dependencies is a problem – This installation does not handle package dependencies • Package dependencies may cause an install to fail Slide 10
  • 11. The Bad Problem: users do not have administrative privileges – This is not uncommon in industry Problem: different users on a computer need different package versions Idea: – A user can create a virtual Python environment – The user installs packages in this virtual Python directories Impact: – Users have complete control over their Python environment • Can even have multiple environments (e.g. for developers) – Can install both pure-Python packages or pre-compiled extension packages Slide 11
  • 12. Virtual Python Idea: create an isolated Python environment virtualenv: – Creates a directory structure that mimics the system Python installation – Works on MS Windows, Linux and Mac OS Installing virtualenv (with administrative privileges) – Debian Linux • apt-get install python-virtualenv – Other • wget http://peak.telecommunity.com/dist/ez_setup.py • python ez_setup.py • easy_install virtualenv Slide 12
  • 13. Virtual Python (cont) Creating a virtual Python environment: – virtualenv directory Virtual Python executable: – MS Windows: directory/Scripts/python.exe – Linux: directory/bin/python Notes: – On MS Windows the executables are installed in the Scripts directory • For simplicity, all subsequent examples will use the bin directory – The setuptools package is installed in a virtual environment • Can use the easy_install command to install packages Example: – directory/bin/easy_install pip Slide 13
  • 14. Virtual Python (cont) Problem: setup a virtual environment without administrative privileges vpy_install: – Bootstrap a virtualenv installation from a script Steps: – wget http://doiop.com/pyutilib/vpy_install – python vpy_install directory Notes: – Standard tools like setuptools and pip are installed by vpy_install – The specified directory is a virtualenv Python environment – On Linux, you can use a simpler command-line: • vpy_install directory – The –-site-packages option can be used to expose packages that are installed in the system Python installation • This is particularly useful when using precompiled extension packages, which are installed in system Python directories Slide 14
  • 15. Example 5 Using a virtual environment to isolate package installations Idea: – Create a virtual python installation with vpy_install – Install packages with pip Example (Linux): – wget http://doiop.com/pyutilib/vpy_install – vpy_install mypy – mypy/bin/pip install packagename Notes: – Within the virtual environment, pip is installed as an executable • You do not need to execute it with the Python executable Slide 15
  • 16. Example 5 (cont) Using a virtual environment to isolate package installations Note: source package installations using a virtual Python executable are installed in the virtual environment Example (Linux): – wget http://doiop.com/pyutilib/vpy_install – vpy_install mypy – cd packagename – ../mypy/bin/python setup.py install Slide 16
  • 17. Example 6 Using an installer executable on Windows with a virtual environment Problem: – MS Windows installers use the system Python installation – If a user does not have administrative privileges, then an installer cannot be used directly! Idea: – “Install” the executable with the easy_install command Example: – easy_install.exe matplotlib-1.0.0.win32-py2.6.exe Note: this only works if the executable was created by the Python distutils package! Slide 17
  • 18. Example 6 (cont) Using an installer executable on Windows with a virtual environment Idea: – Modify the MS Windows registry to register the virtual python executable Steps: 1.Download the the_python.py script that is described at http://doiop.com/nedbatchelder/register_python.html 2.Register the virtual python executable (as administrator) • mypyScriptspython.exe the_python.py 1.Execute the MS Windows installer 2.Reregister the original python executable (as administrator) Slide 18
  • 19. The Ugly Problem: – you need to use an extension package that has dependencies – prebuilt packages are not available Observation: – There is very little consistency between installation setup for different packages – Few packages use configuration management tools like autotools or cmake – Build instructions can be very different for different platforms There are few options beyond diving deep into the package build process! Slide 19
  • 20. Example 7 Installing a Python extension package from source Note: there is no standard way for doing this Example: SciPy documentation – General build instructions – Separate instructions for Linux, Mac OS, Windows, and Solaris Recommendations: – Make sure that this package is going to be worth your time – Don’t hesitate to ask the developer team for help – Have patience ... Slide 20
  • 21. Example 8 PyCoinInstall – Managing builds for Python extension packages Note: this script is a relatively new project within CoinBazaar – https://projects.coin-or.org/CoinBazaar/wiki/Projects/PyCoinInstall Idea: – Create a virtual environment with virtualenv – Define package installation with a simple plugin system • Packages define download, build and/or install operations – A user creates a simple configuration file to specify the packages that will be installed – The pci command is used to manage the installation Notes: – Current development is focused on COIN-OR related packages – Current plugins are tailored for building under Linux Slide 21
  • 22. Final Thoughts Installing and distributing pure-Python packages is quite easy. Installing extension packages is much more difficult. – Try to leverage pre-compiled extension packages! Virtual Python environments offer a flexible paradigm for managing different Python configurations – These are worth using even if you have administrative privileges! Slide 22

Notas del editor

  1. SAND 2010-7908C