Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a275cb9
Use utf-8 to read README
methane Dec 12, 2019
d8c125b
Organize index of guides into 3 categories
pastelmind Mar 13, 2020
cb87c01
Remove Requires-Python note from piwheels project description
bennuttall Sep 25, 2020
1e33fed
Merge pull request #775 from bennuttall/patch-2
di Sep 25, 2020
b7fff2a
fix setuptools entry_point link
imba-tjd Oct 6, 2020
ea7641e
fix cx_Freeze link
imba-tjd Oct 6, 2020
22f7784
Fix sphinx command and docs directory text
matheusfelipeog Oct 23, 2020
e7d022b
Merge pull request #780 from matheusfelipeog/feature/fix-text
pradyunsg Oct 24, 2020
9b1b421
update PyPI package download queries to use file_downloads table
tswast Oct 27, 2020
3f44439
move warning to correct section
tswast Oct 27, 2020
b5f7f5d
Merge pull request #784 from tswast/issue782-file_downloads
di Oct 27, 2020
d3f138b
Add sdist format specification and metadata field (PEP 643)
pfmoore Oct 31, 2020
67c57a0
Clarify that the constraints on wheel metadata only apply for version…
pfmoore Oct 31, 2020
311b358
Fix details of sdist name format
pfmoore Oct 31, 2020
5da5bc6
Apply suggestions from code review
pfmoore Nov 1, 2020
505ee22
Correctly use globaltoc.html for global ToC
pradyunsg Nov 9, 2020
b3a8bc5
Merge pull request #788 from pradyunsg/cleanups
pradyunsg Nov 9, 2020
7d00c1c
Update link to egg format
jgerityneurala Nov 11, 2020
51b19db
fix BigQuery examples
sir-sigurd Nov 12, 2020
886bb62
Various updates for PEP 643
pfmoore Nov 13, 2020
7cc7fac
Merge branch 'pep643' of https://github.com/pfmoore/python-packaging-…
pfmoore Nov 13, 2020
7b150ed
Fix typo and dead link
dduong42 Nov 18, 2020
8cd15e6
Merge pull request #793 from dduong42/master
pradyunsg Nov 18, 2020
801fdcc
key_projects: add pypa/build
FFY00 Nov 20, 2020
208d121
guides: replace pep517 CLI usage with pypa/build
FFY00 Nov 20, 2020
6e186dd
Update include directive's end-before
pradyunsg Nov 21, 2020
1fb20bd
Merge pull request #795 from FFY00/add-build
pradyunsg Nov 21, 2020
079f4ec
Merge pull request #796 from FFY00/replace-pep517-cli
pradyunsg Nov 21, 2020
90b054d
Specify PEP 621
brettcannon Nov 23, 2020
1f46c25
Apply suggestions from code review
brettcannon Nov 23, 2020
c19e3e7
Address review comments
brettcannon Nov 25, 2020
1c905c2
Merge pull request #797 from brettcannon/declaring-project-metadata
pfmoore Nov 25, 2020
7cf802e
Fix duplicate phrase about poetry (#799)
pinealan Nov 28, 2020
297ac11
Merge pull request #778 from imba-tjd/patch-1
pradyunsg Nov 28, 2020
27e067e
Merge pull request #789 from jgerityneurala/patch-1
di Dec 2, 2020
69c86ae
Merge pull request #790 from sir-sigurd/fix-big-queries
di Dec 2, 2020
8b5cd53
fix orphaned link
wimglenn Dec 4, 2020
886be54
Merge pull request #800 from wimglenn/patch-2
di Dec 4, 2020
4514b43
Fix references with wrong link text
jodal Dec 6, 2020
794482f
Merge pull request #682 from methane/patch-1
di Dec 6, 2020
453701c
Merge pull request #801 from jodal/fix-easy_install-vs-setuptools-refs
di Dec 6, 2020
83c2b20
Move 2 "Misc" items under "Installing Packages"
pastelmind Dec 11, 2020
5c51b93
Merge branch 'master' into organize-guides-index
di Dec 11, 2020
9ef40af
Merge pull request #708 from pastelmind/organize-guides-index
di Dec 11, 2020
dcfa4b7
Refer to PyPI API tokens as such in GitHub secret names, spell in upp…
scop Dec 13, 2020
3a3d923
Merge pull request #803 from scop/gh-actions-secret-names
pradyunsg Dec 15, 2020
e08be9c
Spelling fixes
scop Dec 13, 2020
8c1f843
Merge pull request #802 from scop/spelling
di Dec 15, 2020
75c4acc
Merge branch 'master' into pep643
pfmoore Jan 1, 2021
ae48f92
Merge pull request #785 from pfmoore/pep643
pfmoore Jan 1, 2021
767a430
Tweak opening "important note" in installing-packages tutorial
pradyunsg Jan 2, 2021
0575db2
PEP 610 Add direct_url.json specification (#690)
sbidoul Jan 3, 2021
0aba4dc
Merge branch 'master' into pradyunsg-reorder-meaning-synonym
pradyunsg Jan 3, 2021
822413b
Merge pull request #810 from pypa/pradyunsg-reorder-meaning-synonym
pradyunsg Jan 3, 2021
63ec2a7
Fix typos
hugovk Jan 3, 2021
3d11d3c
Merge pull request #811 from hugovk/patch-1
pradyunsg Jan 3, 2021
2210aca
Grammatically updated the docs
chris1109873 Jan 14, 2021
fc6844e
Merge pull request #813 from chris1109873/doc-contribution
di Jan 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@

# Custom sidebar templates, filenames relative to this file.
html_sidebars = {
'**': ['localtoc.html', 'relations.html'],
'index': ['localtoc.html']
'**': ['globaltoc.html', 'relations.html'],
'index': ['globaltoc.html']
}

# Additional templates that should be rendered to pages, maps page names to
Expand Down
4 changes: 2 additions & 2 deletions source/discussions/pip-vs-easy-install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ pip vs easy_install
===================


`easy_install` was released in 2004, as part of :ref:`setuptools`. It was
:ref:`easy_install <easy_install>` was released in 2004, as part of :ref:`setuptools`. It was
notable at the time for installing :term:`packages <Distribution Package>` from
:term:`PyPI <Python Package Index (PyPI)>` using requirement specifiers, and
automatically installing dependencies.

:ref:`pip` came later in 2008, as alternative to `easy_install`, although still
:ref:`pip` came later in 2008, as alternative to :ref:`easy_install <easy_install>`, although still
largely built on top of :ref:`setuptools` components. It was notable at the
time for *not* installing packages as :term:`Eggs <Egg>` or from :term:`Eggs <Egg>` (but
rather simply as 'flat' packages from :term:`sdists <Source Distribution (or
Expand Down
2 changes: 1 addition & 1 deletion source/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Glossary
A :term:`Built Distribution` format introduced by :ref:`setuptools`,
which is being replaced by :term:`Wheel`. For details, see `The
Internal Structure of Python Eggs
<https://setuptools.readthedocs.io/en/latest/formats.html>`_ and
<https://setuptools.readthedocs.io/en/latest/deprecated/python_eggs.html>`_ and
`Python Eggs <http://peak.telecommunity.com/DevCenter/PythonEggs>`_

Extension Module
Expand Down
161 changes: 91 additions & 70 deletions source/guides/analyzing-pypi-package-downloads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,35 @@ the `BigQuery quickstart guide
Data schema
-----------

Linehaul writes an entry in a ``the-psf.pypi.downloadsYYYYMMDD`` table for each
Linehaul writes an entry in a ``the-psf.pypi.file_downloads`` table for each
download. The table contains information about what file was downloaded and how
it was downloaded. Some useful columns from the `table schema
<https://console.cloud.google.com/bigquery?pli=1&p=the-psf&d=pypi&t=downloads&page=table>`__
<https://console.cloud.google.com/bigquery?pli=1&p=the-psf&d=pypi&t=file_downloads&page=table>`__
include:

+------------------------+-----------------+-----------------------+
| Column | Description | Examples |
+========================+=================+=======================+
| file.project | Project name | ``pipenv``, ``nose`` |
+------------------------+-----------------+-----------------------+
| file.version | Package version | ``0.1.6``, ``1.4.2`` |
+------------------------+-----------------+-----------------------+
| details.installer.name | Installer | pip, `bandersnatch`_ |
+------------------------+-----------------+-----------------------+
| details.python | Python version | ``2.7.12``, ``3.6.4`` |
+------------------------+-----------------+-----------------------+
+------------------------+-----------------+-----------------------------+
| Column | Description | Examples |
+========================+=================+=============================+
| timestamp | Date and time | ``2020-03-09 00:33:03 UTC`` |
+------------------------+-----------------+-----------------------------+
| file.project | Project name | ``pipenv``, ``nose`` |
+------------------------+-----------------+-----------------------------+
| file.version | Package version | ``0.1.6``, ``1.4.2`` |
+------------------------+-----------------+-----------------------------+
| details.installer.name | Installer | pip, `bandersnatch`_ |
+------------------------+-----------------+-----------------------------+
| details.python | Python version | ``2.7.12``, ``3.6.4`` |
+------------------------+-----------------+-----------------------------+


Useful queries
--------------

Run queries in the `BigQuery web UI`_ by clicking the "Compose query" button.

Note that the rows are stored in separate tables for each day, which helps
Note that the rows are stored in a partitioned, which helps
limit the cost of queries. These example queries analyze downloads from
recent history by using `wildcard tables
<https://cloud.google.com/bigquery/docs/querying-wildcard-tables>`__ to
select all tables and then filter by ``_TABLE_SUFFIX``.
recent history by filtering on the ``timestamp`` column.

Counting package downloads
~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -108,18 +108,17 @@ The following query counts the total number of downloads for the project

#standardSQL
SELECT COUNT(*) AS num_downloads
FROM `the-psf.pypi.downloads*`
FROM `the-psf.pypi.file_downloads`
WHERE file.project = 'pytest'
-- Only query the last 30 days of history
AND _TABLE_SUFFIX
BETWEEN FORMAT_DATE(
'%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY))
AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
AND DATE(timestamp)
BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
AND CURRENT_DATE()

+---------------+
| num_downloads |
+===============+
| 2117807 |
| 20531925 |
+---------------+

To only count downloads from pip, filter on the ``details.installer.name``
Expand All @@ -129,71 +128,94 @@ column.

#standardSQL
SELECT COUNT(*) AS num_downloads
FROM `the-psf.pypi.downloads*`
FROM `the-psf.pypi.file_downloads`
WHERE file.project = 'pytest'
AND details.installer.name = 'pip'
-- Only query the last 30 days of history
AND _TABLE_SUFFIX
BETWEEN FORMAT_DATE(
'%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY))
AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
AND DATE(timestamp)
BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
AND CURRENT_DATE()

+---------------+
| num_downloads |
+===============+
| 1829322 |
| 19391645 |
+---------------+

Package downloads over time
~~~~~~~~~~~~~~~~~~~~~~~~~~~

To group by monthly downloads, use the ``_TABLE_SUFFIX`` pseudo-column. Also
use the pseudo-column to limit the tables queried and the corresponding
costs.
To group by monthly downloads, use the ``TIMESTAMP_TRUNC`` function. Also
filtering by this column reduces corresponding costs.

::

#standardSQL
SELECT
COUNT(*) AS num_downloads,
SUBSTR(_TABLE_SUFFIX, 1, 6) AS `month`
FROM `the-psf.pypi.downloads*`
DATE_TRUNC(DATE(timestamp), MONTH) AS `month`
FROM `the-psf.pypi.file_downloads`
WHERE
file.project = 'pytest'
-- Only query the last 6 months of history
AND _TABLE_SUFFIX
BETWEEN FORMAT_DATE(
'%Y%m01', DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH))
AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
AND DATE(timestamp)
BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH), MONTH)
AND CURRENT_DATE()
GROUP BY `month`
ORDER BY `month` DESC

+---------------+--------+
| num_downloads | month |
+===============+========+
| 1956741 | 201801 |
+---------------+--------+
| 2344692 | 201712 |
+---------------+--------+
| 1730398 | 201711 |
+---------------+--------+
| 2047310 | 201710 |
+---------------+--------+
| 1744443 | 201709 |
+---------------+--------+
| 1916952 | 201708 |
+---------------+--------+

More queries
~~~~~~~~~~~~

- `Data driven decisions using PyPI download statistics
<https://langui.sh/2016/12/09/data-driven-decisions/>`__
- `PyPI queries gist <https://gist.github.com/alex/4f100a9592b05e9b4d63>`__
- `Python versions over time
<https://github.com/tswast/code-snippets/blob/master/2018/python-community-insights/Python%20Community%20Insights.ipynb>`__
- `Non-Windows downloads, grouped by platform
<https://bigquery.cloud.google.com/savedquery/51422494423:ff1976af63614ad4a1258d8821dd7785>`__
+---------------+------------+
| num_downloads | month |
+===============+============+
| 1956741 | 2018-01-01 |
+---------------+------------+
| 2344692 | 2017-12-01 |
+---------------+------------+
| 1730398 | 2017-11-01 |
+---------------+------------+
| 2047310 | 2017-10-01 |
+---------------+------------+
| 1744443 | 2017-09-01 |
+---------------+------------+
| 1916952 | 2017-08-01 |
+---------------+------------+

Python versions over time
~~~~~~~~~~~~~~~~~~~~~~~~~

Extract the Python version from the ``details.python`` column. Warning: This
query processes over 500 GB of data.

::

#standardSQL
SELECT
REGEXP_EXTRACT(details.python, r"[0-9]+\.[0-9]+") AS python_version,
COUNT(*) AS num_downloads,
FROM `the-psf.pypi.file_downloads`
WHERE
-- Only query the last 6 months of history
DATE(timestamp)
BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH), MONTH)
AND CURRENT_DATE()
GROUP BY `python_version`
ORDER BY `num_downloads` DESC

