Distribution latest version permalink?
Hello, Knowing a distribution name, I'd like to download its latest release file - as a single step, for easy shell scripting. Is that possible? For example: https://pypi.python.org/pypi/dry/ gives a link to https://pypi.python.org/packages/source/d/dry/dry-0.0.4.tar.gz . Any chance to have a URL like https://pypi.python.org/packages/source/d/dry/dry.tar.gz which would download whatever is set as current release? Thanks, Paul mailto:pmiscml@gmail.com
Paul Sokolovsky
Knowing a distribution name, I'd like to download its latest release file - as a single step, for easy shell scripting. Is that possible?
There's not really such a thing as “the latest release file”. Each distribution can comprise many files; various wheels, eggs, the source in various formats, etc. Which files are available is different between distributions. So a program can't know, just based on a distribution's name, which files will be available for download. You need to query PyPI and then choose a URL from what's available. There is a page for each distribution with links to each file for download. (This is known as the “simple” PyPI API.) For example, given the distribution name “pip”, you can get the page URL:https://pypi.python.org/simple/pip/ and parse that for links. You'll need to decide what the “latest” is according to the same rules as PyPI itself uses. Python's Setuptools library has functions to compare version strings to determine which is later. Alternatively, you can parse the user-facing page at URL:https://pypi.python.org/pypi/pip/ which shows the latest version of the “pip” distribution. The table listing the files for download doesn't have semantic markup, and I'm fairly sure no promises are made to support web scraping. But it's feasible without much effort. I would recommend using one of the PyPI API pages (the “simple” API is what I described, I don't know how to use any of the others) since at least some guarantee is made of their stability. -- \ “I have a map of the United States; it's actual size. It says | `\ ‘1 mile equals 1 mile’. Last summer, I folded it.” —Steven | _o__) Wright | Ben Finney
On 7 February 2015 at 20:38, Ben Finney
I would recommend using one of the PyPI API pages (the “simple” API is what I described, I don't know how to use any of the others) since at least some guarantee is made of their stability.
There's also the JSON page at https://pypi.python.org/pypi/<package>/json which includes details of all available versions and files. Paul
I suppose it wouldn't be too hard to make a redirection service that reads up the json and redirects to the file you want. Eg, you could use appengine for free (I suppose you'll be under the quota for few http requests). Thanks, -- Ionel Cristian Mărieș, blog.ionelmc.ro On Sat, Feb 7, 2015 at 11:17 PM, Paul Moore
On 7 February 2015 at 20:38, Ben Finney
wrote: I would recommend using one of the PyPI API pages (the “simple” API is what I described, I don't know how to use any of the others) since at least some guarantee is made of their stability.
There's also the JSON page at https://pypi.python.org/pypi/<package>/json which includes details of all available versions and files.
Paul _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org https://mail.python.org/mailman/listinfo/distutils-sig
participants (4)
-
Ben Finney
-
Ionel Cristian Mărieș
-
Paul Moore
-
Paul Sokolovsky