SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler offline
After Coding
package and distribute
13年8月11日星期日
TIM
• 3+Year TrendMicro
• Have my own company now
13年8月11日星期日
寫完Code以後
• 聚會都在講寫 Code.
• Code 寫完,痛苦就開始了
13年8月11日星期日
Distribute
13年8月11日星期日
Distribute Flavor
• Windows/Mac
• self contained
• 好大⼀一包,Appliance
13年8月11日星期日
Distribute Flavor
• linux based
• A Collection of self-contained unit
• Called Package
13年8月11日星期日
Pros
• Self Contained: Easy management for app
• Second, update is easier ( security fix )
13年8月11日星期日
Cons
• Appliance: update is hard
• Package: dependency hell
13年8月11日星期日
It depends
• Sublime in Mac uses systems’s python
• Dropbox always uses it’s own python
• It takes time....
13年8月11日星期日
Distribute Package
• System Package?
• Language Package?
13年8月11日星期日
RPM
自行代換 deb
13年8月11日星期日
RPM 做了什麼事?
• 跟系統深度整合
• /var /etc
• 升級套件, 智慧地保留備份 Config
• 有人幫你測⼀一整組 (也修過bug)
• 會用YUM 的人很多
13年8月11日星期日
Cheese Shop
• pypi
• A Center for python package
• we install python package from Cheese
Shop
13年8月11日星期日
我跟 Python 是好朋友
• sudo pip install django ?
• sudo pip install -r requirements.txt?
13年8月11日星期日
Don’t use sudo pip
• django 1.5 requires more setting or you
cannot runserver
• You may broken a lot of service such as
review board
13年8月11日星期日
Caution
• Don’t install your programing language’s
package into system’s
• UseYUM for system wide package
• Use virtual environment as developing
• avoid by:
• export
PIP_REQUIRE_VIRTUALENV=true
13年8月11日星期日
After finish your code
• How To Package to python package
• Package To RPM via python package
13年8月11日星期日
13年8月11日星期日
The confusing history
• distutils in stdlib is the core of package
• setuptools is an enhancement of distutils
• Distribute is a fork from setuptools
• Distribute is merged to setuptools o_O
• distutil is too basic and risky to refactor
• distutil2 is delayed.
13年8月11日星期日
13年8月11日星期日
setup.py
• 功能極多!
• 但是極好學
• 範例 == 所有 Python 的套件數量
13年8月11日星期日
setup.py sample
• from distutils.core import setup
• setup(
name=‘sample’, 	

py_modules=[‘foo.py’],
)
13年8月11日星期日
setup.py command
• python setup.py bdist_wininst
• # Create a wizard to install the package!
13年8月11日星期日
setup.py in realworld
• specify install_requires
• Read README.md
• execute git/hg to know version/tag info
13年8月11日星期日
how to create RPM?
• python setup.py bdist_rpm
• Or Find Linux Distribution’s guide and
Repo. don’t search “python rpm/deb
• Don’t write SPEC file directly.
13年8月11日星期日
Future
• Distutil2
• setup.cfg !!
13年8月11日星期日
some useful tips
• entrypoint::console_script
• python setup develop
• python setup sdist
• pip install -r requirements.txt
• pip freeze -r base.txt > dev_req.txt
• pip install -e <your local repo>
13年8月11日星期日
Reference
• http://aosabook.org/en/packaging.html
• http://wokslog.wordpress.com/2011/06/04/
distutils-diff/
• http://ziade.org/2010/02/18/python-
language-summit-summary-of-the-
packaging-track/
13年8月11日星期日
Quick Guides
• Use setuptools and get easy_install
• Use PIP, use pip to install nearly everything
• UseVirtual Env to protect environment
• Buildout (with system dependency)
13年8月11日星期日

Mais conteúdo relacionado

Destaque

Destaque (10)

Build Python CMS The Plone Way
Build Python CMS The Plone WayBuild Python CMS The Plone Way
Build Python CMS The Plone Way
 
Essential TDD @ pycontw2016
Essential TDD @ pycontw2016Essential TDD @ pycontw2016
Essential TDD @ pycontw2016
 
Guides To Analyzing WebKit Performance
Guides To Analyzing WebKit PerformanceGuides To Analyzing WebKit Performance
Guides To Analyzing WebKit Performance
 
Python Load Testing - Pygotham 2012
Python Load Testing - Pygotham 2012Python Load Testing - Pygotham 2012
Python Load Testing - Pygotham 2012
 
Introduce to Linux command line
Introduce to Linux command lineIntroduce to Linux command line
Introduce to Linux command line
 
Performance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-MechanizePerformance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-Mechanize
 
淺談Debian套件打包
淺談Debian套件打包淺談Debian套件打包
淺談Debian套件打包
 
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryA Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
PyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 TutorialPyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 Tutorial
 

Semelhante a Tainan.py, Experience about package (10)

Pymacs 初體驗
Pymacs 初體驗Pymacs 初體驗
Pymacs 初體驗
 
Getting Started with the Tools of Software Development
Getting Started with the Tools of Software DevelopmentGetting Started with the Tools of Software Development
Getting Started with the Tools of Software Development
 
2013 輔大資工 暑期宅學營 Drupal 
基礎應用與模組實作
2013 輔大資工 暑期宅學營 Drupal 
基礎應用與模組實作2013 輔大資工 暑期宅學營 Drupal 
基礎應用與模組實作
2013 輔大資工 暑期宅學營 Drupal 
基礎應用與模組實作
 
Node getting start
Node getting startNode getting start
Node getting start
 
Django deploy
Django deployDjango deploy
Django deploy
 
iOs app 101
iOs app 101iOs app 101
iOs app 101
 
2013 輔大資工 暑期宅學營 PhoneGap 跨平台任我玩,HTML5 無痛開發 App
2013 輔大資工 暑期宅學營  PhoneGap  跨平台任我玩,HTML5 無痛開發 App2013 輔大資工 暑期宅學營  PhoneGap  跨平台任我玩,HTML5 無痛開發 App
2013 輔大資工 暑期宅學營 PhoneGap 跨平台任我玩,HTML5 無痛開發 App
 
Git安裝
Git安裝Git安裝
Git安裝
 
Nimbus
NimbusNimbus
Nimbus
 
Pygments
PygmentsPygments
Pygments
 

Mais de Tim (文昌) (9)

Python的50道陰影
Python的50道陰影Python的50道陰影
Python的50道陰影
 
Frontend django, Django Web 前端探索
Frontend django, Django Web 前端探索Frontend django, Django Web 前端探索
Frontend django, Django Web 前端探索
 
Profile django
Profile djangoProfile django
Profile django
 
Introduction to protocol buffer
Introduction to protocol bufferIntroduction to protocol buffer
Introduction to protocol buffer
 
I18n
I18nI18n
I18n
 
Mock Introduction
Mock IntroductionMock Introduction
Mock Introduction
 
Ml weka
Ml wekaMl weka
Ml weka
 
Performance Enhancement Tips
Performance Enhancement TipsPerformance Enhancement Tips
Performance Enhancement Tips
 
pygame sharing pyhug
pygame sharing pyhugpygame sharing pyhug
pygame sharing pyhug
 

Tainan.py, Experience about package