Skip to content

Commit 20dfd4b

Browse files
committed
fixup! Drop Python 2.7
1 parent 96c0c1d commit 20dfd4b

File tree

9 files changed

+19
-66
lines changed

9 files changed

+19
-66
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ What does it do?
3636
- Bundles shared library dependencies on Linux and macOS through [auditwheel](https://github.com/pypa/auditwheel) and [delocate](https://github.com/matthew-brett/delocate)
3737
- Runs your library's tests against the wheel-installed version of your library
3838

39+
See the [cibuildwheel 1 documentation](https://cibuildwheel.readthedocs.io/en/1.x/) if you need to build unsupported versions of Python, such as Python 2.
40+
3941
Usage
4042
-----
4143

cibuildwheel/resources/install_certifi.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
| stat.S_IXOTH
2525
)
2626

27-
if sys.version_info[0] == 2:
28-
FileNotFoundError = OSError
29-
3027

3128
def main():
3229
openssl_dir, openssl_cafile = os.path.split(ssl.get_default_verify_paths().openssl_cafile)

docs/faq.md

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ If your wheel didn't compile, check the list below for some debugging tips.
1414

1515
- MacOS: calling cibuildwheel from a python3 script and getting a `ModuleNotFoundError`? Due to a (fixed) [bug](https://bugs.python.org/issue22490) in CPython, you'll need to [unset the `__PYVENV_LAUNCHER__` variable](https://github.com/joerick/cibuildwheel/issues/133#issuecomment-478288597) before activating a venv.
1616

17+
### Building Python 2.7 / PyPy2 wheels
18+
19+
See the [cibuildwheel verison 1 docs](https://cibuildwheel.readthedocs.io/en/1.x/) for information about building Python 2.7 or PyPy2 wheels. There are lots of tricks and workaround there that are no longer required for Python 3 in cibuildwheel 2.
20+
1721
### Linux builds on Docker
1822

1923
Linux wheels are built in the [`manylinux` docker images](https://github.com/pypa/manylinux) to provide binary compatible wheels on Linux, according to [PEP 571](https://www.python.org/dev/peps/pep-0571/). Because of this, when building with `cibuildwheel` on Linux, a few things should be taken into account:
@@ -136,35 +140,6 @@ Here's an example GitHub Actions workflow with a job that builds for Apple Silic
136140
{% include "../examples/github-apple-silicon.yml" %}
137141
```
138142

139-
### Windows and Python 2.7
140-
141-
Building 2.7 extensions on Windows is difficult, because the VS 2008 compiler that was used for the original Python compilation was discontinued in 2018, and has since been removed from Microsoft's downloads. Most people choose to not build Windows 2.7 wheels, or to override the compiler to something more modern.
142-
143-
To override, you need to have a modern compiler toolchain activated, and set `DISTUTILS_USE_SDK=1` and `MSSdk=1`. For example, on GitHub Actions, you would add these steps:
144-
145-
```yaml
146-
- name: Prepare compiler environment for Windows
147-
if: runner.os == 'Windows'
148-
uses: ilammy/msvc-dev-cmd@v1
149-
with:
150-
arch: x64
151-
152-
- name: Set Windows environment variables
153-
if: runner.os == 'Windows'
154-
shell: bash
155-
run: |
156-
echo "DISTUTILS_USE_SDK=1" >> $GITHUB_ENV
157-
echo "MSSdk=1" >> $GITHUB_ENV
158-
159-
# invoke cibuildwheel...
160-
```
161-
162-
cibuildwheel will not try to build 2.7 on Windows unless it detects that the above two variables are set. Note that changing to a more modern compiler will mean your wheel picks up a runtime dependency to a different [Visual C++ Redistributable][]. You also need to be [a bit careful][] in designing your extension; some major binding tools like pybind11 do this for you.
163-
164-
More on setting a custom Windows toolchain in our docs on modern C++ standards [here](cpp_standards.md#windows-and-python-27).
165-
166-
[Visual C++ Redistributable]: https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0
167-
[a bit careful]: https://pybind11.readthedocs.io/en/stable/faq.html#working-with-ancient-visual-studio-2008-builds-on-windows
168143

169144
### Building packages with optional C extensions
170145

docs/options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ The format is `python_tag-platform_tag`, with tags similar to those in [PEP 425]
133133

134134
For CPython, the minimally supported macOS version is 10.9; for PyPy 3.6/3.7, macOS 10.13 or higher is required.
135135

136+
See the [cibuildwheel 1 documentation](https://cibuildwheel.readthedocs.io/en/1.x/) for past end of life versions of Python, and PyPy2.7.
137+
136138
#### Examples
137139

138140
```yaml

test/test_cpp_standards.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,9 @@ def test_cpp14(tmp_path):
9494

9595
cpp17_project = cpp_test_project.copy()
9696

97-
# Python and PyPy 2.7 headers use the `register` keyword, which is forbidden in
98-
# the C++17 standard, so we need the -Wno-register or /wd5033 options
99-
cpp17_project.template_context["extra_compile_args"] = (
100-
["/std:c++17", "/wd5033"] if utils.platform == "windows" else ["-std=c++17", "-Wno-register"]
101-
)
97+
cpp17_project.template_context["extra_compile_args"] = [
98+
"/std:c++17" if utils.platform == "windows" else "-std=c++17"
99+
]
102100
cpp17_project.template_context[
103101
"spam_cpp_top_level_add"
104102
] = r"""

test/test_pep518.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
"""
99
# Will fail if PEP 518 does work
1010
import requests
11-
if sys.version_info < (3, 6, 0):
12-
assert requests.__version__ == "2.22.0", "Requests found but wrong version ({0})".format(requests.__version__)
13-
else:
14-
assert requests.__version__ == "2.23.0", "Requests found but wrong version ({0})".format(requests.__version__)
11+
assert requests.__version__ == "2.23.0", "Requests found but wrong version ({0})".format(requests.__version__)
1512
1613
# Just making sure environment is still set
1714
import os
@@ -29,8 +26,7 @@
2926
"setuptools >= 42",
3027
"setuptools_scm[toml]>=4.1.2",
3128
"wheel",
32-
"requests==2.22.0; python_version<'3.6'",
33-
"requests==2.23.0; python_version>='3.6'"
29+
"requests==2.23.0"
3430
]
3531
3632
build-backend = "setuptools.build_meta"

test/test_ssl.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
r"""
88
import ssl
99
10-
if sys.version_info[0] == 2:
11-
from urllib2 import urlopen
12-
else:
13-
from urllib.request import urlopen
10+
from urllib.request import urlopen
1411
1512
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
1613
data = urlopen("https://www.nist.gov", context=context)

test/test_testing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def test_virtualenv(self):
5252
# sys.prefix is different from sys.base_prefix when running a virtualenv
5353
# See https://docs.python.org/3/library/venv.html, which virtualenv seems
5454
# to honor in recent releases
55-
# Python 2 doesn't have sys.base_prefix by default
56-
if not hasattr(sys, 'base_prefix') or sys.prefix == sys.base_prefix:
55+
if sys.prefix == sys.base_prefix:
5756
self.fail("Not running in a virtualenv")
5857
5958
self.assertTrue(path_contains(sys.prefix, sys.executable))

test/utils.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
import os
88
import platform as pm
9-
import shutil
109
import subprocess
1110
import sys
12-
from contextlib import contextmanager
13-
from tempfile import mkdtemp
11+
from tempfile import TemporaryDirectory
1412

1513
platform: str
1614

@@ -26,17 +24,6 @@
2624
raise Exception("Unsupported platform")
2725

2826

29-
# Python 2 does not have a tempfile.TemporaryDirectory context manager
30-
@contextmanager
31-
def TemporaryDirectoryIfNone(path):
32-
_path = path or mkdtemp()
33-
try:
34-
yield _path
35-
finally:
36-
if path is None:
37-
shutil.rmtree(_path)
38-
39-
4027
def cibuildwheel_get_build_identifiers(project_path, env=None):
4128
"""
4229
Returns the list of build identifiers that cibuildwheel will try to build
@@ -76,21 +63,21 @@ def cibuildwheel_run(project_path, package_dir=".", env=None, add_env=None, outp
7663
if add_env is not None:
7764
env.update(add_env)
7865

79-
with TemporaryDirectoryIfNone(output_dir) as _output_dir:
66+
with TemporaryDirectory() as tmp_output_dir:
8067
subprocess.run(
8168
[
8269
sys.executable,
8370
"-m",
8471
"cibuildwheel",
8572
"--output-dir",
86-
str(_output_dir),
73+
str(output_dir or tmp_output_dir),
8774
str(package_dir),
8875
],
8976
env=env,
9077
cwd=project_path,
9178
check=True,
9279
)
93-
wheels = os.listdir(_output_dir)
80+
wheels = os.listdir(output_dir or tmp_output_dir)
9481
return wheels
9582

9683

0 commit comments

Comments
 (0)