Paul Sokolovsky <[email protected]> writes: > 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 _______________________________________________ Distutils-SIG maillist - [email protected] https://mail.python.org/mailman/listinfo/distutils-sig
