Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit cfdccad

Browse files
committed
Initial release
0 parents  commit cfdccad

File tree

6 files changed

+314
-0
lines changed

6 files changed

+314
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build all packages
2+
on: workflow_dispatch
3+
jobs:
4+
native:
5+
runs-on: ubuntu-latest
6+
name: Build native packages
7+
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: satackey/[email protected]
11+
# Ignore the failure of a step and avoid terminating the job.
12+
continue-on-error: true
13+
14+
- name: Build the Docker image
15+
env:
16+
NAME: ${{ secrets.changelog_name }}
17+
EMAIL: ${{ secrets.changelog_email }}
18+
run: >-
19+
docker build
20+
--no-cache
21+
--target native
22+
--build-arg NAME
23+
--build-arg EMAIL
24+
-t native-build .
25+
26+
- name: Extract artifacts from image
27+
run: docker run -v /artifacts:/usr/local/src/python-source/artifacts native-build
28+
29+
- uses: actions/upload-artifact@v3
30+
with:
31+
name: native-debs
32+
path: /artifacts
33+
34+
crossbuild-armhf:
35+
runs-on: ubuntu-latest
36+
name: Crossbuild armhf packages
37+
needs: native
38+
39+
steps:
40+
- uses: actions/checkout@v3
41+
- uses: satackey/[email protected]
42+
# Ignore the failure of a step and avoid terminating the job.
43+
continue-on-error: true
44+
with:
45+
skip-save: true
46+
47+
- name: Build the Docker image
48+
env:
49+
NAME: ${{ secrets.changelog_name }}
50+
EMAIL: ${{ secrets.changelog_email }}
51+
run: >-
52+
docker build
53+
--target crossbuild
54+
--build-arg CROSSBUILD=armhf
55+
--build-arg NAME
56+
--build-arg EMAIL
57+
-t armhf-build .
58+
59+
- name: Extract artifacts from image
60+
run: docker run -v /artifacts:/usr/local/src/python-source/artifacts armhf-build
61+
62+
- uses: actions/upload-artifact@v3
63+
with:
64+
name: crossbuild-armhf
65+
path: /artifacts
66+
67+
crossbuild-arm64:
68+
runs-on: ubuntu-latest
69+
name: Crossbuild arm64 packages
70+
needs: native
71+
72+
steps:
73+
- uses: actions/checkout@v3
74+
- uses: satackey/[email protected]
75+
# Ignore the failure of a step and avoid terminating the job.
76+
continue-on-error: true
77+
with:
78+
skip-save: true
79+
80+
- name: Build the Docker image
81+
env:
82+
NAME: ${{ secrets.changelog_name }}
83+
EMAIL: ${{ secrets.changelog_email }}
84+
run: >-
85+
docker build
86+
--target crossbuild
87+
--build-arg CROSSBUILD=arm64
88+
--build-arg NAME
89+
--build-arg EMAIL
90+
-t arm64-build .
91+
92+
- name: Extract artifacts from image
93+
run: docker run -v /artifacts:/usr/local/src/python-source/artifacts arm64-build
94+
95+
- uses: actions/upload-artifact@v3
96+
with:
97+
name: crossbuild-arm64
98+
path: /artifacts

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM debian:bullseye-slim AS build-system
2+
RUN echo '\
3+
deb http://deb.debian.org/debian bookworm main\n\
4+
deb-src http://deb.debian.org/debian bookworm main' \
5+
>> /etc/apt/sources.list
6+
RUN echo '\
7+
Package: *\n\
8+
Pin: release n=bookworm\n\
9+
Pin-Priority: 1' \
10+
> /etc/apt/preferences.d/99pinning
11+
RUN apt-get update && apt-get upgrade -y
12+
RUN apt-get install -y --no-install-recommends devscripts equivs
13+
WORKDIR /usr/local/src
14+
RUN apt-get source python3.10
15+
RUN mv python3.10*/ python-source
16+
WORKDIR python-source
17+
ADD python3.10.diff .
18+
RUN patch -p1 < python3.10.diff
19+
ADD changelog_previous .
20+
RUN if [ -s changelog_previous ]; then echo "$(cat changelog_previous)\n\
21+
\n\
22+
$(cat debian/changelog)" > debian/changelog; fi
23+
ARG NAME
24+
ARG EMAIL
25+
ARG CHANGE
26+
RUN dch --bpo "$CHANGE"
27+
28+
FROM build-system AS native
29+
RUN mk-build-deps --install --tool 'apt-get -y --no-install-recommends'
30+
RUN debuild -b -uc -us
31+
RUN mkdir debs && mv ../*.deb debs
32+
CMD mkdir -p artifacts && cp -r debs/. artifacts && cp ../python3.10*.build ../python3.10*.buildinfo artifacts
33+
34+
FROM build-system AS crossbuild
35+
ARG CROSSBUILD
36+
RUN [ ! -z "$CROSSBUILD" ]
37+
RUN dpkg --add-architecture $CROSSBUILD
38+
RUN apt-get update
39+
COPY --from=native /usr/local/src/python-source/debs native-debs
40+
RUN cd native-debs && apt-get install -y ./libpython3.10-minimal*.deb \
41+
./libpython3.10-stdlib*.deb \
42+
./libpython3.10_*.deb \
43+
./python3.10-minimal*.deb \
44+
./python3.10_*.deb
45+
ADD crossbuild-dep.diff .
46+
RUN patch -p1 < crossbuild-dep.diff
47+
# For some reason mk-build-deps cannot install directly when cross-compiling
48+
RUN mk-build-deps --arch $CROSSBUILD --host-arch $CROSSBUILD
49+
RUN apt-get install -y --no-install-recommends ./python3.10-cross-build-deps*.deb
50+
RUN DEB_BUILD_OPTIONS='nocheck nobench' debuild -b -uc -us -a$CROSSBUILD
51+
RUN mkdir debs && mv ../*.deb debs
52+
CMD mkdir -p artifacts && cp -r debs/. artifacts && cp ../python3.10*.build ../python3.10*.buildinfo artifacts

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Python 3.10 backport for Debian 11 bullseye
2+
The aim of this project is to provide a Python 3.10 backport to Debian buster. Packages are of course much better manageable than compiling the source from scratch.
3+
4+
Motivation for this project was the [removal of Python 3.9 support in Home Assistant 2023.2.0](https://github.com/home-assistant/core/pull/85456). Debian bookworm doesn't have Python 3.10 however and Debian bookworm (which will contain Python 3.11) will not be released anytime before July 2023. In the meantime, you can use this backport.
5+
6+
More information about the use of this packages/repository for Home Assistant can be found on a [Home Assistant Community post](https://community.home-assistant.io/t/home-assistant-core-python-3-10-backport-for-debian-11-bullseye/528439) I've written.
7+
8+
## Scope
9+
The scope of this project is limited to backporting just Python 3.10 itself. So no defaults (which provide virtual packages so `python3` get's automatically linked to `python3.10`) and no precompiled pip-packages or wheels. Therefore it can coexist with your regular Python (3.9) installation without any interference and still being simple to maintain. It's main use is for in virtual environments where you can use pip to compile and install any packages you desire. It does provide all the packages and dependencies needed to create a Python 3.10 virtual environment.
10+
11+
Because their were problems when cross-compiling the `stdlib-extensions`, I've included the contents which would normally be in the `python3.10-distutils` package inside the `python3.10-venv` packages. This way you can create a Python 3.10 virtual environment without needing distutils as a seperate package.
12+
13+
Although Debian 11 at the moment still provides Python 3.10, it will not be available at release. Instead Python 3.11 will be the supported Python version for Debian 11. Therefore I am not sure if the maintainers will provide Python 3.10 updates in the mean time.
14+
15+
## Repository
16+
You can download the packages in my repository at `deb.pascalroeleven.nl` by adding this line to your sources.list:
17+
```sh
18+
deb http://deb.pascalroeleven.nl/python3.10 buster-backports main
19+
```
20+
You should also add my PGP (which you can get from my website via https) to APT's sources keyring:
21+
```sh
22+
wget -qO- https://pascalroeleven.nl/deb-pascalroeleven.gpg | sudo tee /etc/apt/trusted.gpg.d/deb-pascalroeleven.gpg
23+
```
24+
25+
Packages are built using Github actions along with a file containing the checksums of all packages. Therefore, you can compare the checksums of the packages in the repository with the checksums in Github Actions and trace the entire process (up to 90 days after the build after which the artifacts and logs get removed). This way, if you trust the Github Actions build system, you can be sure that the packages I provide are actually built using the instructions in this repo.
26+
27+
## Support
28+
Currently there is support for **`amd64`**, **`arm64`** and **`armhf`** architectures. The `amd64` packages are build natively while the `arm64` and `armhf` packages are crossbuilt. Testing is not possible while crossbuilding, so these packages did not undergo the same amount of testing as usual Debian packages do.
29+
30+
## Building the packages yourself
31+
If you want to build the packages yourself, you can use the Dockerfile and the patches in this repository. Patches will be applied by the Dockerfile.
32+
33+
Two targets are supported: `native` and `crossbuild`. You should specify either of these:
34+
```sh
35+
docker build --target native .
36+
```
37+
38+
When crossbuilding, you can specify the architecture by adding the `CROSSBUILD` build argument:
39+
```sh
40+
docker build --target crossbuild --build-arg CROSSBUILD=armhf .
41+
```
42+
43+
You can also specify your name, email and changelog message when building which will then be added to the changelog.
44+
```sh
45+
docker build --target native --build-arg NAME="James Smith" --build-arg EMAIL="[email protected]" --build-arg CHANGE="Initial backport for bullseye" .
46+
```
47+
48+
Building natively takes about 2 hours on a modern decent PC because of the extensive testing. Cross building takes about 30 minutes (but uses native binaries so requires the extra 2 hours the first time).
49+
50+
The packages can the be extracted from the image.
51+

changelog_previous

Whitespace-only changes.

crossbuild-dep.diff

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff -u a/debian/control b/debian/control
2+
--- a/debian/control
3+
+++ b/debian/control
4+
@@ -18,7 +18,7 @@
5+
net-tools, xvfb <!nocheck>, xauth <!nocheck>,
6+
systemtap-sdt-dev,
7+
valgrind-if-available,
8+
-Build-Depends-Indep: python3-sphinx, python3-docs-theme, texinfo
9+
+Build-Depends-Indep: python3-sphinx:all, python3-docs-theme:all, texinfo
10+
Standards-Version: 4.6.1
11+
Vcs-Browser: https://salsa.debian.org/cpython-team/python3/tree/python3.10
12+
Vcs-Git: https://salsa.debian.org/cpython-team/python3.git -b python3.10
13+
14+
diff -u a/debian/rules b/debian/rules
15+
--- a/debian/rules
16+
+++ b/debian/rules
17+
@@ -1456,7 +1456,7 @@
18+
done
19+
20+
: # devhelp docs
21+
- cd $(buildd_static) && ./python ../debian/pyhtml2devhelp.py \
22+
+ cd $(buildd_static) && python3.10 ../debian/pyhtml2devhelp.py \
23+
../$(d_doc)/usr/share/doc/$(p_base)/html index.html $(VER) \
24+
> ../$(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp
25+
gzip -9nv $(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp

python3.10.diff

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
--- a/debian/control
2+
+++ b/debian/control
3+
@@ -46,9 +46,7 @@
4+
Multi-Arch: allowed
5+
Priority: optional
6+
Depends: python3.10 (= ${binary:Version}),
7+
- python3-pip-whl,
8+
- python3-setuptools-whl,
9+
- python3.10-distutils,
10+
+ python-pip-whl,
11+
${shlibs:Depends}, ${misc:Depends},
12+
Breaks: python3-pip (<< 1.5.6-4)
13+
Description: Interactive high-level object-oriented language (pyvenv binary, version 3.10)
14+
@@ -176,7 +174,6 @@
15+
Section: libdevel
16+
Architecture: all
17+
Depends: python3.10 (>= ${binary:Version}), ${misc:Depends}, net-tools
18+
-Suggests: python3-gdbm, python3-tk
19+
Description: Testsuite for the Python standard library (v3.10)
20+
The complete testsuite for the Python standard library. Note that
21+
a subset is found in the libpython3.10-stdlib package, which should
22+
@@ -222,7 +209,6 @@
23+
Multi-Arch: allowed
24+
Depends: python3.10 (= ${binary:Version}), libpython3.10-dbg (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
25+
Recommends: gdb
26+
-Suggests: python3-gdbm-dbg, python3-tk-dbg
27+
Description: Debug Build of the Python Interpreter (version 3.10)
28+
The package holds two things:
29+
.
30+
--- a/debian/control.in
31+
+++ b/debian/control.in
32+
@@ -46,9 +46,7 @@
33+
Multi-Arch: allowed
34+
Priority: @PRIO@
35+
Depends: @PVER@ (= ${binary:Version}),
36+
- python3-pip-whl,
37+
- python3-setuptools-whl,
38+
- @PVER@-distutils,
39+
+ python-pip-whl,
40+
${shlibs:Depends}, ${misc:Depends},
41+
Breaks: python3-pip (<< 1.5.6-4)
42+
Description: Interactive high-level object-oriented language (pyvenv binary, version @VER@)
43+
@@ -176,7 +174,6 @@
44+
Section: libdevel
45+
Architecture: all
46+
Depends: @PVER@ (>= ${binary:Version}), ${misc:Depends}, net-tools
47+
-Suggests: python3-gdbm, python3-tk
48+
Description: Testsuite for the Python standard library (v@VER@)
49+
The complete testsuite for the Python standard library. Note that
50+
a subset is found in the lib@PVER@-stdlib package, which should
51+
@@ -222,7 +209,6 @@
52+
Multi-Arch: allowed
53+
Depends: @PVER@ (= ${binary:Version}), lib@PVER@-dbg (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
54+
Recommends: gdb
55+
-Suggests: python3-gdbm-dbg, python3-tk-dbg
56+
Description: Debug Build of the Python Interpreter (version @VER@)
57+
The package holds two things:
58+
.
59+
--- a/debian/rules
60+
+++ a/debian/rules
61+
@@ -1143,12 +1143,6 @@
62+
: # Tkinter library files shipped in python3-tk
63+
rm -rf $(d)/usr/lib/python$(VER)/tkinter
64+
65+
- : # distutils shipped in python3-distutils
66+
- rm -rf $(d)/usr/lib/python$(VER)/distutils/*
67+
- : # ... except for distutils.version
68+
- cp Lib/distutils/{__init__,version}.py \
69+
- $(d)/usr/lib/python$(VER)/distutils/.
70+
-
71+
: # lib2to3 shipped in python3-lib2to3
72+
rm -rf \
73+
$(d)/usr/bin/2to3-$(VER) \
74+
@@ -1223,11 +1217,13 @@
75+
cp -p debian/README.Tk $(d_tk)/usr/share/doc/$(p_tk)/
76+
endif
77+
78+
- : # pyvenv and ensurepip files into $(p_venv)
79+
+ : # pyvenv, distutils and ensurepip files into $(p_venv)
80+
dh_installdirs -p$(p_venv) \
81+
usr/lib/python$(VER)
82+
dh_movefiles -p$(p_venv) \
83+
usr/lib/python$(VER)/ensurepip
84+
+ dh_movefiles -p$(p_venv) \
85+
+ usr/lib/python$(VER)/distutils
86+
87+
: # library files into $(p_lbase)
88+
dh_installdirs -p$(p_lbase) \

0 commit comments

Comments
 (0)