Skip to content

Commit 04a155a

Browse files
authored
Merge pull request #1105 from di/section-on-file-paths
Add section on getting absolute URLs via BigQuery dataset
2 parents 7c22708 + 292129b commit 04a155a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

source/guides/analyzing-pypi-package-downloads.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,43 @@ query processes over 500 GB of data.
217217
| 3.5 | 1894153540 |
218218
+--------+---------------+
219219

220+
221+
Getting absolute links to artifacts
222+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223+
224+
It's sometimes helpful to be able to get the absolute links to download
225+
artifacts from PyPI based on their hashes, e.g. if a particular project or
226+
release has been deleted from PyPI. The metadata table includes the ``path``
227+
column, which includes the hash and artifact filename.
228+
229+
.. note::
230+
The URL generated here is not guaranteed to be stable, but currently aligns with the URL where PyPI artifacts are hosted.
231+
232+
::
233+
234+
SELECT
235+
CONCAT('https://files.pythonhosted.org/packages', path) as url
236+
FROM
237+
`bigquery-public-data.pypi.distribution_metadata`
238+
WHERE
239+
filename LIKE 'sampleproject%'
240+
241+
242+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
243+
| url |
244+
+===================================================================================================================================================================+
245+
| https://files.pythonhosted.org/packages/eb/45/79be82bdeafcecb9dca474cad4003e32ef8e4a0dec6abbd4145ccb02abe1/sampleproject-1.2.0.tar.gz |
246+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
247+
| https://files.pythonhosted.org/packages/56/0a/178e8bbb585ec5b13af42dae48b1d7425d6575b3ff9b02e5ec475e38e1d6/sampleproject_nomura-1.2.0-py2.py3-none-any.whl |
248+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
249+
| https://files.pythonhosted.org/packages/63/88/3200eeaf22571f18d2c41e288862502e33365ccbdc12b892db23f51f8e70/sampleproject_nomura-1.2.0.tar.gz |
250+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
251+
| https://files.pythonhosted.org/packages/21/e9/2743311822e71c0756394b6c5ab15cb64ca66c78c6c6a5cd872c9ed33154/sampleproject_doubleyoung18-1.3.0-py2.py3-none-any.whl |
252+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
253+
| https://files.pythonhosted.org/packages/6f/5b/2f3fe94e1c02816fe23c7ceee5292fb186912929e1972eee7fb729fa27af/sampleproject-1.3.1.tar.gz |
254+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
255+
256+
220257
Caveats
221258
=======
222259

0 commit comments

Comments
 (0)