3
votes

I have a public python project on github. It's is only meant to be run on windows. I'd like to add it to pypi so that people can install it via

pip install mypackage

Is there a way to store my package on github instead of using an aws s3 bucket? If yes, how? I need to also know what's the expected format. Am I supposed to make a package folder and put mypackage-1.0.tar.gz in it eventhough this is meant for windows?

I've already read this: http://docs.python-guide.org/en/latest/shipping/packaging/

so far, when I run pip install https://github.com/my_username/mypackage I get this error:

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

I also figured out that I must write setup.py and setup.cfg and then I can run

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

I do not know why the registration fails. Also tried:

python setup.py sdist register upload

which complains as in: PyPi issues - Upload failed (401): You must be identified to edit package information but creating .pypirc did not fix the problem. Any ideas how to get my package added to pypi?

2

2 Answers

4
votes

I found a correct clear documentation: http://peterdowns.com/posts/first-time-with-pypi.html

I list the steps below as well:

  • register for pypi account
  • put your credentials in a text file .pypirc (on windows you need to rename .pypirc.txt to .pypirc in the terminal)
  • set the HOME environment variable (you can do it in the terminal)

    set HOME=path-to-the-directory where you put .pypirc

  • make sure you have a correct setup.py and setup.cfg file. You need to read the docs and sample projects.

  • make https://github.com/my_username/mypackage/packages/0.1
  • build mypackage.zip by running

    python setup.py register -r pypitest

  • upload it to you 0.1 folder on github

  • tag it in github

    git tag 0.1 -m "Adds a tag so that we can put this on PyPI." git push --tags origin master

  • register and upload:

    python setup.py register -r pypi

    python setup.py sdist upload -r pypi

1
votes

I had the same 401 authentication problem: I changed [distutils] to [pypirc] as per the docs and this worked for me.

Here is my ~/.pypirc file:

[pypirc]
index-servers =
    pypi
    pypitest

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

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

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