pip

作者: xncode | 来源:发表于2017-08-23 10:39 被阅读0次

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

文件内容

[global]
index-url = https://pypi.douban.com/simple/

发布

配置

需要一个setup.py文件,定义项目,执行安装命令
setup.cfg作为setup.py中命令的默认选项
外加一个readme
manifest.in用来打包额外的文件

打包

源码发布

python setup.py sdist

需要一个build步骤 即使发布的的代码是纯python 还需要一个build来产生安装后的元数据。

wheels

可直接被安装的

可分为三种wheel

universal wheel:需要是纯python的程序,没有额外编译好的扩展,同时支持py2 py3

python setup.py bdist_wheel --universal

可以在setup.cfg中设置

[bdist_wheel]
universal=1

pure python wheels:也需要是纯python 可以不兼容py2 py3

python setup.py bdist_wheel

会自动检测python版本 可以使用2to3工具 两次运行即可创建对应版本的

platform wheels:不是纯python的

python setup.py bdist_wheel

运行了上述的命令后 会在当前项目根路径下创建dist文件夹

上传

需要注册一个pypi账号 可以在用户路径下创建.pypirc文件来填入用户名密码

[pypi]
username = 
password = 

twine upload dist/*

自动测试支持不同python版本

six python-future

二进制扩展

相关文章

网友评论

      本文标题:pip

      本文链接:https://www.haomeiwen.com/subject/yiwzhxtx.html