最近阅读一本python的书,head first python ,里面有讲到如何制作python包,并发表到pypi上,但是使用的是linux系统。win系统如何做呢?
其实,相对来说,很简单。但是又很麻烦。
1、制作两个文件。
setup.py文件,setup.py的相关参数:
Meta-Data | Description | Value | Notes |
---|---|---|---|
name | name of the package | short string | (1) |
version | version of this release | short string | (1)(2) |
author | package author’s name | short string | (3) |
author_email | email address of the package author | email address | (3) |
maintainer | package maintainer’s name | short string | (3) |
maintainer_email | email address of the package maintainer | email address | (3) |
url | home page for the package | URL | (1) |
description | short, summary description of the package | short string | |
long_description | longer description of the package | long string | (5) |
download_url | location where the package may be downloaded | URL | (4) |
classifiers | a list of classifiers | list of strings | (4) |
platforms | a list of platforms | list of strings | |
license | license for the package | short string | (6) |
两个文件的名字要一致。
2、进入cmd,用python setup.py sdist 命令制作python包;
可以使用python setup.py --help-commands
查看setup.py相关参数:
Standard commands:
build build everything needed to install
build_py "build" pure Python modules (copy to build directory)
build_ext build C/C++ extensions (compile/link to build directory)
build_clib build C/C++ libraries used by Python extensions
build_scripts "build" scripts (copy and fixup #! line)
clean clean up temporary files from 'build' command
install install everything from build directory
install_lib install all Python modules (extensions and pure Python)
install_headers install C/C++ header files
install_scripts install scripts (Python or otherwise)
install_data install data files
sdist create a source distribution (tarball, zip file, etc.)
register register the distribution with the Python package index
bdist create a built (binary) distribution
bdist_dumb create a "dumb" built distribution
bdist_rpm create an RPM distribution
bdist_wininst create an executable installer for MS Windows
check perform some checks on the package
upload upload binary package to PyPI
关键问题是,会出现这样一个错误,就不能继续下去了。找了很多种解决办法, 仍然不行
使用python setup.py bdist可以生成相应的包,我在本地是可以安装到自己的python上了,并且可以用import 调用,但是似乎不能用pip 安装。
等有时间在来解决这个问题。打住这个问题,以后再来解决。去学习下如何用python制作APP。