Skip to content

Commit eb5a653

Browse files
authored
Merge branch 'main' into maintenance/intersphinx-setuptools
2 parents 2a92465 + 9dfbeb0 commit eb5a653

31 files changed

Lines changed: 1200 additions & 264 deletions

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.9
16+
17+
- name: pip cache
18+
uses: actions/cache@v2
19+
with:
20+
path: ~/.cache/pip
21+
key:
22+
${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('noxfile.py') }}
23+
restore-keys: |
24+
${{ matrix.os }}-${{ matrix.python-version }}-
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade nox virtualenv
29+
30+
- name: Nox build
31+
run: |
32+
python -m nox -s build

.travis.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sphinx==3.2.0
22
sphinx-autobuild==0.7.1
3+
sphinx-inline-tabs==2020.10.19b4
34
git+https://github.com/python/python-docs-theme.git#egg=python-docs-theme
45
git+https://github.com/pypa/pypa-docs-theme.git#egg=pypa-docs-theme

source/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'sphinx.ext.extlinks',
3535
'sphinx.ext.intersphinx',
3636
'sphinx.ext.todo',
37+
'sphinx_inline_tabs',
3738
]
3839

3940
# Add any paths that contain templates here, relative to this directory.
@@ -196,8 +197,8 @@
196197

197198
# Custom sidebar templates, filenames relative to this file.
198199
html_sidebars = {
199-
'**': ['localtoc.html', 'relations.html'],
200-
'index': ['localtoc.html']
200+
'**': ['globaltoc.html', 'relations.html'],
201+
'index': ['globaltoc.html']
201202
}
202203

203204
# Additional templates that should be rendered to pages, maps page names to

source/discussions/pip-vs-easy-install.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ pip vs easy_install
66
===================
77

88

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

