Tainan.py, Experience about package

Preview:

DESCRIPTION

Happy to share my experience in tainan.py :)

Citation preview

After Codingpackage 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

• Use YUM 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日星期日

Quick Guides

• Use setuptools and get easy_install

• Use PIP, use pip to install nearly everything

• Use Virtual Env to protect environment

• Buildout (with system dependency)

13年8月11日星期日