audreyfeldroy / cookiecutter-pypackage

Cookiecutter template for a Python package.
BSD 3-Clause "New" or "Revised" License
4.26k stars 1.78k forks source link

Fix travis_pypi_setup.py #410

Open pydanny opened 6 years ago

pydanny commented 6 years ago

Description

Failed with this stack trace:

$ python travis_pypi_setup.py 
Traceback (most recent call last):
  File "travis_pypi_setup.py", line 131, in <module>
    main(args)
  File "travis_pypi_setup.py", line 116, in main
    public_key = fetch_public_key(args.repo)
  File "travis_pypi_setup.py", line 65, in fetch_public_key
    data = json.loads(urlopen(keyurl).read().decode())
  File "/usr/local/Cellar/python36/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/Cellar/python36/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python36/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/Cellar/python36/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python36/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python36/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

What I Did

python travis_pypi_setup.py

YAML Parsing Concerns for Windows Users

PyYAML is hard to get working on Windows and last update was in 2016. Raumel.yaml works better but can also have issues.

pydanny commented 6 years ago

@eliasdorneles, would you have a problem if I removed this module for now? Or moved it to a beta folder? The reason is we have an upcoming workshop and this is causing problems, especially for Windows users trying to get YAML libraries working.

pydanny commented 6 years ago

If anyone can get this working, including for Windows users, we'll put it back in.

eliasdorneles commented 6 years ago

Hi @pydanny ! No problem at all, please go ahead! Thanks for asking, but there was no need I was considering removing it myself, albeit for different reasons (it seems confusing first-time users). Good luck with workshop!

pydanny commented 6 years ago

Thanks @eliasdorneles!

pydanny commented 6 years ago

Tasks remaining:

elgertam commented 5 years ago

@pydanny I'd be willing to work on this issue. I have mostly resolved it for my fork cookiecutter-pipenv, and figure it might be good to contribute back upstream.

I have a few caveats for my solution.

First, in order to get the tests running, I use Pipenv to install all generated dependencies, including cryptography, in a virtualenv inside the baked test project. I assume you'd like to keep the existing requirements.txt and requirements_dev.txt dependency specification instead of Pipfile and Pipfile.lock.

Second, tests failed for pypy because of problems installing cryptography. I haven't had a chance dig into this issue, so for the time being, I've removed pypy support for my fork.

Third, the travis_pypy_setup.py script really needs a flag to differentiate between travis-ci.com and travis-ci.org. Since last year, Travis has requested that new repos (including open source) should run on com. I plan on adding a --com flag to the CLI options, but wanted to make a note.

Fourth, the v3 of the Travis API requires user authentication using the travis CLI in order to retrieve a public key. When using v2.1 (which is still supported), no authentication is necessary. If Travis deprecates the existing v2.1 API, users may have to use the travis CLI tool regardless, unless we implement the login & token functionality under the v3 API.

I can handle these last two items on my own when I have some more time. However, I'd like your thoughts on the first two. What is an acceptable way to get dependencies installed within the tests? And what are your thoughts on running tests on pypy?