This is an automated email from the ASF dual-hosted git repository.

uranusjr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 39d8f93  Remove Python 2 from our images (#20680)
39d8f93 is described below

commit 39d8f93f4675f6e66c04b501b6f2ca42ae89d175
Author: Jarek Potiuk <[email protected]>
AuthorDate: Thu Jan 6 04:42:41 2022 +0100

    Remove Python 2 from our images (#20680)
---
 Dockerfile                                 |  4 ---
 Dockerfile.ci                              |  2 --
 tests/decorators/test_python_virtualenv.py | 41 ------------------------------
 tests/operators/test_python.py             | 34 +------------------------
 4 files changed, 1 insertion(+), 80 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 2be2b45..bbe9185 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -341,9 +341,6 @@ RUN apt-get update \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/*
 
-# As of August 2021, Debian buster-slim does not include Python2 by default 
and we need it
-# as we still support running Python2 via PythonVirtualenvOperator
-# TODO: Remove python2 when we stop supporting it
 ARG RUNTIME_APT_DEPS="\
        apt-transport-https \
        apt-utils \
@@ -365,7 +362,6 @@ ARG RUNTIME_APT_DEPS="\
        netcat \
        openssh-client \
        postgresql-client \
-       python2 \
        rsync \
        sasl2-bin \
        sqlite3 \
diff --git a/Dockerfile.ci b/Dockerfile.ci
index 5ea6c99..48962e6 100644
--- a/Dockerfile.ci
+++ b/Dockerfile.ci
@@ -90,7 +90,6 @@ RUN mkdir -pv /usr/share/man/man1 \
            locales  \
            netcat \
            nodejs \
-           python2 \
            rsync \
            sasl2-bin \
            sudo \
@@ -123,7 +122,6 @@ ARG RUNTIME_APT_DEPS="\
       krb5-user \
       ldap-utils \
       less \
-      libpython2.7-stdlib \
       lsb-release \
       net-tools \
       openssh-client \
diff --git a/tests/decorators/test_python_virtualenv.py 
b/tests/decorators/test_python_virtualenv.py
index 13e7be0..a14205d 100644
--- a/tests/decorators/test_python_virtualenv.py
+++ b/tests/decorators/test_python_virtualenv.py
@@ -139,27 +139,6 @@ class TestPythonVirtualenvDecorator(TestPythonBase):
         with pytest.raises(CalledProcessError):
             ret.operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
 
-    def test_python_2(self):
-        @task.virtualenv(python_version=2, requirements=['dill'])
-        def f():
-            {}.iteritems()
-
-        with self.dag:
-            ret = f()
-
-        ret.operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
-
-    def test_python_2_7(self):
-        @task.virtualenv(python_version='2.7', requirements=['dill'])
-        def f():
-            {}.iteritems()
-            return True
-
-        with self.dag:
-            ret = f()
-
-        ret.operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
-
     def test_python_3(self):
         @task.virtualenv(python_version=3, use_dill=False, 
requirements=['dill'])
         def f():
@@ -177,26 +156,6 @@ class TestPythonVirtualenvDecorator(TestPythonBase):
 
         ret.operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
 
-    @staticmethod
-    def _invert_python_major_version():
-        if sys.version_info[0] == 2:
-            return 3
-        else:
-            return 2
-
-    def test_string_args(self):
-        @task.virtualenv(python_version=self._invert_python_major_version(), 
string_args=[1, 2, 1])
-        def f():
-            global virtualenv_string_args
-            print(virtualenv_string_args)
-            if virtualenv_string_args[0] != virtualenv_string_args[2]:
-                raise Exception
-
-        with self.dag:
-            ret = f()
-
-        ret.operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
-
     def test_with_args(self):
         @task.virtualenv
         def f(a, b, c=False, d=False):
diff --git a/tests/operators/test_python.py b/tests/operators/test_python.py
index 54a8a54..22ea531 100644
--- a/tests/operators/test_python.py
+++ b/tests/operators/test_python.py
@@ -817,19 +817,6 @@ class TestPythonVirtualenvOperator(unittest.TestCase):
         with pytest.raises(CalledProcessError):
             self._run_as_operator(f)
 
-    def test_python_2(self):
-        def f():
-            {}.iteritems()
-
-        self._run_as_operator(f, python_version=2, requirements=['dill'])
-
-    def test_python_2_7(self):
-        def f():
-            {}.iteritems()
-            return True
-
-        self._run_as_operator(f, python_version='2.7', requirements=['dill'])
-
     def test_python_3(self):
         def f():
             import sys
@@ -843,25 +830,6 @@ class TestPythonVirtualenvOperator(unittest.TestCase):
 
         self._run_as_operator(f, python_version=3, use_dill=False, 
requirements=['dill'])
 
-    @staticmethod
-    def _invert_python_major_version():
-        if sys.version_info[0] == 2:
-            return 3
-        else:
-            return 2
-
-    def test_wrong_python_version_with_op_args(self):
-        def f():
-            pass
-
-        version = self._invert_python_major_version()
-
-        with pytest.raises(AirflowException):
-            self._run_as_operator(f, python_version=version, op_args=[1])
-
-        with pytest.raises(AirflowException):
-            self._run_as_operator(f, python_version=version, op_kwargs={"arg": 
1})
-
     def test_without_dill(self):
         def f(a):
             return a
@@ -875,7 +843,7 @@ class TestPythonVirtualenvOperator(unittest.TestCase):
             if virtualenv_string_args[0] != virtualenv_string_args[2]:
                 raise Exception
 
-        self._run_as_operator(f, 
python_version=self._invert_python_major_version(), string_args=[1, 2, 1])
+        self._run_as_operator(f, string_args=[1, 2, 1])
 
     def test_with_args(self):
         def f(a, b, c=False, d=False):

Reply via email to