Skip to content

Commit fb2d713

Browse files
authored
feat: install from python:2.7-slim, version constraint v1.24.10 (#14)
1 parent c67a5bd commit fb2d713

File tree

6 files changed

+54
-15
lines changed

6 files changed

+54
-15
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
```bash
1616
ddev add-on get https://github.com/stasadev/ddev-python2/tarball/refs/pull/REPLACE_ME_WITH_THIS_PR_NUMBER/head
1717
ddev restart
18-
ddev exec python -V
18+
ddev exec python --version
19+
ddev exec pip --version
1920
```
2021

2122
## Automated Testing Overview

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ After installation, make sure to commit the `.ddev` directory to version control
2626

2727
| Command | Description |
2828
| ------- | ----------- |
29-
| `ddev exec python2.7` | Run Python 2.7.18 inside the `web` container.<br>Installed at `/usr/bin/python2.7` |
30-
| `ddev exec python` | Run Python 2.7.18 inside the `web` container.<br>Symlink at `/usr/local/bin/python` |
29+
| `ddev exec python` | Run Python 2.7.18 inside the `web` container.<br>Installed at `/usr/local/bin/python` |
30+
| `ddev exec pip` | Run pip 20.0.2 inside the `web` container.<br>Installed at `/usr/local/bin/pip` |
3131

3232
This add-on also installs the `build-essential` package, which is usually required for the `npm build`, see [config.python2.yaml](./config.python2.yaml). Remove or replace the contents of this file if you only need Python 2.
3333

docker-compose.python2.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ddev-generated
2+
services:
3+
# This service is only used to pull the Docker image for offline use.
4+
python2:
5+
image: python:2.7-slim-${DDEV_SITENAME}-built
6+
profiles:
7+
- python2

install.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: python2
22

33
project_files:
44
- config.python2.yaml
5+
- docker-compose.python2.yaml
56
- web-build/Dockerfile.python2
67

7-
ddev_version_constraint: '>= v1.23.5'
8+
ddev_version_constraint: '>= v1.24.10'

tests/test.bats

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,37 @@ setup() {
3939
}
4040

4141
health_checks() {
42-
run ddev exec python -V
42+
run ddev exec python --version
4343
assert_success
4444
assert_output "Python 2.7.18"
4545

46-
run ddev exec python2.7 -V
46+
run ddev exec python2 --version
4747
assert_success
4848
assert_output "Python 2.7.18"
49+
50+
run ddev exec python2.7 --version
51+
assert_success
52+
assert_output "Python 2.7.18"
53+
54+
run ddev exec pip --version
55+
assert_success
56+
assert_output "pip 20.0.2 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)"
57+
58+
run ddev exec pip2 --version
59+
assert_success
60+
assert_output "pip 20.0.2 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)"
61+
62+
run ddev exec pip2.7 --version
63+
assert_success
64+
assert_output "pip 20.0.2 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)"
65+
66+
run ddev exec python -c "import hashlib; print('MD5:', hashlib.md5('test').hexdigest())"
67+
assert_success
68+
assert_output "('MD5:', '098f6bcd4621d373cade4e832627b4f6')"
69+
70+
run ddev exec python -c "import ssl; print('SSL:', ssl.OPENSSL_VERSION)"
71+
assert_success
72+
assert_output "('SSL:', 'OpenSSL 1.1.1d 10 Sep 2019')"
4973
}
5074

5175
teardown() {

web-build/Dockerfile.python2

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
#ddev-generated
2-
# Adapted from https://web.archive.org/web/20250223192706/https://www.fadedbee.com/2024/01/18/installing-python2-on-debian-12-bookworm/
2+
COPY --from=python:2.7-slim /usr/local /usr/local
3+
COPY --from=python:2.7-slim /usr/lib /tmp/python2-libs
34
ARG TARGETARCH
4-
RUN mkdir -p /tmp/python2 && \
5-
wget -O /tmp/python2/python2.7.tar.gz https://github.com/stasadev/ddev-python2/releases/download/v1.0.1/python2.7_${TARGETARCH}.tar.gz && \
6-
tar -xzf /tmp/python2/python2.7.tar.gz -C /tmp/python2 && \
7-
source /etc/os-release && \
8-
if [ "$VERSION_CODENAME" = "bookworm" ]; then rm -f /tmp/python2/libnsl2*.deb /tmp/python2/libtirpc3t64*.deb; fi && \
9-
dpkg -i /tmp/python2/*.deb && \
10-
rm -rf /tmp/python2 && \
11-
ln -s /usr/bin/python2.7 /usr/local/bin/python
5+
RUN if [ "$TARGETARCH" = "amd64" ]; then \
6+
LIB_ARCH="x86_64-linux-gnu"; \
7+
elif [ "$TARGETARCH" = "arm64" ]; then \
8+
LIB_ARCH="aarch64-linux-gnu"; \
9+
else \
10+
echo "Unsupported architecture: $TARGETARCH"; exit 1; \
11+
fi && \
12+
echo "Detected architecture: $TARGETARCH ($LIB_ARCH)" && \
13+
mkdir -p /usr/lib/$LIB_ARCH && \
14+
cp /tmp/python2-libs/*/libssl.so.1.1 /usr/lib/$LIB_ARCH/ && \
15+
cp /tmp/python2-libs/*/libcrypto.so.1.1 /usr/lib/$LIB_ARCH/ && \
16+
rm -rf /tmp/python2-libs && \
17+
ldconfig

0 commit comments

Comments
 (0)