14-
:ref:`pip` came later in 2008, as alternative to `easy_install`, although still
14+
:ref:`pip` came later in 2008, as alternative to :ref:`easy_install <easy_install>`, although still
1515
largely built on top of :ref:`setuptools` components. It was notable at the
1616
time for *not* installing packages as :term:`Eggs <Egg>` or from :term:`Eggs <Egg>` (but
1717
rather simply as 'flat' packages from :term:`sdists <Source Distribution (or

source/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Glossary
4444
A :term:`Built Distribution` format introduced by :ref:`setuptools`,
4545
which is being replaced by :term:`Wheel`. For details, see `The
4646
Internal Structure of Python Eggs
47-
<https://setuptools.readthedocs.io/en/latest/formats.html>`_ and
47+
<https://setuptools.readthedocs.io/en/latest/deprecated/python_eggs.html>`_ and
4848
`Python Eggs <http://peak.telecommunity.com/DevCenter/PythonEggs>`_
4949

5050
Extension Module

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

Lines changed: 91 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,35 @@ the `BigQuery quickstart guide
6868
Data schema
6969
-----------
7070

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

77-
+------------------------+-----------------+-----------------------+
78-
| Column | Description | Examples |
79-
+========================+=================+=======================+
80-
| file.project | Project name | ``pipenv``, ``nose`` |
81-
+------------------------+-----------------+-----------------------+
82-
| file.version | Package version | ``0.1.6``, ``1.4.2`` |
83-
+------------------------+-----------------+-----------------------+
84-
| details.installer.name | Installer | pip, `bandersnatch`_ |
85-
+------------------------+-----------------+-----------------------+
86-
| details.python | Python version | ``2.7.12``, ``3.6.4`` |
87-
+------------------------+-----------------+-----------------------+
77+
+------------------------+-----------------+-----------------------------+
78+
| Column | Description | Examples |
79+
+========================+=================+=============================+
80+
| timestamp | Date and time | ``2020-03-09 00:33:03 UTC`` |
81+
+------------------------+-----------------+-----------------------------+
82+
| file.project | Project name | ``pipenv``, ``nose`` |
83+
+------------------------+-----------------+-----------------------------+
84+
| file.version | Package version | ``0.1.6``, ``1.4.2`` |
85+
+------------------------+-----------------+-----------------------------+
86+
| details.installer.name | Installer | pip, `bandersnatch`_ |
87+
+------------------------+-----------------+-----------------------------+
88+
| details.python | Python version | ``2.7.12``, ``3.6.4`` |
89+
+------------------------+-----------------+-----------------------------+
8890

8991

9092
Useful queries
9193
--------------
9294

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

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

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

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

119118
+---------------+
120119
| num_downloads |
121120
+===============+
122-
| 2117807 |
121+
| 20531925 |
123122
+---------------+
124123

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

130129
#standardSQL
131130
SELECT COUNT(*) AS num_downloads
132-
FROM `the-psf.pypi.downloads*`
131+
FROM `the-psf.pypi.file_downloads`
133132
WHERE file.project = 'pytest'
134133
AND details.installer.name = 'pip'
135134
-- Only query the last 30 days of history
136-
AND _TABLE_SUFFIX
137-
BETWEEN FORMAT_DATE(
138-
'%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY))
139-
AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
135+
AND DATE(timestamp)
136+
BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
137+
AND CURRENT_DATE()
140138

141139
+---------------+
142140
| num_downloads |
143141
+===============+
144-
| 1829322 |
142+
| 19391645 |
145143
+---------------+
146144

147145
Package downloads over time
148146
~~~~~~~~~~~~~~~~~~~~~~~~~~~
149147

150-
To group by monthly downloads, use the ``_TABLE_SUFFIX`` pseudo-column. Also
151-
use the pseudo-column to limit the tables queried and the corresponding
152-
costs.
148+
To group by monthly downloads, use the ``TIMESTAMP_TRUNC`` function. Also
149+
filtering by this column reduces corresponding costs.
153150

154151
::
155152

156153
#standardSQL
157154
SELECT
158155
COUNT(*) AS num_downloads,
159-
SUBSTR(_TABLE_SUFFIX, 1, 6) AS `month`
160-
FROM `the-psf.pypi.downloads*`
156+
DATE_TRUNC(DATE(timestamp), MONTH) AS `month`
157+
FROM `the-psf.pypi.file_downloads`
161158
WHERE
162159
file.project = 'pytest'
163160
-- Only query the last 6 months of history
164-
AND _TABLE_SUFFIX
165-
BETWEEN FORMAT_DATE(
166-
'%Y%m01', DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH))
167-
AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
161+
AND DATE(timestamp)
162+
BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH), MONTH)
163+
AND CURRENT_DATE()
168164
GROUP BY `month`
169165
ORDER BY `month` DESC
170166

171-
+---------------+--------+
172-
| num_downloads | month |
173-
+===============+========+
174-
| 1956741 | 201801 |
175-
+---------------+--------+
176-
| 2344692 | 201712 |
177-
+---------------+--------+
178-
| 1730398 | 201711 |
179-
+---------------+--------+
180-
| 2047310 | 201710 |
181-
+---------------+--------+
182-
| 1744443 | 201709 |
183-
+---------------+--------+
184-
| 1916952 | 201708 |
185-
+---------------+--------+
186-
187-
More queries
188-
~~~~~~~~~~~~
189-
190-
- `Data driven decisions using PyPI download statistics
191-
<https://langui.sh/2016/12/09/data-driven-decisions/>`__
192-
- `PyPI queries gist <https://gist.github.com/alex/4f100a9592b05e9b4d63>`__
193-
- `Python versions over time
194-
<https://github.com/tswast/code-snippets/blob/master/2018/python-community-insights/Python%20Community%20Insights.ipynb>`__
195-
- `Non-Windows downloads, grouped by platform
196-
<https://bigquery.cloud.google.com/savedquery/51422494423:ff1976af63614ad4a1258d8821dd7785>`__
167+
+---------------+------------+
168+
| num_downloads | month |
169+
+===============+============+
170+
| 1956741 | 2018-01-01 |
171+
+---------------+------------+
172+
| 2344692 | 2017-12-01 |
173+
+---------------+------------+
174+
| 1730398 | 2017-11-01 |
175+
+---------------+------------+
176+
| 2047310 | 2017-10-01 |
177+
+---------------+------------+
178+
| 1744443 | 2017-09-01 |
179+
+---------------+------------+
180+
| 1916952 | 2017-08-01 |
181+
+---------------+------------+
182+
183+
Python versions over time
184+
~~~~~~~~~~~~~~~~~~~~~~~~~
185+
186+
Extract the Python version from the ``details.python`` column. Warning: This
187+
query processes over 500 GB of data.
188+
189+
::
190+
191+
#standardSQL
192+
SELECT
193+
REGEXP_EXTRACT(details.python, r"[0-9]+\.[0-9]+") AS python_version,
194+
COUNT(*) AS num_downloads,
195+
FROM `the-psf.pypi.file_downloads`
196+
WHERE
197+
-- Only query the last 6 months of history
198+
DATE(timestamp)
199+
BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH), MONTH)
200+
AND CURRENT_DATE()
201+
GROUP BY `python_version`
202+
ORDER BY `num_downloads` DESC
203+
204+
+--------+---------------+
205+
| python | num_downloads |
206+
+========+===============+
207+
| 3.7 | 12990683561 |
208+
+--------+---------------+
209+
| 3.6 | 9035598511 |
210+
+--------+---------------+
211+
| 2.7 | 8467785320 |
212+
+--------+---------------+
213+
| 3.8 | 4581627740 |
214+
+--------+---------------+
215+
| 3.5 | 2412533601 |
216+
+--------+---------------+
217+
| null | 1641456718 |
218+
+--------+---------------+
197219

