SlideShare a Scribd company logo
Python-specific Packaging
setuptools, virtualenv, PyPUG (and a little bit of Conda)
Dale Visser
https://dalevisser.wordpress.com/
Outline
● PyPI, a.k.a., the Cheese Shop
– Setuptools
– Sdists, Eggs and Wheels
– pip and virtualenv
– Stats
– Security
● Conda
● Conclusion
Image credit: http://www.clker.com/clipart-cheese-wheel.html
from setuptools import setup, find_packages
setup(
    name = "HelloWorld",
    version = "0.1",
    packages = find_packages(),
    scripts = ['say_hello.py'],
    # Project uses reStructuredText, so ensure that the docutils get
    # installed or upgraded on the target machine
    install_requires = ['docutils>=0.3'],
    package_data = {
        # If any package contains *.txt or *.rst files, include them:
        '': ['*.txt', '*.rst'],
        # And include any *.msg files found in the 'hello' package, too:
        'hello': ['*.msg'],
    },
Setuptools (1/2)
Source: https://bitbucket.org/pypa/setuptools#basic-use
Setuptools (2/2)
    # metadata for upload to PyPI
    author = "Me",
    author_email = "me@example.com",
    description = "This is an Example Package",
    license = "PSF",
    keywords = "hello world example examples",
    url = "http://example.com/HelloWorld/",   # project home page, if any
    # could also include long_description, download_url, classifiers, etc.
)
Source: https://bitbucket.org/pypa/setuptools#basic-use
Python Distributions – 2 kinds
● Source Distributions or “sdists”
– python setup.py sdist
● Built Distributions (“bdists”)
– Eggs
● python setup.py bdist or
● python setup.py bdist_egg
– Wheels
● python setup.py bdist_wheel
● python setup.py bdist_wheel --universal
Egg and Wheel Distribution Formats
● Eggs - classic
– .egg – zip archive or folder containing
package and metadata
– .egg-info – metadata folder that sits alongside
installed package folder
– Lacks formal specification, but is well-
described: https://bit.ly/egg_format
● Wheels – pip and PyPI preferred
– .whl – zip archive containing package and metadata
– .dist-info – metadatafolder that sits alongside installed
package folder
– Relevant specifications:
●
PEP-376 - Database of Installed Python Distributions
● PEP-426 - Metadata for Python Software Packages 2.0
● PEP-427 - The Wheel Binary Package Format 1.0
Debian/Ubuntu Conventions
● PyPI packages go into a site­packages folder on the local system.
● Debian (and derivatives) also distribute some python packages via APT
(Advanced Package Tool).
– From https://wiki.debian.org/Python#Deviations_from_upstream
“Third party Python software installed from Debian packages goes into dist­
packages, not site­packages.”
● See /usr/local/lib/pythonX.Y/
Wheels
Platform Pure
Universal
pip and virtualenv demo
Online Resources
● Your first, best resource is this:
https://packaging.python.org/
– It is a collaborative resource created by the PyPI
people. E.g., find out about twine
● Also, you can “pip install” from git
repos!: https://bit.ly/pip_install_vcs
Image credit: http://www.clker.com/clipart-9829.html
Dependency stats – overall graph
● https://kgullikson88.github.io/blog/pypi-analysis.htm
● Biggest nodes
– requests
– zope
Stats: Measures of package importance
Stats - # other packages depended on
Stats (Development Communities)
1) Flask, bottle
2) Redis, tornado, pyzmq
3) Numpy, scipy, matplotlib, pandas
4) Testing/documentation packages
5) Django
6) Requests
7) Distribute (i.e., Zope)
8) Static website dev (e.g., pyyaml, jinja2)
9) Argparse, decorator, pyparsing, et al.
10) Various, most important: sqlalchemy
Keep your library dependencies secure
Have a look at OWASP Dependency Check.
● PyPI
– Looks at: Python source files (*.py); Package metadata files (PKG-INFO,
METADATA); Package Distribution Files (*.whl, *.egg, *.zip)
– Analyses using: Regex scan of Python source files for setuptools metadata;
Parse RFC822 header format for metadata in all other artifacts.
● Also scans archive files, .NET assmblies, autoconf, Maven/Nexus,
Cmake, PHP composer.lock, .jar, .war, NPM package.json, Nuget
*.nuspec, Ruby *.gemspec
Conda
● I've only played a little with it since the last meeting…
● Combines pip/virtualenv capabilities
● Allows to work with specific versions of Python,
independent of what's available from your OS
● For packages not on anaconda.org, its environments can
interoperate with “pip install”
● Perhaps someone else would like to give a talk? �
This work is licensed under the Creative
Commons Attribution-ShareAlike 4.0 International
License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-sa/4.0/ or
send a letter to Creative Commons, PO Box 1866,
Mountain View, CA 94042, USA.

