Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Commit

Permalink
Intial release
Browse files Browse the repository at this point in the history
  • Loading branch information
pascallj committed Oct 11, 2020
0 parents commit ef2eb60
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM debian:buster-slim AS build-system
RUN echo 'deb http://deb.debian.org/debian bullseye main\n\
deb-src http://deb.debian.org/debian bullseye main'\
>> /etc/apt/sources.list
RUN echo 'Package: *\n\
Pin: release n=bullseye\n\
Pin-Priority: 1'\
> /etc/apt/preferences.d/99bullseye-testing
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y build-essential fakeroot devscripts
WORKDIR /usr/local/src
RUN apt-get source python3.8
RUN mv python3.8*/ python-source
WORKDIR python-source
ADD distutils-dep.diff debian/patches/
RUN echo 'distutils-dep.diff' >> debian/patches/series
ARG NAME
ARG EMAIL
ARG CHANGE=Backport
RUN dch --bpo "$CHANGE"

FROM build-system AS native
RUN mk-build-deps --install --tool 'apt-get -y --no-install-recommends'
RUN debuild -b -uc -us
RUN mkdir debs && mv ../*.deb debs

FROM build-system AS crossbuild
ARG CROSSBUILD
RUN [ ! -z "$CROSSBUILD" ]
RUN dpkg --add-architecture $CROSSBUILD
RUN apt-get update
COPY --from=native /usr/local/src/python-source/debs native-debs
RUN cd native-debs && apt-get install -y ./libpython3.8-minimal*.deb \
./libpython3.8-stdlib*.deb \
./libpython3.8_*.deb \
./python3.8-minimal*.deb \
./python3.8_*.deb
ADD crossbuild-dep.diff .
RUN patch -p1 < crossbuild-dep.diff
# For some reason mk-build-deps cannot install directly when cross-compiling
RUN mk-build-deps --arch $CROSSBUILD --host-arch $CROSSBUILD
RUN apt-get install -y ./python3.8-cross-build-deps*.deb
RUN DEB_BUILD_OPTIONS='nocheck nobench' debuild -b -uc -us -a$CROSSBUILD
RUN mkdir debs && mv ../*.deb debs
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Python 3.8 Backport for Debian buster

The aim of this project is to provide a Python 3.8 backport to Debian buster. Packages are of course much better manageable then compiling the source from scratch.

Motivation for this project was the [deprecation of Python 3.7 support in Home Assistant](https://www.home-assistant.io/blog/2020/10/07/release-116/#python-37-deprecated). Support ends in version 0.118 which is scheduled for somewhere in December. While Debian bullseye will not be released anytime before Apil 2021. In the meantime, you can use this backport.

## Scope
The scope of this project is limited to backporting just Python 3.8 itself. So no defaults (which provide virtual packages so `python3` get's automatically linked to `python3.8`), no pip and no pip-packages. This version should be an extension to your system, but it's not meant to replace an existing Python installation.

### Virtual enviroment
To make the `venv` module work without backporting all pip-related packages, the `python3.8-venv` package depends on `python3-distutils` which is present in buster. After you have created your virtual enviroment you can then update pip itself and any packages as usual.

## Repository
You can download the packages in my repository at `deb.pascalroeleven.nl` by adding this line to your sources.list:
```sh
deb http://deb.pascalroeleven.nl/python3.8 buster-backports main
```
You should also add my PGP (which you can get from my website via https) to APT's sources keyring:
```sh
wget https://pascalroeleven.nl/deb-pascalroeleven.gpg
sudo apt-key add deb-pascalroeleven.gpg
```

## Support
Currently there is support for **`amd64`** and **`armhf`** architectures. The `amd64` packages are build natively while the `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.

## Building the packages yourself
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.

Two targets are supported: `native` and `crossbuild`. You should specify either of these:
```sh
docker build --target native .
```

When crossbuilding, you can specify the architecture by adding the `CROSSBUILD` build argument:
```sh
docker build --target crossbuild --build-arg CROSSBUILD=armhf .
```

You can also specify your name, email and changelog message when building which will then be added to the changelog.
```sh
docker build --target native --build-arg NAME="James Smith" --build-arg EMAIL="[email protected]" --build-arg CHANGE="Initial backport for buster" .
```

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).
27 changes: 27 additions & 0 deletions crossbuild-dep.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Index: b/debian/control
===================================================================
--- a/debian/control
+++ b/debian/control
@@ -18,7 +18,7 @@
mime-support, netbase, bzip2, time, python3@bd_qual@, @PVER@@bd_qual@ <cross>,
net-tools, xvfb <!nocheck>, xauth <!nocheck>,
systemtap-sdt-dev
-Build-Depends-Indep: python3-sphinx, python3-docs-theme, texinfo
+Build-Depends-Indep: python3-sphinx:all, python3-docs-theme:all, texinfo
Standards-Version: 4.5.0
Vcs-Browser: https://salsa.debian.org/cpython-team/python3/tree/python3.8
Vcs-Git: https://salsa.debian.org/cpython-team/python3.git -b python3.8

Index: b/debian/rules
===================================================================
--- a/debian/rules
+++ b/debian/rules
@@ -1353,7 +1353,7 @@
done

: # devhelp docs
- cd $(buildd_static) && ./python ../debian/pyhtml2devhelp.py \
+ cd $(buildd_static) && python3.8 ../debian/pyhtml2devhelp.py \
../$(d_doc)/usr/share/doc/$(p_base)/html index.html $(VER) \
> ../$(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp
gzip -9nv $(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp
43 changes: 43 additions & 0 deletions distutils-dep.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Index: b/debian/control.in
===================================================================
--- a/debian/control.in
+++ b/debian/control.in
@@ -45,7 +45,7 @@
Architecture: any
Multi-Arch: allowed
Priority: @PRIO@
-Depends: @PVER@ (= ${binary:Version}),
+Depends: @PVER@ (= ${binary:Version}), python3-distutils (>=3.7.3-1),
python-pip-whl (>= 8.1.0-2), ${shlibs:Depends}, ${misc:Depends},
Breaks: python3-pip (<< 1.5.6-4)
Description: Interactive high-level object-oriented language (pyvenv binary, version @VER@)

Index: b/debian/PVER-venv.postinst.in
===================================================================
--- a/debian/PVER-venv.postinst.in
+++ b/debian/PVER-venv.postinst.in
@@ -15,6 +15,9 @@
fi
esac

+rm -rf /usr/lib/@PVER@/distutils
+ln -s /usr/lib/python3.7/distutils /usr/lib/@PVER@
+
#DEBHELPER#

exit 0

Index: b/debian/PVER-venv.postrm.in
===================================================================
--- a/debian/PVER-venv.postrm.in
+++ b/debian/PVER-venv.postrm.in
@@ -7,6 +7,8 @@
rm -rf /var/lib/python-wheels
fi

+rm /usr/lib/@PVER@/distutils
+
#DEBHELPER#

exit 0

0 comments on commit ef2eb60

Please sign in to comment.