Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.13t #218

Merged
merged 7 commits into from
Oct 12, 2024
Merged

3.13t #218

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ COPY --link scripts/build_python.sh /

# ------------------------------------------------------------------------------
FROM builder-py-base as builder-py-3_12
RUN /build_python.sh 3.12.5
RUN /build_python.sh 3.12.7
# ------------------------------------------------------------------------------
FROM builder-py-base as builder-py-3_13
RUN /build_python.sh 3.13.0rc3
# ------------------------------------------------------------------------------
FROM builder-py-base as builder-py-3_13t
# Building with all 3 of the options below causes tests to fail.
# Removing just the first means the image is a bit bigger, but we keep optimisations
# --disable-test-modules --enable-optimizations --with-lto
ENV PYTHON_CONFIGURE_OPTS='--enable-optimizations --with-lto --with-system-expat --without-ensurepip'
RUN /build_python.sh 3.13.0rc3t
# ------------------------------------------------------------------------------
FROM python:3.12-slim-bookworm as base

ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
Expand All @@ -56,6 +63,7 @@ RUN apt-get -y update \
COPY --link --from=builder-nsjail /nsjail/nsjail /usr/sbin/
COPY --link --from=builder-py-3_12 /snekbin/ /snekbin/
COPY --link --from=builder-py-3_13 /snekbin/ /snekbin/
COPY --link --from=builder-py-3_13t /snekbin/ /snekbin/

RUN chmod +x /usr/sbin/nsjail \
&& ln -s /snekbin/python/3.12/ /snekbin/python/default
Expand Down
4 changes: 2 additions & 2 deletions requirements/eval-deps.pip
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fishhook~=0.3; python_version == '3.12'
forbiddenfruit~=0.1
fuzzywuzzy~=0.18
lark~=1.2
matplotlib~=3.9
matplotlib~=3.9 ; python_version != '3.13'
ChrisLovering marked this conversation as resolved.
Show resolved Hide resolved
more-itertools~=10.5
networkx~=3.3
numpy~=2.1
Expand All @@ -16,7 +16,7 @@ pendulum~=3.0 ; python_version == '3.12'
pyarrow~=17.0; python_version == '3.12'
python-dateutil~=2.9
pyyaml~=6.0
scipy~=1.14
scipy~=1.14 ; python_version != '3.13'
sympy~=1.13
typing-extensions~=4.12
tzdata~=2024.2
Expand Down
14 changes: 11 additions & 3 deletions scripts/build_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ shopt -s inherit_errexit

py_version="${1}"

# Install Python interpreter under e.g. /snekbin/python/3.11/ (no patch version).
# Install Python interpreter under e.g. /snekbin/python/3.13/ (no patch version)
# By dropping everything after, and including, the last period or hyphen.
install_path="${py_version%[-.]*}"

# If python version ends with a t, then ensure Python is installed to a dir ending with a t.
if [[ $py_version == *t ]]; then
install_path+="t"
fi

"${PYENV_ROOT}/plugins/python-build/bin/python-build" \
"${py_version}" \
"/snekbin/python/${py_version%[-.]*}"
"/snekbin/python/${py_version%[-.]*}/bin/python" -m pip install -U pip
"/snekbin/python/${install_path}"
"/snekbin/python/${install_path}/bin/python" -m pip install -U pip

# Clean up some unnecessary files to reduce image size bloat.
find /snekbin/python/ -depth \
Expand Down
20 changes: 20 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ def test_alternate_executable_support(self):
self.assertEqual(status, 200)
self.assertEqual(json.loads(response)["stdout"], expected)

def test_gil_status(self):
"""Test no-gil builds actually don't have a gil."""
with run_gunicorn():
get_gil_status = {
"input": "import sysconfig; print(sysconfig.get_config_var('Py_GIL_DISABLED'))"
}
cases = [
("3.13", "0\n"),
("3.13t", "1\n"),
]
for version, expected in cases:
with self.subTest(version=version, expected=expected):
payload = {
"executable_path": f"/snekbin/python/{version}/bin/python",
**get_gil_status,
}
response, status = snekbox_request(payload)
self.assertEqual(status, 200)
self.assertEqual(json.loads(response)["stdout"], expected)

def invalid_executable_paths(self):
"""Test that passing invalid executable paths result in no code execution."""
with run_gunicorn():
Expand Down