package/wadepypk$ ls __init__.py f1.py f2.py
f1.pypython
def show(): print("in pkg f.show()")
f2.pygit
def show(): print("in pkg f.show()")
init.pyui
__all__ = ['f1','f2']
上層目錄創建一個setup.pyurl
from distutils.core import setup setup( name='wadepypk', version='1.0', description='This is a test of the setup', author='huoty', author_email='no7david123@gmail.com', url='https://www.deng.io', packages=['wadepypk'] )
python setup.py build
python setup.py sdist
獲得一個wadepypk-1.0.tar.gzcode
tar -zxvf wadepypk-1.0.tar.gz cd wadepypk-1.0 python setup.py install
則安裝到本地的目錄裏面ip
固然也能夠在做爲git 項目直接upload 到git repo,而後再git clone 去分發源碼
python具體代碼調用it
>>> from wadepypk import f1,f2 >>> f1.show() in pkg f.show() >>> f2.show() in pkg f.show()
修改下源碼
f2.pyio
def show(): print("in pkg f2.show()")
從新 build, sdist ,install ,setupfunction
退出python 終端,否則仍然使用cache 裏面的1.0包版本
>>> from wadepypk import f1,f2 >>> f2.show() in pkg f2.show()
原來的"in pkg f.show()" 已經改成 "in pkg f2.show()"