More Related Content

PDF
Python packaging and dependency resolution
PPTX
A Big, Fast and Persistent Queue
PDF
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUG
PDF
Current State of Python Packaging
PDF
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
PDF
PuppetDB: A Single Source for Storing Your Puppet Data - PUG NY
PDF
Openwrt frontend backend
PDF
Pry at the Ruby Drink-up of Sophia, February 2012
Python packaging and dependency resolution
A Big, Fast and Persistent Queue
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUG
Current State of Python Packaging
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
PuppetDB: A Single Source for Storing Your Puppet Data - PUG NY
Openwrt frontend backend
Pry at the Ruby Drink-up of Sophia, February 2012

What's hot (20)

PDF
Openwrt startup
PPTX
Node collaboration - Exported Resources and PuppetDB
PPTX
Calling python from r
PPTX
How to deliver a Python project
PPTX
How Secure Are Docker Containers?
PDF
Solaris 11 base box for Vagrant using Packer
PPTX
Install hadoop in a cluster
PDF
Containers from scratch
PPT
download presentation
PDF
OpenStack for Centos
TXT
Instructions
PDF
PyDriller: Python Framework for Mining Software Repositories
ODP
Sfd hanoi2012 nguyen nang thang sfd-2012_chroot_apache
PDF
Py conkr 20150829_docker-python
PDF
MQTTS mosquitto - cheat sheet -
PDF
Accessing File-Specific Attributes on Steroids - EuroPython 2008
PDF
Complementing Docker with Puppet
PDF
Using Puppet to Create a Dynamic Network - PuppetConf 2013
PDF
Does Cowgirl Dream of Red Swirl?
TXT
Openstack
Openwrt startup
Node collaboration - Exported Resources and PuppetDB
Calling python from r
How to deliver a Python project
How Secure Are Docker Containers?
Solaris 11 base box for Vagrant using Packer
Install hadoop in a cluster
Containers from scratch
download presentation
OpenStack for Centos
Instructions
PyDriller: Python Framework for Mining Software Repositories
Sfd hanoi2012 nguyen nang thang sfd-2012_chroot_apache
Py conkr 20150829_docker-python
MQTTS mosquitto - cheat sheet -
Accessing File-Specific Attributes on Steroids - EuroPython 2008
Complementing Docker with Puppet
Using Puppet to Create a Dynamic Network - PuppetConf 2013
Does Cowgirl Dream of Red Swirl?
Openstack
Ad

Viewers also liked (16)

PDF
PyCon 2013 : Scripting to PyPi to GitHub and More
PDF
Introduction to the Python conda package manager
PDF
FHI360-Statement of Service-2
PPT
Ceip montserrat
DOCX
CV~Bayu Maindonald_20150518
PDF
Linda S Munro Graphic Designer
DOCX
Cb06 brarranco jorge
PPTX
Dr. Scott Farrell
PPT
Töötajate rahulolu tööga. Karolin Kõrreveski, Statistikaameti analüütik, Tall...
PDF
PPTX
Опис ромашки
PDF
Whitepaper IBM Qradar Security Intelligence
PPTX
Scaling Your Link Acquisition by Ehmz Vivas
PPTX
How to Penalty-Proof Your Website - Arvin Buising
PPTX
Воєнні дії на території україни в 1915 – 1917 роках
PyCon 2013 : Scripting to PyPi to GitHub and More
Introduction to the Python conda package manager
FHI360-Statement of Service-2
Ceip montserrat
CV~Bayu Maindonald_20150518
Linda S Munro Graphic Designer
Cb06 brarranco jorge
Dr. Scott Farrell
Töötajate rahulolu tööga. Karolin Kõrreveski, Statistikaameti analüütik, Tall...
Опис ромашки
Whitepaper IBM Qradar Security Intelligence
Scaling Your Link Acquisition by Ehmz Vivas
How to Penalty-Proof Your Website - Arvin Buising
Воєнні дії на території україни в 1915 – 1917 роках
Ad

