2014-11-03 67 views
3

我在github上有一个公共python项目。这只是为了在Windows上运行。 我想将它添加到PyPI中,使人们可以通过在pypi上从github提供python包

pip install mypackage 

安装它的存在来存储我在GitHub上包,而不是使用AWS S3存储的方法吗? 如果是,如何? 我也需要知道预期的格式是什么。 我是否应该制作一个包文件夹,并将mypackage-1.0.tar.gz放入其中,尽管这是为了Windows?

我已经读完了这一点:http://docs.python-guide.org/en/latest/shipping/packaging/

到目前为止,当我运行 PIP安装https://github.com/my_username/mypackage 我得到这个错误:

Downloading from URL https://github.com/my_username/mypackage Cleaning up... Exception: Traceback (most recent call last): File "C:\Python27\lib\site-packages\pip-1.5.6-py2.7.egg\pip\basecommand.py", line 122, in main status = self.run(options, args) File "C:\Python27\lib\site-packages\pip-1.5.6-py2.7.egg\pip\commands\install.py", line 278, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File "C:\Python27\lib\site-packages\pip-1.5.6-py2.7.egg\pip\req.py", line 1197, in prepare_files do_download, File "C:\Python27\lib\site-packages\pip-1.5.6-py2.7.egg\pip\req.py", line 1375, in unpack_url self.session, File "C:\Python27\lib\site-packages\pip-1.5.6-py2.7.egg\pip\download.py", line 582, in unpack_http_url unpack_file(temp_location, location, content_type, link) File "C:\Python27\lib\site-packages\pip-1.5.6-py2.7.egg\pip\util.py", line 627, in unpack_file and is_svn_page(file_contents(filename))): File "C:\Python27\lib\site-packages\pip-1.5.6-py2.7.egg\pip\util.py", line 210, in file_contents return fp.read().decode('utf-8') File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte

我也想通了,我必须写setup.py和setup.cfg然后我可以运行

python setup.py build 
python setup.py register 
>>Registering mypackage to http://pypi.python.org/pypi 
>>Server response (401): basic auth failed 

我不知道为什么注册失败。 也试过:

python setup.py sdist register upload 

这抱怨为: PyPi issues - Upload failed (401): You must be identified to edit package information 但是创建.pypirc并没有解决问题。 任何想法如何让我的包添加到pypi?

回答

4

我找到了一个正确清晰的文档:http://peterdowns.com/posts/first-time-with-pypi.html

我在下面列举以及步骤:

  • 寄存器的PyPI占
  • 把你的证件在一个文本文件.pypirc(你的窗口需要在终端中将.pypirc.txt重命名为.pypirc)
  • 设置HOME环境变量(可以在终端执行)

    set HOME =您要放置的路径.pypirc

  • 请确保您有正确的setup.py和setup.cfg文件。您需要阅读文档和示例项目。

  • 使https://github.com/my_username/mypackage/packages/0.1
  • 构建mypackage.zip运行

    蟒蛇setup.py注册-r pypitest

  • 上传到你的文件夹0.1 github上在github上

  • 标签它“

    git tag 0.1 -m”添加一个标签,以便我们可以把它放在PyPI上。“ 混帐推--tags起源主

  • 注册和上传:

    蟒蛇setup.py注册-r的PyPI

    蟒蛇setup.py sdist上传-r的PyPI

1

我有相同的401身份验证问题:根据docs,我将更改为[pypirc],这对我很有用

这是我的~/.pypirc文件:

[pypirc] 
index-servers = 
    pypi 
    pypitest 

[pypi] 
repository=https://pypi.python.org/pypi 

[pypitest] 
repository=https://testpypi.python.org/pypi 

[server-login] 
username:stav 
password:****