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

Remove Python 2.7 support #11654

Merged
merged 7 commits into from
Dec 15, 2023
Merged
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
6 changes: 4 additions & 2 deletions .github/workflows/build_pex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ jobs:
build_pex:
name: Build PEX
runs-on: ubuntu-20.04
rtibbles marked this conversation as resolved.
Show resolved Hide resolved
container:
image: python:2.7.18-buster
outputs:
pex-file-name: ${{ steps.get-pex-filename.outputs.pex-file-name }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.6
uses: actions/setup-python@v4
with:
python-version: 3.6
- uses: actions/cache@v3
with:
path: ~/.cache/pip
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/build_whl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,26 @@ jobs:
build_whl:
name: Build WHL
runs-on: ubuntu-20.04
container:
image: python:2.7.18-buster
outputs:
whl-file-name: ${{ steps.get-whl-filename.outputs.whl-file-name }}
tar-file-name: ${{ steps.get-tar-filename.outputs.tar-file-name }}
steps:
- name: Install Git LFS
run: |
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
apt-get install git-lfs
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Install Ubuntu dependencies
run: |
apt-get -y -qq update
apt-get install -y gettext sudo
sudo apt-get -y -qq update
sudo apt-get install -y gettext
- name: Set up Python 3.6
uses: actions/setup-python@v4
with:
python-version: 3.6
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Install Yarn
run: npm install -g yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
Expand Down
32 changes: 14 additions & 18 deletions .github/workflows/c_extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ jobs:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-20.04
container:
image: python:2.7.18-buster
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.6
- name: pip cache
uses: actions/cache@v3
with:
Expand All @@ -54,27 +52,25 @@ jobs:
# in the kolibri directory
python -m compileall -q kolibri -x py2only
# Until we have staged builds, we will be running this in each and every
# environment even though builds should be done in Py 2.7
# environment even though builds should be done in Py 3.6
make staticdeps
make staticdeps-cext
pip install .
# Start and stop kolibri - disabled until we can move out of a container
# kolibri start --port=8081
# kolibri stop
# Start and stop kolibri
coverage run -p kolibri start --port=8081
coverage run -p kolibri stop
# Run just tests in test/
py.test --cov=kolibri --cov-report= --cov-append --color=no test/
no_c_ext:
name: No C Extensions
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-20.04
container:
image: python:2.7.18-buster
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.6
- name: pip cache
uses: actions/cache@v3
with:
Expand All @@ -94,11 +90,11 @@ jobs:
# in the kolibri directory
python -m compileall -q kolibri -x py2only
# Until we have staged builds, we will be running this in each and every
# environment even though builds should be done in Py 2.7
# environment even though builds should be done in Py 3.6
make staticdeps
pip install .
# Start and stop kolibri - disabled until we can move out of a container
# kolibri start --port=8081
# kolibri stop
# Start and stop kolibri
coverage run -p kolibri start --port=8081
coverage run -p kolibri stop
# Run just tests in test/
py.test --cov=kolibri --cov-report= --cov-append --color=no test/
41 changes: 0 additions & 41 deletions .github/workflows/python2lint.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,6 @@ jobs:
- name: Test with tox
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: tox -e py${{ matrix.python-version }}
unit_test27:
name: Python unit tests (2.7)
needs: pre_job
runs-on: ubuntu-20.04
container:
image: python:2.7.18-buster
steps:
- uses: actions/checkout@v4
- name: Install tox
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: |
python -m pip install --upgrade pip
pip install "tox<4"
- name: tox env cache
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.tox/py2.7
key: ${{ runner.os }}-tox-py2.7-${{ hashFiles('requirements/*.txt') }}
- name: Test with tox
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: tox -e py2.7
postgres:
name: Python postgres unit tests
needs: pre_job
Expand Down
18 changes: 4 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SHELL := /bin/bash

# List most target names as 'PHONY' to prevent Make from thinking it will be creating a file of the same name
.PHONY: help clean clean-assets clean-build clean-pyc clean-docs lint test test-all assets coverage docs release test-namespaced-packages staticdeps staticdeps-cext writeversion setrequirements buildconfig pex i18n-extract-frontend i18n-extract-backend i18n-transfer-context i18n-extract i18n-django-compilemessages i18n-upload i18n-pretranslate i18n-pretranslate-approve-all i18n-download i18n-regenerate-fonts i18n-stats i18n-install-font i18n-download-translations i18n-download-glossary i18n-upload-glossary docker-whl docker-demoserver docker-devserver docker-envlist
.PHONY: help clean clean-assets clean-build clean-pyc clean-docs lint test test-all assets coverage docs release staticdeps staticdeps-cext writeversion setrequirements buildconfig pex i18n-extract-frontend i18n-extract-backend i18n-transfer-context i18n-extract i18n-django-compilemessages i18n-upload i18n-pretranslate i18n-pretranslate-approve-all i18n-download i18n-regenerate-fonts i18n-stats i18n-install-font i18n-download-translations i18n-download-glossary i18n-upload-glossary docker-whl docker-demoserver docker-devserver docker-envlist


help:
Expand Down Expand Up @@ -33,7 +33,6 @@ help:
@echo "test: run tests quickly with the default Python"
@echo "test-all: run tests on every Python version with Tox"
@echo "test-with-postgres: run tests quickly with a temporary postgresql backend"
@echo "test-namespaced-packages: verify that we haven't fetched anything namespaced into kolibri/dist"
@echo "coverage: run tests, recording and printing out Python code coverage"
@echo "docs: generate developer documentation"
@echo "start-foreground-with-postgres: run Kolibri in foreground mode with a temporary postgresql backend"
Expand Down Expand Up @@ -152,30 +151,21 @@ release:
@read __
twine upload -s dist/*

test-namespaced-packages:
# This expression checks that everything in kolibri/dist has an __init__.py
# To prevent namespaced packages from suddenly showing up
# https://github.com/learningequality/kolibri/pull/2972
! find kolibri/dist -mindepth 1 -maxdepth 1 -type d -not -name __pycache__ -not -name cext -not -name py2only -not -name *dist-info -exec ls {}/__init__.py \; 2>&1 | grep "No such file"

clean-staticdeps:
rm -rf kolibri/dist/* || true # remove everything
git checkout -- kolibri/dist # restore __init__.py

staticdeps: clean-staticdeps
test "${SKIP_PY_CHECK}" = "1" || python2 --version 2>&1 | grep -q 2.7 || ( echo "Only intended to run on Python 2.7" && exit 1 )
pip2 install -t kolibri/dist -r "requirements.txt"
test "${SKIP_PY_CHECK}" = "1" || python --version 2>&1 | grep -q 3.6 || ( echo "Only intended to run on Python 3.6" && exit 1 )
pip install -t kolibri/dist -r "requirements.txt"
rm -rf kolibri/dist/*.egg-info
rm -r kolibri/dist/man kolibri/dist/bin || true # remove the two folders introduced by pip 10
python2 build_tools/py2only.py # move `future` and `futures` packages to `kolibri/dist/py2only`
make test-namespaced-packages

staticdeps-cext:
rm -rf kolibri/dist/cext || true # remove everything
python build_tools/install_cexts.py --file "requirements/cext.txt" # pip install c extensions
pip install -t kolibri/dist/cext -r "requirements/cext_noarch.txt" --no-deps
rm -rf kolibri/dist/*.egg-info
make test-namespaced-packages

staticdeps-compileall:
bash -c 'python --version'
Expand Down Expand Up @@ -209,7 +199,7 @@ read-whl-file-version:
python ./build_tools/read_whl_version.py ${whlfile} > kolibri/VERSION

pex:
ls dist/*.whl | while read whlfile; do $(MAKE) read-whl-file-version whlfile=$$whlfile; pex $$whlfile --disable-cache -o dist/kolibri-`cat kolibri/VERSION | sed 's/+/_/g'`.pex -m kolibri --python-shebang=/usr/bin/python; done
ls dist/*.whl | while read whlfile; do $(MAKE) read-whl-file-version whlfile=$$whlfile; pex $$whlfile --disable-cache -o dist/kolibri-`cat kolibri/VERSION | sed 's/+/_/g'`.pex -m kolibri --python-shebang=/usr/bin/python3; done

i18n-extract-backend:
cd kolibri && python -m kolibri manage makemessages -- -l en --ignore 'node_modules/*' --ignore 'kolibri/dist/*'
Expand Down
10 changes: 3 additions & 7 deletions build_tools/install_cexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
This module defines functions to install c extensions for all the platforms into
Kolibri.

It is required to have pip version greater than 19.3.1 to run this script.
See requirements/build.txt for the list of requirements that must be installed for this
script to run.
Usage:
> python build_tools/install_cexts.py --file "requirements/cext.txt" --cache-path "/cext_cache"

Expand Down Expand Up @@ -170,8 +171,6 @@ def parse_package_page(files, pk_version, index_url, cache_path):
* not the version specified in requirements.txt
* not python versions that kolibri does not support
* not macosx
* not win_x64 with python 3.8
* not win32 with python 3.8
"""

result = []
Expand All @@ -191,13 +190,10 @@ def parse_package_page(files, pk_version, index_url, cache_path):

if package_version != pk_version:
continue
if python_version != "27" and python_version not in supported_python3_versions:
if python_version not in supported_python3_versions:
continue
if "macosx" in platform:
continue
if "win_amd64" in platform or "win32" in platform and python_version == "27":
# Don't install win_amd64 or win32 with python 2.7
continue

info = {
"platform": platform,
Expand Down
55 changes: 0 additions & 55 deletions build_tools/py2only.py

This file was deleted.

2 changes: 1 addition & 1 deletion docker/build_whl.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN apt-get update && \
gettext \
git \
git-lfs \
python2.7 \
python3.6 \
python-pip \
python-sphinx

Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Python and Pip

To develop on Kolibri, you'll need:

* Python 3.4+ or Python 2.7+ (Kolibri doesn't currently support Python 3.11.0 or higher)
* Python 3.6+ (Kolibri doesn't currently support Python 3.12.0 or higher)
* `pip <https://pypi.python.org/pypi/pip>`__

Managing Python installations can be quite tricky. We *highly* recommend using `pyenv <https://github.com/pyenv/pyenv>`__ or if you are more comfortable using a package manager, then package managers like `Homebrew <http://brew.sh/>`__ on Mac or ``apt`` on Debian for this.
Expand Down
2 changes: 1 addition & 1 deletion docs/stack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Note that since Kolibri is still in development, the APIs are subject to change,
Server
------

The server is a `Django <https://www.djangoproject.com/>`__ application, and contains only pure-Python (2.7+) dependencies at run-time. It is responsible for:
The server is a `Django <https://www.djangoproject.com/>`__ application, and contains only pure-Python (3.6+) dependencies at run-time. It is responsible for:

- Interfacing with the database (either `SQLite <https://www.sqlite.org/index.html>`__ or `PostgreSQL <https://www.postgresql.org/>`__)
- Authentication and permission middleware
Expand Down
4 changes: 0 additions & 4 deletions kolibri/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
This module is imported in setup.py, so you cannot for instance
import a dependency.
"""
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

from kolibri.utils import env
from kolibri.utils.version import get_version

Expand Down
4 changes: 0 additions & 4 deletions kolibri/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import sys

if __name__ == "__main__":
Expand Down
4 changes: 0 additions & 4 deletions kolibri/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@
enters the docs)

"""
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

default_app_config = "kolibri.core.apps.KolibriCoreConfig"
Loading
Loading