198220
Caveats
199221
=======
@@ -229,13 +251,12 @@ the official Python client library for BigQuery.
229251
230252
query_job = client.query("""
231253
SELECT COUNT(*) AS num_downloads
232-
FROM `the-psf.pypi.downloads*`
254+
FROM `the-psf.pypi.file_downloads`
233255
WHERE file.project = 'pytest'
234-
-- Only query the last 30 days of history
235-
AND _TABLE_SUFFIX
236-
BETWEEN FORMAT_DATE(
237-
'%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY))
238-
AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())""")
256+
-- Only query the last 30 days of history
257+
AND DATE(timestamp)
258+
BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
259+
AND CURRENT_DATE()""")
239260
240261
results = query_job.result() # Waits for job to complete.
241262
for row in results:

source/guides/distributing-packages-using-setuptools.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,8 @@ entry_points
508508
Use this keyword to specify any plugins that your project provides for any named
509509
entry points that may be defined by your project or others that you depend on.
510510

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

516515
The most commonly used entry point is "console_scripts" (see below).

source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ jobs:
1313
uses: actions/setup-python@v1
1414
with:
1515
python-version: 3.7
16-
- name: Install pep517
16+
- name: Install pypa/build
1717
run: >-
1818
python -m
1919
pip install
20-
pep517
20+
build
2121
--user
2222
- name: Build a binary wheel and a source tarball
2323
run: >-
2424
python -m
25-
pep517.build
26-
--source
27-
--binary
28-
--out-dir dist/
25+
build
26+
--sdist
27+
--wheel
28+
--outdir dist/
2929
.
3030
# Actually publish to PyPI/TestPyPI
3131
- name: Publish distribution 📦 to Test PyPI
3232
uses: pypa/gh-action-pypi-publish@master
3333
with:
34-
password: ${{ secrets.test_pypi_password }}
34+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
3535
repository_url: https://test.pypi.org/legacy/
3636
- name: Publish distribution 📦 to PyPI
3737
if: startsWith(github.ref, 'refs/tags')
3838
uses: pypa/gh-action-pypi-publish@master
3939
with:
40-
password: ${{ secrets.pypi_password }}
40+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)