The state of packaging
tarek@critsend.com @tarek_ziade
The state of packaging Tarek Ziad tarek@critsend.com @tarek_ziade - - PowerPoint PPT Presentation
The state of packaging Tarek Ziad tarek@critsend.com @tarek_ziade Friday, February 19, 2010 Google Moderator http://tiny.cc/packaging13 Friday, February 19, 2010 Packaging sucks Friday, February 19, 2010 2007 We need to package and
tarek@critsend.com @tarek_ziade
http://tiny.cc/packaging13
Google Moderator
Friday, February 19, 2010We need to package and release our Python apps !
I’ll work on it !
Packaging ? mm.. Distutils or Setuptools should work
So how do we install
Sweet ! How do we remove it ? Are you kidding ? easy_install foo Manually But boss, you want a portable installer !
I’ll use virtualenv !
And create local installation with everything For every app sysadmins will hate me
But I want to improve packaging !
Let’s try to fix things from the root This will be my contribution to Python
Distutils Setuptools Developer PoV
site-packages
pip install foo easy_install foo
python setup.py install
User PoV
Friday, February 19, 2010Distutils Setuptools Pip Distribute PyPM Enstaller numpy.distutils 4suite.distutils Global PoV
Friday, February 19, 2010problems
Part 1
Friday, February 19, 2010Metadata for Python Software Package 1.1
Actual
Friday, February 19, 2010M e t a d a t a
e r s i
: 1 . N a m e : p i p V e r s i
: . 6 S u m m a r y : p i p i n s t a l l s p a c k a g e s . P y t h
p a c k a g e s . A n e a s y _ i n s t a l l r e p l a c e m e n t H
e
a g e : h t t p : / / p i p .
e n p l a n s .
g A u t h
: T h e O p e n P l a n n i n g P r
e c t A u t h
m a i l : p y t h
i r t u a l e n v @ g r
p s . g
l e . c
L i c e n s e : M I T K e y w
d s : e a s y _ i n s t a l l d i s t u t i l s s e t u p t
s e g g v i r t u a l e n v P l a t f
m : U N K N O W N C l a s s i fi e r : D e v e l
m e n t S t a t u s : : 4
e t a C l a s s i fi e r : I n t e n d e d A u d i e n c e : : D e v e l
e r s C l a s s i fi e r : L i c e n s e : : O S I A p p r
e d : : M I T L i c e n s e C l a s s i fi e r : T
i c : : S
t w a r e D e v e l
m e n t : : B u i l d T
s
Friday, February 19, 2010Project Distribution
python setup.py sdist
setup.py PKG-INFO
PyPI
PKG-INFO
Target system
PKG-INFO
(PEP 314) (PEP 314) (PEP 314)
setup(options)
Friday, February 19, 2010Project Distribution
python setup.py sdist
setup.py PKG-INFO
PyPI
PKG-INFO
Target system
PKG-INFO
(PEP 314) (PEP 314) (PEP 314)
setup(options) + requires.txt + .... + requires.txt + .... + ?????
Friday, February 19, 2010Metadata for Python Software Package 1.2
Accepted
Friday, February 19, 2010Requires-Dist: zope.interface (>3.5) Requires-Dist: PasteDeploy
Friday, February 19, 2010<, >, <=, >=, == and !=
Requires-Dist: zope.interface (>3.5, <4.0)
Friday, February 19, 2010Requires-Python: >2.4 Requires-Python: >=2.5, <2.7
Friday, February 19, 2010Requires-External: libxslt Requires-External: libpng (>=1.5)
Friday, February 19, 2010Provides-Dist: transaction Provides-Dist: ZODB
Zodb transaction
Friday, February 19, 2010Obsoletes-Dist: Setuptools
Friday, February 19, 2010Project-URL: Bug Tracker, http://bitbucket.org/tarek/distribute/issues Project-URL: Repository, http://bitbucket.org/tarek/distribute/src
Friday, February 19, 2010Description: This project provides powerful math functions |For example, you can use `sum()` to sum numbers: | |Example:: | | >>> sum(1, 2) | 3 |
Friday, February 19, 2010* with version specifier
Friday, February 19, 2010PyPI
MyProject.tar.gz
Pip
Metadata
python setup.py egg_info
local
python setup.py install get dependencies
Friday, February 19, 2010Requires-Dist: value (version); marker
platform.machine == 'i386'
sys.version_info[1])
PyPI
MyProject.tar.gz
Pip
local
python setup.py install get dependencies
+ metadata
Friday, February 19, 2010I love PEP 345 !
Friday, February 19, 2010Part 2
Friday, February 19, 2010Distutils’ LooseVersion StrictVersion Setuptools’ parse_version()
Result vary....
Friday, February 19, 2010Distutils Setuptools
>>> import pkg_resources >>> V =
pkg_resources.parse_version
>>> V('1.2rc1') < V('1.2') True >>> V('1.2-a1') < V('1.2') True >>> V('1.2a1') < V('1.2') True >>> import distutils.version >>> V = distutils.version.LooseVersion >>> V('1.2rc1') < V('1.2') False >>> V('1.2-a1') < V('1.2') False >>> V('1.2a1') < V('1.2') False
Friday, February 19, 2010Interoperable version comparison scheme
Accepted
Friday, February 19, 2010N.N[.N]+[{a|b|c|rc}N[.N]+][.postN][.devN]
major, minor, micro post- tag extra numbers pre- tag dev tag
N = integer
Friday, February 19, 20101 . a 1 < 1 . a 2 < 1 . b 2 < 1 . c 1 < 1 . < 1 . 1
Friday, February 19, 20101.0a1 < 1.0a2.dev345 < 1.0b1 < 1.0.dev432 < 1.0
development versions
Friday, February 19, 2010suggest_normalized_version(your scheme) PEP 386 compatible scheme
Friday, February 19, 2010>>> from verlib import NormalizedVersion >>> NormalizedVersion('1.2-a1') < NormalizedVersion('1.2') Traceback (most recent call last): ... raise IrrationalVersionError(s) verlib.IrrationalVersionError: 1.2-a1 >>> from verlib import suggest_normalized_version >>> suggest_normalized_version('1.2-a1') '1.2a1' >>> NormalizedVersion('1.2a1') < NormalizedVersion('1.2') True
Interoperable version tool
Friday, February 19, 2010PEP 386 @ PyPI distributions
90% 8% 3%
Direct match suggest_normalized_version No match
Friday, February 19, 2010We love PEP 386
Friday, February 19, 2010Part 3
Friday, February 19, 2010A database of installed packages
Aborted draft
Friday, February 19, 2010MyProject
PKG-INFO
Target system
(PEP 314)
site-packages
python setup.py install
MyProject.egg-info
file
Directory
Friday, February 19, 2010MyProject
PKG-INFO
Target system
(PEP 314)
+ requires.txt + ....
site-packages
MyProject.egg-info
PKG-INFO
easy_install MyProject
requires.txt SOURCES.txt
file
Directory
Friday, February 19, 2010MyProject
PKG-INFO
Target system
(PEP 314)
+ requires.txt + ....
site-packages
MyProject.egg-info
PKG-INFO
pip install MyProject
requires.txt SOURCES.txt installed_files.txt
file
Directory
Friday, February 19, 2010Interoperable .egg-info structure
Work in progress Replaces 262
Friday, February 19, 2010