Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--repository-url test.pypi.org has no effect #269

Closed
astrojuanlu opened this issue Aug 29, 2017 · 6 comments · Fixed by #325
Closed

--repository-url test.pypi.org has no effect #269

astrojuanlu opened this issue Aug 29, 2017 · 6 comments · Fixed by #325
Assignees
Labels

Comments

@astrojuanlu
Copy link

I just tried to do a test upload to https://test.pypi.org/ (which I assumed is the equivalent of https://testpypi.python.org/pypi) but it got uploaded to https://pypi.org/ instead. Is this a Twine bug?

$ twine upload dist/* --repository-url test.pypi.org
Uploading distributions to https://upload.pypi.org/legacy/
Enter your username: JuanLuisCano
Enter your password: 
Uploading poliastro-0.7.dev0-py3-none-any.whl
Uploading poliastro-0.7.dev0.tar.gz
@astrojuanlu
Copy link
Author

Reading this rant:

https://gist.github.com/boppreh/ac7522b3a4ac46b4f6010eecddc57f21

I found that the correct URL is https://test.pypi.org/legacy/. So this is just a documentation/timing issue, I suppose. I left the decision to close this to the maintainers.

@di
Copy link
Member

di commented Dec 7, 2017

This behavior is a bit confusing to me as well:

With nothing in .pypirc, it just fails, which is OK (even though it's talking about the --repository flag when I used the --repository-url flag):

$ twine upload --repository-url foo.bar dist/whatever.tar.gz
KeyError: Missing 'pypi' section from the configuration file
or not a complete URL in --repository.
Maybe you have a out-dated '~/.pypirc' format?
more info: https://docs.python.org/distutils/packageindex.html#pypirc

However with a [pypi] section in .pypirc:

[pypi]
username: di

It attempts to upload to pypi.org:

$ twine upload --repository-url foo.bar dist/whatever.tar.gz
Uploading distributions to https://upload.pypi.org/legacy/
Enter your password: 

Where I would expect it to just fail and complain about an incomplete URL.

@brainwane
Copy link
Contributor

I'm looking into this. This comment is basically a note to myself as I try to figure out more about the issue and fix it:

brainwane added a commit that referenced this issue Mar 18, 2018
@brainwane
Copy link
Contributor

I can still reproduce this on git master.

twine.upload.upload() calls get_repository_from_config in a way that makes me suspicious. I think we aren't actually preferring the command-line repo URL properly over the special-cased default pypi repo.

I have a WIP branch where I change this by making us far less tolerant of .pypirc files that have no explicit distutils or index-server configuration. You can see in it how this alters our treatment of a number of edge cases (I haven't yet fixed it up to pass test_get_config_no_distutils and test_get_config_deprecated_pypirc). This probably isn't quite the direction we want to go in, since there are probably tens or hundreds of thousands of .pypirc files working right now that do not have the distutils bit at the top. Instead I'm leaning toward changing

    else:
        repositories = ["pypi"]

from utils.py so we do some more nuanced checking of, for instance, whether there's a repository-url provided via CLI.

brainwane added a commit that referenced this issue Mar 18, 2018
Check for repository URL that has no protocol prefix and
raise exception, asking user for https:// or http:// URL.

Assume the user wants to upload to PyPI if there's
no conflicting repository URL given on the command line
AND there's a `pypi` section in .pypirc. Remove assumption
that a 'pypirc' section in .pypirc should override CLI argument.

Fixes #269.
brainwane added a commit that referenced this issue Mar 18, 2018
Check for repository URL that has no protocol prefix and
raise exception, asking user for https:// or http:// URL.

Assume the user wants to upload to PyPI if there's
no conflicting repository URL given on the command line
AND there's a `pypi` section in .pypirc. Remove assumption
that a 'pypi' section in .pypirc should override CLI argument.

Fixes #269.
brainwane added a commit that referenced this issue Mar 18, 2018
Check for repository URL that has no protocol prefix and
raise exception, asking user for https:// or http:// URL.

Assume the user wants to upload to PyPI if there's
no conflicting repository URL given on the command line
AND there's a `pypi` section in .pypirc. Remove assumption
that a 'pypi' section in .pypirc should override CLI argument.

Fixes #269.
@Addicted-to-coding
Copy link

I am able to successfully upload my package using twine upload dist/*.

However, when I try using TestPyPI with the command: twine upload --repository testpypi dist/*, I get the following error:

InvalidConfiguration: Missing 'testpypi' section from the configuration file
or not a complete URL in --repository-url.
Maybe you have an out-dated '~/.pypirc' format?
more info: https://packaging.python.org/specifications/pypirc/

How can I fix this?

@bhrutledge
Copy link
Contributor

@Addicted-to-coding Can you share the contents of your ~/.pypirc file? Be sure to remove any passwords/tokens.

Also, what's the output of twine --version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants