https://bootstrap.pypa.io/get-pip.py
配置文件
存放位置
Per-user:
On Unix and macOS the configuration file is: $HOME/.pip/pip.conf
On Windows the configuration file is: %HOME%\pip\pip.ini
Inside a virtualenv:
On Unix and macOS the file is $VIRTUAL_ENV/pip.conf
On Windows the file is: %VIRTUAL_ENV%\pip.ini
Site-wide:
On Unix the file may be located in /etc/pip.conf
On macOS the file is: /Library/Application Support/pip/pip.conf
On Windows XP the file is: C:\Documents and Settings\All Users\Application Data\pip\pip.ini
On Windows 7 and later the file is hidden, but writeable at C:\ProgramData\pip\pip.ini
Site-wide configuration is not supported on Windows Vista
文件內(nèi)容
[global]
index-url = https://pypi.douban.com/simple/
安裝 --user
安裝時通過--user,安裝在用戶目錄下,例如
/home/uwsgi/.local/bin
發(fā)布
配置
需要一個setup.py文件,定義項目,執(zhí)行安裝命令
setup.cfg作為setup.py中命令的默認(rèn)選項
外加一個readme
manifest.in用來打包額外的文件
打包
源碼發(fā)布
python setup.py sdist
需要一個build步驟 即使發(fā)布的的代碼是純python 還需要一個build來產(chǎn)生安裝后的元數(shù)據(jù)。
wheels
可直接被安裝的
可分為三種wheel
universal wheel:需要是純python的程序,沒有額外編譯好的擴展,同時支持py2 py3
python setup.py bdist_wheel --universal
可以在setup.cfg中設(shè)置
[bdist_wheel]
universal=1
pure python wheels:也需要是純python 可以不兼容py2 py3
python setup.py bdist_wheel
會自動檢測python版本 可以使用2to3工具 兩次運行即可創(chuàng)建對應(yīng)版本的
platform wheels:不是純python的
python setup.py bdist_wheel
運行了上述的命令后 會在當(dāng)前項目根路徑下創(chuàng)建dist文件夾
上傳
需要注冊一個pypi賬號 可以在用戶路徑下創(chuàng)建.pypirc文件來填入用戶名密碼
[pypi]
username =
password =
twine upload dist/*