Skip to content

Commit 9682f0e

Browse files
committed
Auto merge of #66605 - GuillaumeGomez:drop-python2, r=Mark-Simulacrum
Stop explicitly depending on python 2 This PR revises our previous policy of officially only supporting and testing with python 2 in the CI environment to instead test with python 3. It also changes the defaults to python 3 in our various scripts (usually, by way of `python` rather than `python3` to preserve compatibility with systems that do not have a python 3 available). The effect of this is that we expect all new patches to support python 3 (and will test as such). We explicitly also expect that patches support python 2.7 as well -- and test as such, though only on one builder. This is intended as a temporary, though likely long-lived, measure to preserve compatibility while looking towards the future which is likely to be a python 3 only world. We do not at this point set a timeline for when we'll drop support for python 2.7; it's plausible that this is months or years into the future, depending on how quickly the ecosystem drops support and how painful it is for us to maintain that support over time. Closes #65063 (as far as I can tell; please file explicit and separate issues or PRs if not).
2 parents dbc3cfd + 38eb369 commit 9682f0e

File tree

62 files changed

+131
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+131
-111
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ or reading the [rustc dev guide][rustcguidebuild].
2727
1. Make sure you have installed the dependencies:
2828

2929
* `g++` 5.1 or later or `clang++` 3.5 or later
30-
* `python` 2.7 (but not 3.x)
30+
* `python` 3 or 2.7
3131
* GNU `make` 3.81 or later
3232
* `cmake` 3.4.3 or later
3333
* `curl`
@@ -113,7 +113,7 @@ build.
113113
make \
114114
diffutils \
115115
tar \
116-
mingw-w64-x86_64-python2 \
116+
mingw-w64-x86_64-python \
117117
mingw-w64-x86_64-cmake \
118118
mingw-w64-x86_64-gcc
119119
```

config.toml.example

+2-4
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,9 @@
168168

169169
# Python interpreter to use for various tasks throughout the build, notably
170170
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
171-
# Note that Python 2 is currently required.
172171
#
173-
# Defaults to python2.7, then python2. If neither executable can be found, then
174-
# it defaults to the Python interpreter used to execute x.py.
175-
#python = "python2.7"
172+
# Defaults to the Python interpreter used to execute x.py.
173+
#python = "python"
176174

177175
# Force Cargo to check that Cargo.lock describes the precise dependency
178176
# set that all the Cargo.toml files create, instead of updating it.

configure

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ try() {
1111
fi
1212
}
1313

14+
try python3 "$@"
1415
try python2.7 "$@"
1516
try python27 "$@"
1617
try python2 "$@"

src/bootstrap/job.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,12 @@ pub unsafe fn setup(build: &mut Build) {
103103
};
104104

105105
let parent = OpenProcess(PROCESS_DUP_HANDLE, FALSE, pid.parse().unwrap());
106-
assert!(!parent.is_null(), "{}", io::Error::last_os_error());
106+
assert!(
107+
!parent.is_null(),
108+
"PID `{}` doesn't seem to exist: {}",
109+
pid,
110+
io::Error::last_os_error()
111+
);
107112
let mut parent_handle = ptr::null_mut();
108113
let r = DuplicateHandle(
109114
GetCurrentProcess(),

src/bootstrap/sanity.rs

-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ pub fn check(build: &mut Build) {
132132
.python
133133
.take()
134134
.map(|p| cmd_finder.must_have(p))
135-
.or_else(|| cmd_finder.maybe_have("python2.7"))
136-
.or_else(|| cmd_finder.maybe_have("python2"))
137135
.or_else(|| env::var_os("BOOTSTRAP_PYTHON").map(PathBuf::from)) // set by bootstrap.py
138136
.or_else(|| Some(cmd_finder.must_have("python")));
139137

src/ci/docker/arm-android/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ENV TARGETS=arm-linux-androideabi
3131

3232
ENV RUST_CONFIGURE_ARGS --arm-linux-androideabi-ndk=/android/ndk/arm-14
3333

34-
ENV SCRIPT python2.7 ../x.py test --target $TARGETS
34+
ENV SCRIPT python3 ../x.py test --target $TARGETS
3535

3636
COPY scripts/sccache.sh /scripts/
3737
RUN sh /scripts/sccache.sh

src/ci/docker/armhf-gnu/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
1414
libc6-dev \
1515
libc6-dev-armhf-cross \
1616
make \
17-
python2.7 \
17+
python3 \
1818
qemu-system-arm \
1919
xz-utils
2020

@@ -78,6 +78,6 @@ COPY scripts/sccache.sh /scripts/
7878
RUN sh /scripts/sccache.sh
7979

8080
ENV RUST_CONFIGURE_ARGS --qemu-armhf-rootfs=/tmp/rootfs
81-
ENV SCRIPT python2.7 ../x.py test --target arm-unknown-linux-gnueabihf
81+
ENV SCRIPT python3 ../x.py test --target arm-unknown-linux-gnueabihf
8282

8383
ENV NO_CHANGE_USER=1

src/ci/docker/disabled/aarch64-gnu/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
1414
libc6-dev \
1515
libc6-dev-arm64-cross \
1616
make \
17-
python2.7 \
17+
python3 \
1818
qemu-system-aarch64 \
1919
xz-utils
2020

@@ -75,5 +75,5 @@ RUN sh /scripts/sccache.sh
7575

7676
ENV RUST_CONFIGURE_ARGS \
7777
--qemu-aarch64-rootfs=/tmp/rootfs
78-
ENV SCRIPT python2.7 ../x.py test --target aarch64-unknown-linux-gnu
78+
ENV SCRIPT python3 ../x.py test --target aarch64-unknown-linux-gnu
7979
ENV NO_CHANGE_USER=1

src/ci/docker/disabled/asmjs/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python \
9+
python3 \
1010
git \
1111
cmake \
1212
sudo \
@@ -33,7 +33,7 @@ ENV EMCC_CFLAGS=-O1
3333
# Emscripten installation is user-specific
3434
ENV NO_CHANGE_USER=1
3535

36-
ENV SCRIPT python2.7 ../x.py test --target $TARGETS
36+
ENV SCRIPT python3 ../x.py test --target $TARGETS
3737

3838
# This is almost identical to the wasm32-unknown-emscripten target, so
3939
# running with assertions again is not useful

src/ci/docker/disabled/dist-aarch64-android/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ENV RUST_CONFIGURE_ARGS \
1919
--enable-extended \
2020
--enable-cargo-openssl-static
2121

22-
ENV SCRIPT python2.7 ../x.py dist --target $HOSTS --host $HOSTS
22+
ENV SCRIPT python3 ../x.py dist --target $HOSTS --host $HOSTS
2323

2424
COPY scripts/sccache.sh /scripts/
2525
RUN sh /scripts/sccache.sh

src/ci/docker/disabled/dist-armv7-android/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ ENV RUST_CONFIGURE_ARGS \
3333
# build to finish we use --warn-unresolved-symbols. Note that the missing
3434
# symbols does not affect std, only the compiler (llvm) and cargo (openssl).
3535
ENV SCRIPT \
36-
python2.7 ../x.py build src/llvm --host $HOSTS --target $HOSTS && \
36+
python3 ../x.py build src/llvm --host $HOSTS --target $HOSTS && \
3737
(export RUSTFLAGS="\"-C link-arg=-Wl,--warn-unresolved-symbols\""; \
3838
rm /android/ndk/arm && \
3939
ln -s /android/ndk/arm-14 /android/ndk/arm && \
40-
python2.7 ../x.py dist --host $HOSTS --target $HOSTS)
40+
python3 ../x.py dist --host $HOSTS --target $HOSTS)
4141

4242
COPY scripts/sccache.sh /scripts/
4343
RUN sh /scripts/sccache.sh

src/ci/docker/disabled/dist-i686-android/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ ENV RUST_CONFIGURE_ARGS \
3333
# build to finish we use --warn-unresolved-symbols. Note that the missing
3434
# symbols does not affect std, only the compiler (llvm) and cargo (openssl).
3535
ENV SCRIPT \
36-
python2.7 ../x.py build src/llvm --host $HOSTS --target $HOSTS && \
36+
python3 ../x.py build src/llvm --host $HOSTS --target $HOSTS && \
3737
(export RUSTFLAGS="\"-C link-arg=-Wl,--warn-unresolved-symbols\""; \
3838
rm /android/ndk/x86 && \
3939
ln -s /android/ndk/x86-14 /android/ndk/x86 && \
40-
python2.7 ../x.py dist --host $HOSTS --target $HOSTS)
40+
python3 ../x.py dist --host $HOSTS --target $HOSTS)
4141

4242
COPY scripts/sccache.sh /scripts/
4343
RUN sh /scripts/sccache.sh

src/ci/docker/disabled/dist-powerpcspe-linux/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python2.7 \
9+
python3 \
1010
git \
1111
cmake \
1212
sudo \
@@ -23,4 +23,4 @@ RUN sh /scripts/sccache.sh
2323
ENV HOSTS=powerpc-unknown-linux-gnuspe
2424

2525
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
26-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
26+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/disabled/dist-sparc64-linux/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python2.7 \
9+
python3 \
1010
git \
1111
cmake \
1212
sudo \
@@ -23,4 +23,4 @@ RUN sh /scripts/sccache.sh
2323
ENV HOSTS=sparc64-unknown-linux-gnu
2424

2525
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
26-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
26+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/disabled/dist-x86_64-android/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ENV RUST_CONFIGURE_ARGS \
1919
--enable-extended \
2020
--enable-cargo-openssl-static
2121

22-
ENV SCRIPT python2.7 ../x.py dist --target $HOSTS --host $HOSTS
22+
ENV SCRIPT python3 ../x.py dist --target $HOSTS --host $HOSTS
2323

2424
COPY scripts/sccache.sh /scripts/
2525
RUN sh /scripts/sccache.sh

src/ci/docker/disabled/dist-x86_64-dragonfly/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python2.7 \
9+
python3 \
1010
git \
1111
cmake \
1212
sudo \
@@ -33,4 +33,4 @@ ENV \
3333
ENV HOSTS=x86_64-unknown-dragonfly
3434

3535
ENV RUST_CONFIGURE_ARGS --enable-extended
36-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
36+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/disabled/dist-x86_64-haiku/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1818
make \
1919
nasm \
2020
pkg-config \
21-
python2.7 \
21+
python3 \
2222
sudo \
2323
texinfo \
2424
wget \
@@ -46,4 +46,4 @@ ENV RUST_CONFIGURE_ARGS --disable-jemalloc \
4646
--set=$TARGET.cc=x86_64-unknown-haiku-gcc \
4747
--set=$TARGET.cxx=x86_64-unknown-haiku-g++ \
4848
--set=$TARGET.llvm-config=/bin/llvm-config-haiku
49-
ENV SCRIPT python2.7 ../x.py dist --host=$HOST --target=$HOST
49+
ENV SCRIPT python3 ../x.py dist --host=$HOST --target=$HOST

src/ci/docker/disabled/dist-x86_64-redox/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ ENV \
1919
CXX_x86_64_unknown_redox=x86_64-unknown-redox-g++
2020

2121
ENV RUST_CONFIGURE_ARGS --enable-extended
22-
ENV SCRIPT python2.7 ../x.py dist --target x86_64-unknown-redox
22+
ENV SCRIPT python3 ../x.py dist --target x86_64-unknown-redox

src/ci/docker/dist-aarch64-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ ENV RUST_CONFIGURE_ARGS \
3636
--enable-extended \
3737
--enable-profiler \
3838
--disable-docs
39-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
39+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-android/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ENV RUST_CONFIGURE_ARGS \
3232
--x86_64-linux-android-ndk=/android/ndk/x86_64-21 \
3333
--disable-docs
3434

35-
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
35+
ENV SCRIPT python3 ../x.py dist --target $TARGETS
3636

3737
COPY scripts/sccache.sh /scripts/
3838
RUN sh /scripts/sccache.sh

src/ci/docker/dist-arm-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc \
2828
ENV HOSTS=arm-unknown-linux-gnueabi
2929

3030
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
31-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
31+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-armhf-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ ENV CC_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-gcc \
2828
ENV HOSTS=arm-unknown-linux-gnueabihf
2929

3030
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
31-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
31+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-armv7-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ ENV CC_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-gcc \
2828
ENV HOSTS=armv7-unknown-linux-gnueabihf
2929

3030
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
31-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
31+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-i586-gnu-i586-i686-musl/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python2.7 \
9+
python3 \
1010
git \
1111
cmake \
1212
xz-utils \
@@ -46,5 +46,5 @@ ENV CFLAGS_i586_unknown_linux_musl=-Wa,-mrelax-relocations=no
4646
ENV TARGETS=i586-unknown-linux-gnu,i686-unknown-linux-musl
4747

4848
ENV SCRIPT \
49-
python2.7 ../x.py test --target $TARGETS && \
50-
python2.7 ../x.py dist --target $TARGETS,i586-unknown-linux-musl
49+
python3 ../x.py test --target $TARGETS && \
50+
python3 ../x.py dist --target $TARGETS,i586-unknown-linux-musl

src/ci/docker/dist-i686-freebsd/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python2.7 \
9+
python3 \
1010
git \
1111
cmake \
1212
sudo \
@@ -30,4 +30,4 @@ ENV \
3030
ENV HOSTS=i686-unknown-freebsd
3131

3232
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
33-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
33+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-mips-linux/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python2.7 \
9+
python3 \
1010
git \
1111
cmake \
1212
sudo \
@@ -23,4 +23,4 @@ RUN sh /scripts/sccache.sh
2323
ENV HOSTS=mips-unknown-linux-gnu
2424

2525
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
26-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
26+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-mips64-linux/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python2.7 \
9+
python3 \
1010
git \
1111
cmake \
1212
sudo \
@@ -22,4 +22,4 @@ RUN sh /scripts/sccache.sh
2222
ENV HOSTS=mips64-unknown-linux-gnuabi64
2323

2424
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
25-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
25+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-mips64el-linux/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python2.7 \
9+
python3 \
1010
git \
1111
cmake \
1212
sudo \
@@ -23,4 +23,4 @@ RUN sh /scripts/sccache.sh
2323
ENV HOSTS=mips64el-unknown-linux-gnuabi64
2424

2525
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
26-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
26+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-mipsel-linux/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
file \
77
curl \
88
ca-certificates \
9-
python2.7 \
9+
python3 \
1010
git \
1111
cmake \
1212
sudo \
@@ -22,4 +22,4 @@ RUN sh /scripts/sccache.sh
2222
ENV HOSTS=mipsel-unknown-linux-gnu
2323

2424
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
25-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
25+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-powerpc-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ ENV \
3535
ENV HOSTS=powerpc-unknown-linux-gnu
3636

3737
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
38-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
38+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-powerpc64-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ ENV \
3636
ENV HOSTS=powerpc64-unknown-linux-gnu
3737

3838
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
39-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
39+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-powerpc64le-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ ENV \
3333
ENV HOSTS=powerpc64le-unknown-linux-gnu
3434

3535
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
36-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
36+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-s390x-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ ENV \
3535
ENV HOSTS=s390x-unknown-linux-gnu
3636

3737
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
38-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
38+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

0 commit comments

Comments
 (0)