+--------+---------------+
| python | num_downloads |
+========+===============+
| 3.7 | 12990683561 |
+--------+---------------+
| 3.6 | 9035598511 |
+--------+---------------+
| 2.7 | 8467785320 |
+--------+---------------+
| 3.8 | 4581627740 |
+--------+---------------+
| 3.5 | 2412533601 |
+--------+---------------+
| null | 1641456718 |
+--------+---------------+

Caveats
=======
Expand Down Expand Up @@ -229,13 +251,12 @@ the official Python client library for BigQuery.

query_job = client.query("""
SELECT COUNT(*) AS num_downloads
FROM `the-psf.pypi.downloads*`
FROM `the-psf.pypi.file_downloads`
WHERE file.project = 'pytest'
-- Only query the last 30 days of history
AND _TABLE_SUFFIX
BETWEEN FORMAT_DATE(
'%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY))
AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())""")
-- Only query the last 30 days of history
AND DATE(timestamp)
BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
AND CURRENT_DATE()""")

results = query_job.result() # Waits for job to complete.
for row in results:
Expand Down
5 changes: 2 additions & 3 deletions source/guides/distributing-packages-using-setuptools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,8 @@ entry_points
Use this keyword to specify any plugins that your project provides for any named
entry points that may be defined by your project or others that you depend on.

For more information, see the section on `Dynamic Discovery of Services and
Plugins
<https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins>`_
For more information, see the section on `Advertising Behavior
<https://setuptools.readthedocs.io/en/latest/userguide/entry_point.html#dynamic-discovery-of-services-and-plugins>`_
from the :ref:`setuptools` docs.

The most commonly used entry point is "console_scripts" (see below).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install pep517
- name: Install pypa/build
run: >-
python -m
pip install
pep517
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
pep517.build
--source
--binary
--out-dir dist/
build
--sdist
--wheel
--outdir dist/
.
# Actually publish to PyPI/TestPyPI
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.test_pypi_password }}
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
password: ${{ secrets.PYPI_API_TOKEN }}
19 changes: 15 additions & 4 deletions source/guides/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ introduction to packaging, see :doc:`/tutorials/index`.

.. toctree::
:maxdepth: 1
:caption: Installing Packages:

tool-recommendations
installing-using-pip-and-virtual-environments
installing-stand-alone-command-line-tools
installing-using-linux-tools
installing-scientific-packages
multi-version-installs
index-mirrors-and-caches
hosting-your-own-index

.. toctree::
:maxdepth: 1
:caption: Building and Publishing Projects:

distributing-packages-using-setuptools
using-manifest-in
single-sourcing-package-version
Expand All @@ -23,10 +30,14 @@ introduction to packaging, see :doc:`/tutorials/index`.
supporting-windows-using-appveyor
packaging-namespace-packages
creating-and-discovering-plugins
analyzing-pypi-package-downloads
index-mirrors-and-caches
hosting-your-own-index
migrating-to-pypi-org
using-testpypi
making-a-pypi-friendly-readme
publishing-package-distribution-releases-using-github-actions-ci-cd-workflows

.. toctree::
:maxdepth: 1
:caption: Miscellaneous:

tool-recommendations
analyzing-pypi-package-downloads
2 changes: 1 addition & 1 deletion source/guides/installing-using-linux-tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ To install pip, wheel, and setuptools, in a parallel, non-system environment
(using yum) then there are two options:


1. Use the "Sofware Collections" feature to enable a parallel collection that
1. Use the "Software Collections" feature to enable a parallel collection that
includes pip, setuptools, and wheel.

* For Redhat, see here:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ for Python 2. These are the lowest-level tools for managing Python
packages and are recommended if higher-level tools do not suit your needs.

.. note:: This doc uses the term **package** to refer to a
:term:`Distribution Package` which is different from a :term:`Import
:term:`Distribution Package` which is different from an :term:`Import
Package` that which is used to import modules in your Python source code.


Expand Down
2 changes: 1 addition & 1 deletion source/guides/multi-version-installs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This can be worked around by setting all dependencies in
``__main__.__requires__`` before importing ``pkg_resources`` for the first
time, but that approach does mean that standard command line invocations of
the affected tools can't be used - it's necessary to write a custom
wrapper script or use ``python -c '<commmand>'`` to invoke the application's
wrapper script or use ``python -c '<command>'`` to invoke the application's
main entry point directly.

Refer to the `pkg_resources documentation
Expand Down
2 changes: 1 addition & 1 deletion source/guides/packaging-binary-extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ profiling has identified the code where the speed increase is worth
additional maintenance effort), a number of other alternatives should
also be considered:

* look for existing optimised alternatives. The CPython standard libary
* look for existing optimised alternatives. The CPython standard library
includes a number of optimised data structures and algorithms (especially
in the builtins and the ``collections`` and ``itertools`` modules). The
Python Package Index also offers additional alternatives. Sometimes, the
Expand Down
Loading