Shi*_*334 1 python ubuntu pypi pypiserver python-packaging
我正在使用 ubuntu,我已经创建了一个 python 包,它已经准备好在 PyPI 上注册,但是当我使用python setup.py register它时显示如下错误:
Server response (410): This API is no longer supported, instead simply upload the file.
Run Code Online (Sandbox Code Playgroud)
我知道这是找不到 .pypirc 文件的错误,但我不知道如何解决这个问题,因为我家没有 .pypirc 文件。我们不能创建 pypirc 文件吗?(只是问一下)。当我在 virtualenv 中使用 register 命令时也有一个不同的错误,我得到这个:
Server response (410): Gone (This API has been deprecated and removed from legacy PyPI in favor of using the APIs available in the new PyPI.org implementation of PyPI (located at https://pypi.org/). For more information about migrating your use of this API to PyPI.org, please see https://packaging.python.org/guides/migrating-to-pypi-org/#uploading. For more information about the sunsetting of this API, please see https://mail.python.org/pipermail/distutils-sig/2017-June/030766.html)
Run Code Online (Sandbox Code Playgroud)
这是我的 setup.py 文件
from setuptools import setup
setup(name='Utilitarian',
version='0.1',
description='little description',
url='https://github.com/Shivams334/Utilitarian.git',
author='Shivam Sharma',
author_email='shivams334@gmail.com',
license='MIT',
packages=['Utilitarian'],
zip_safe=False)
Run Code Online (Sandbox Code Playgroud)
请帮忙。谢谢你。
您需要.pypirc在您的HOME目录中自己创建文件
touch ~/.pypirc
Run Code Online (Sandbox Code Playgroud)
这个文件应该包含以下代码,把你的登录名和密码从pypi
[distutils]
index-servers =
pypi
pypitest
[pypitest]
repository = https://test.pypi.org/legacy/
username = <your username>
password = <your password>
[pypi]
repository = https://upload.pypi.org/legacy/
username = <your username>
password = <your password>
Run Code Online (Sandbox Code Playgroud)
因为您将登录名和密码放入此文件中,所以您可能需要更改它的权限,以便只有您可以读取和写入它。
chmod 600 ~/.pypirc
Run Code Online (Sandbox Code Playgroud)
之后你可以尝试注册你的包,顺便说一下,我强烈建议你使用twine库来加载你的包,只需安装它
pip install twine
Run Code Online (Sandbox Code Playgroud)
然后为您的包进行分发
python setup.py install
Run Code Online (Sandbox Code Playgroud)
此命令将创建一个dist文件夹,其中包含您的模块,然后注册您的项目(如有必要):
twine register dist/example-project-x.y.z.tar.gz
Run Code Online (Sandbox Code Playgroud)
之后,您可以使用以下命令将您的包上传到 pip
twine upload dist/*
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3968 次 |
| 最近记录: |