pip 打包发布(失败)

看这里 [python 打包发布](python 打包发布)

注册

先去 pypi.python.org 注册一个帐号

会问你 PGP Key ID, 先不用填

才发现我果然又注册过了, 但是密码果然记不住, 找回密码, 果断用 pp 生成一个

vim ~/.pypirc

[distutils]
index-servers = pypi

[pypi]
username:bigzhu

项目结构

参看 sampleproject

setup.py

setup.py 是最核心的文件, 放项目目录下, 定义了项目名称版本等主要信息.

主要结构是把函数 setup 引进来 from setuptools import setup, 然后调用这个函数, 调用参数说明在这里setup-args

把 setup.py 写好

打包

python setup.py bdist_wheel

会生成很多文件

注册

python setup.py register
running register
running egg_info
writing requirements to pp.egg-info/requires.txt
writing pp.egg-info/PKG-INFO
writing top-level names to pp.egg-info/top_level.txt
writing dependency_links to pp.egg-info/dependency_links.txt
writing entry points to pp.egg-info/entry_points.txt
reading manifest file 'pp.egg-info/SOURCES.txt'
writing manifest file 'pp.egg-info/SOURCES.txt'
running check
We need to know who you are, so please choose either:
 1. use your existing login,
 2. register as a new user,
 3. have the server generate a new password for you (and email it to you), or
 4. quit
Your selection [default 1]:
1
Username: bigzhu
Password:
Registering pp to https://upload.pypi.org/legacy/
Server response (410): This API is no longer supported, instead simply upload the file.

说 API 不可用了, 什么鬼

解决注册问题

https://stackoverflow.com/questions/40022710/how-am-i-supposed-to-register-a-package-to-pypi 说的改了, 还是不行

bigzhu:/Users/bigzhu/project_bz/pp/$ twine register dist/pp-1.0.0.tar.gz
Registering package to https://pypi.python.org/pypi
Registering pp-1.0.0.tar.gz
HTTPError: 400 Client Error: Invalid classifier "Intended Audience ::" for url: https://pypi.python.org/pypi

真是不知说什么了

这些文档太老了, 根本不用去注册了

打包 package

python setup.py sdist bdist_wheel

会在 dist 里生成一个 .tar.gz 文件

直接传, 告诉我没有权限

bigzhu:/Users/bigzhu/project_bz/pp/$ twine upload dist/*
Uploading distributions to https://pypi.python.org/pypi
Note: you are uploading to the old upload URL. It's recommended to use the new URL "https://upload.pypi.org/legacy/" or to leave the URL unspecified and allow twine to choose.
Uploading pp-1.0.0-py2-none-any.whl
HTTPError: 403 Client Error: You are not allowed to edit 'pp' package information for url: https://pypi.python.org/pypi

我也知道 pp 这名字一定是被用了的. 好糟心, 就没有简单清晰的文档告诉我该怎么做么?

洗把脸, 重来!

https://kinegratii.github.io/2017/04/25/python-project-ci-publish/