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

Feature suggestion: Show Warehouse URL after upload #459

Closed
bhrutledge opened this issue May 8, 2019 · 4 comments · Fixed by #472
Closed

Feature suggestion: Show Warehouse URL after upload #459

bhrutledge opened this issue May 8, 2019 · 4 comments · Fixed by #472

Comments

@bhrutledge
Copy link
Contributor

bhrutledge commented May 8, 2019

While following the packaging tutorial during the PyCon 2109 sprints, I thought a small enhancement would be to provide the web URL for the release.

For example:

$ twine upload --repository testpypi dist/*
Uploading distributions to https://test.pypi.org/legacy/
Uploading example_pkg_bhrutledge-0.0.3-py3-none-any.whl
100%|████████████████████████████████████| 5.60k/5.60k [00:00<00:00, 55.1kB/s]
Uploading example-pkg-bhrutledge-0.0.3.tar.gz
100%|████████████████████████████████████| 4.31k/4.31k [00:01<00:00, 4.26kB/s]

View at:
https://test.pypi.org/project/example-pkg-bhrutledge/0.0.3/
  1. Your operating system:
    macOS

  2. Version of python you are running:
    3.7.3

  3. How did you install twine?
    Forked repo

  4. Version of twine you have installed (include complete output of):
    twine version 1.13.0 (pkginfo: 1.5.0.1, requests: 2.21.0, setuptools: 41.0.1, requests-toolbelt: 0.9.1, tqdm: 4.31.1)

  5. Which package repository are you targeting?
    TestPyPI, PyPI

@bhrutledge
Copy link
Contributor Author

I'd be happy to submit a PR for this.

@bhrutledge bhrutledge changed the title Feature suggestion: show Warehouse URL after upload Feature suggestion: Show Warehouse URL after upload May 8, 2019
@theacodes
Copy link
Member

theacodes commented May 8, 2019 via email

@di di added the enhancement label May 8, 2019
@bhrutledge
Copy link
Contributor Author

I'm starting to dig into this, and I have a couple thoughts/questions about the approach.

As I understand it, a single upload can potentially include multiple releases, each with multiple PackageFile's. So, it seems the desired output is the set of unique release URLs for the uploaded files.

To get a release URL, it looks like we could derive it for PyPI/TestPyPI using the from the PackageFile metadata; something like:

class Repository:
    def url_for_package(self, package: PackageFile) -> str:
        meta = package.metadata_dictionary()
        return f"{self.url}/{meta['name']}/{meta['version']}"

Or, we could query the Warehouse API after the file is uploaded to get the official URLs. This seems more "correct" in the sense that it allows the URL format to change. However, it adds the complexity and time of an additional HTTP request. On the other hand, Twine already queries the API to determine if a package is uploaded; it seems like that code could possibly be refactored to serve this purpose.

Any suggestions before I go further?

@bhrutledge
Copy link
Contributor Author

I started working on this over the weekend. Hoping to submit a PR this week.

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

Successfully merging a pull request may close this issue.

3 participants