diff --git a/Dockerfile b/Dockerfile index fb803b40..17415c0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,8 +39,8 @@ RUN yarn run build:prod ## Python collection stage ################################################################################ -# Fetch python3.9 and python2.7 -FROM python:3.9-slim-buster as collector +# Fetch python3.11 and python2.7 +FROM python:3.11-slim-buster as collector # Install all python dependencies. ADD sandbox/requirements.txt requirements.txt @@ -89,13 +89,13 @@ COPY --from=builder /grist/static /grist/static-built COPY --from=collector /usr/bin/python2.7 /usr/bin/python2.7 COPY --from=collector /usr/lib/python2.7 /usr/lib/python2.7 COPY --from=collector /usr/local/lib/python2.7 /usr/local/lib/python2.7 -COPY --from=collector /usr/local/bin/python3.9 /usr/bin/python3.9 -COPY --from=collector /usr/local/lib/python3.9 /usr/local/lib/python3.9 -COPY --from=collector /usr/local/lib/libpython3.9.* /usr/local/lib/ +COPY --from=collector /usr/local/bin/python3.11 /usr/bin/python3.11 +COPY --from=collector /usr/local/lib/python3.11 /usr/local/lib/python3.11 +COPY --from=collector /usr/local/lib/libpython3.11.* /usr/local/lib/ # Set default to python3 RUN \ - ln -s /usr/bin/python3.9 /usr/bin/python && \ - ln -s /usr/bin/python3.9 /usr/bin/python3 && \ + ln -s /usr/bin/python3.11 /usr/bin/python && \ + ln -s /usr/bin/python3.11 /usr/bin/python3 && \ ldconfig # Copy runsc. diff --git a/README.md b/README.md index 11671716..922a090b 100644 --- a/README.md +++ b/README.md @@ -377,7 +377,7 @@ Then, you can run the main test suite like so: yarn test ``` -Python tests may also be run locally. (Note: currently requires Python 3.9.) +Python tests may also be run locally. (Note: currently requires Python 3.9 - 3.11.) ``` yarn test:python diff --git a/app/server/lib/NSandbox.ts b/app/server/lib/NSandbox.ts index ad31b8e4..f2e9be8a 100644 --- a/app/server/lib/NSandbox.ts +++ b/app/server/lib/NSandbox.ts @@ -1021,9 +1021,13 @@ function findPython(command: string|undefined, preferredVersion?: string) { } } // Fall back on system python. - return which.sync(preferredVersion === '2' ? 'python2' : 'python3', {nothrow: true}) - || which.sync(preferredVersion === '2' ? 'python2.7' : 'python3.9', {nothrow: true}) - || which.sync('python'); + const systemPrefs = preferredVersion === '2' ? ['2.7', '2', ''] : ['3.11', '3.10', '3.9', '3', '']; + for (const version of systemPrefs) { + const pythonPath = which.sync(`python${version}`, {nothrow: true}); + if (pythonPath) { + return pythonPath; + } + } } /** diff --git a/documentation/develop.md b/documentation/develop.md index 84cf4dde..e95b5b01 100644 --- a/documentation/develop.md +++ b/documentation/develop.md @@ -10,8 +10,7 @@ To setup your environment, you would need to install the following dependencies: - git - [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md) (recommended) or nodejs installed on your system - Chromium to run the end-to-end tests - - Python (preferably Python 3.9) and virtualenv - - :warning: As of 2023-06-06, Python 3.11 is not supported due to the version of the [wrapt dependency](https://github.com/GrahamDumpleton/wrapt/issues/196) + - Python (preferably Python 3.11, minimum 3.9) and virtualenv ### Clone the repository @@ -61,7 +60,7 @@ You can also use nodejs installed in your system. To prevent incompatibilities, Be sure to have Python and virtualenv installed. On debian-based Linux distributions, you can simply run the following command as root: ```bash -# apt install python3.9 python3.9-venv +# apt install python3.11 python3.11-venv ``` ### Install the project dependencies and build diff --git a/sandbox/docker/Dockerfile b/sandbox/docker/Dockerfile index eb8b7799..3e09f4f0 100644 --- a/sandbox/docker/Dockerfile +++ b/sandbox/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9 +FROM python:3.11 COPY requirements3.txt /tmp/requirements3.txt diff --git a/sandbox/gvisor/run.py b/sandbox/gvisor/run.py index 1cf3c238..61a6b916 100755 --- a/sandbox/gvisor/run.py +++ b/sandbox/gvisor/run.py @@ -173,9 +173,9 @@ if not include_python2: # We expect python3 in /usr/bin or /usr/local/bin. candidates = [ path - # Pick the most generic python if not matching python3.9. + # Pick the most generic python if not matching python3.11. # Sorry this is delicate because of restores, mounts, symlinks. - for pattern in ['python3.9', 'python3', 'python3*'] + for pattern in ['python3.11', 'python3.10', 'python3.9', 'python3', 'python3*'] for root in ['/usr/local', '/usr'] for path in glob.glob(f'{root}/bin/{pattern}') if os.path.exists(path) diff --git a/sandbox/requirements3.in b/sandbox/requirements3.in index 033e03ab..c8f9a4f2 100644 --- a/sandbox/requirements3.in +++ b/sandbox/requirements3.in @@ -12,3 +12,4 @@ python-dateutil six sortedcontainers unittest-xml-reporting +typing-extensions # used by astroid before Python 3.11 diff --git a/sandbox/requirements3.txt b/sandbox/requirements3.txt index 53acc46e..ef5dc1a8 100644 --- a/sandbox/requirements3.txt +++ b/sandbox/requirements3.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.9 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile --output-file=core/sandbox/requirements3.txt core/sandbox/requirements3.in @@ -48,7 +48,7 @@ sortedcontainers==2.4.0 stack-data==0.5.1 # via friendly-traceback typing-extensions==4.4.0 - # via astroid + # via -r core/sandbox/requirements3.in unittest-xml-reporting==2.0.0 # via -r core/sandbox/requirements3.in wrapt==1.15.0