pip

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/

安装 --user

安装时通过--user,安装在用户目录下,例如

/home/uwsgi/.local/bin

发布

配置

需要一个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

二进制扩展

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容