Similar to Python-specific packaging (20)

PDF
Python+gradle
PPT
10 11-hart installing pythonsoftware
PDF
Pipfile, pipenv, pip… what?!
PDF
Princeton RSE: Building Python Packages (+binary)
PDF
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
PDF
Virtualenv
PDF
Packaging in Python? Don't Roll the Dice.
PDF
Effectively using Open Source with conda
PDF
Python packaging: how did we get here, and where are we going?
PDF
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
PDF
SFScon 21 - Duc Ly Vu - LastPyMile: a lightweight approach for securing Pytho...
PDF
Isolated development in python
PDF
Time travel: Let’s learn from the history of Python packaging!
PDF
Arbeiten mit distribute, pip und virtualenv
PDF
We Buy Cheese in a Cheese Shop
PPTX
E D - Environmental Dependencies in Python
PDF
Build and deploy scientific Python Applications
PDF
Using Python Packages - An Overview
PPTX
Run Python on windows
PPTX
Complete python toolbox for modern developers
Python+gradle
10 11-hart installing pythonsoftware
Pipfile, pipenv, pip… what?!
Princeton RSE: Building Python Packages (+binary)
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Virtualenv
Packaging in Python? Don't Roll the Dice.
Effectively using Open Source with conda
Python packaging: how did we get here, and where are we going?
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
SFScon 21 - Duc Ly Vu - LastPyMile: a lightweight approach for securing Pytho...
Isolated development in python
Time travel: Let’s learn from the history of Python packaging!
Arbeiten mit distribute, pip und virtualenv
We Buy Cheese in a Cheese Shop
E D - Environmental Dependencies in Python
Build and deploy scientific Python Applications
Using Python Packages - An Overview
Run Python on windows
Complete python toolbox for modern developers

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
assetexplorer- product-overview - presentation
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
history of c programming in notes for students .pptx
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Nekopoi APK 2025 free lastest update
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
L1 - Introduction to python Backend.pptx
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
17 Powerful Integrations Your Next-Gen MLM Software Needs
Patient Appointment Booking in Odoo with online payment
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Autodesk AutoCAD Crack Free Download 2025
How to Choose the Right IT Partner for Your Business in Malaysia
assetexplorer- product-overview - presentation
Wondershare Filmora 15 Crack With Activation Key [2025
history of c programming in notes for students .pptx
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Reimagine Home Health with the Power of Agentic AI​
Advanced SystemCare Ultimate Crack + Portable (2025)
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Nekopoi APK 2025 free lastest update
Oracle Fusion HCM Cloud Demo for Beginners
wealthsignaloriginal-com-DS-text-... (1).pdf

Python-specific packaging

Editor's Notes

  • #4: find_packages(...) can take arguments specifying what to include/exclude when finding packages entry_points = […] gives a way to generate .exe files on Windows (and .sh scripts on Linux ?) Scripts = […] ??? I think script outside the package to include. install_requires version spec language avail. Fairly intuitive. package_data - {…} specify data files to include that normally would be ignored
  • #10: Ensure reliable Internet connection Have simple demo package and setup.py, depending on something at PyPI Create a virtualenv named 'demo1' and activate Show how to 'setup.py install' Show how to use pip to create a wheelhouse Deactivate Create a virtualenv named 'demo2' and activate Install from wheelhouse.