Repository: oppia/oppia

Issue:
[Feature Request]: Consider allowing Python version to be 3.8.x where x >= 12
### Is there an existing issue for this?

- [X] I have searched the existing issues

### A clear and concise description of what you want to happen.

In https://github.com/oppia/oppia/issues/16436, @sagangwee noted that he couldn't get Python 3.8.12 to work on his machine, but Python 3.8.13 worked fine. We might want to consider allowing 3.8.13 etc. in the start script checks for local developers.

### Describe the solution you'd like

Consider expanding the start.py script checks to include later versions of Python that are still on the 3.8.x series.

### Describe alternatives you've considered

We could leave the existing behaviour as-is, but this poses serious problems for developers who can't install 3.8.12. 

### Additional context

_No response_


Discussion:
@gp201 @U8NWXD @vojtechjelinek What do you think about this?

/cc @sagangwee
All the releases from 3.8.12 to 3.8.15 are security releases. I find no reason to enforce the python version to be 3.8.12. Hence I'm on board with this change.

Python releases:
- [python 3.8.12](https://www.python.org/downloads/release/python-3812/)
- [python 3.8.13](https://www.python.org/downloads/release/python-3813/)
- [python 3.8.14](https://www.python.org/downloads/release/python-3814/)
- [python 3.8.15](https://www.python.org/downloads/release/python-3815/)

[Entire Changelog for python 3.8 listed by version](https://docs.python.org/release/3.8.15/whatsnew/changelog.html)
I'm fine with this, but maybe a better solution would actually be to move to 3.8.15.
Yup I think that seems reasonable, let's do that. https://cloud.google.com/appengine/docs/standard/python3/runtime suggests that the python version is auto-updated to the latest patch version anyway in prod so we should probably have 3.8.15 as the default.

Btw what stops us from moving to 3.9 / 3.10? /cc @ashish-patwal 
I also prefer moving to 3.8.15 and keeping a fully-pinned Python version
@vojtechjelinek what would be involved in moving to 3.8.15?
Replace all sensible strings in our codebase that are `"3.8.12"` with `"3.8.15"`. Basically stuff in #15508 except for the changes to imports.
Sorry for the late reply ! Originally we planned to migrate to the latest (
bleeding edge version ) of python i.e. 3.10 . However, when we tested the
codebase against 3.9 and 3.10, the setup process halted at a certain stage,
throwing error due to pip-compile command. At this point, we were not able
to pinpoint the obvious cause of it, thus we decided to move to the latest
which was giving no error. And that came out to be 3.8.12


On Mon, 31 Oct 2022 at 14:46, Vojtěch Jelínek ***@***.***>
wrote:

> Replace all sensible strings in our codebase that are "3.8.12" with
> "3.8.15". Basically stuff in #15508
> <https://github.com/oppia/oppia/pull/15508> except for the changes to
> imports.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/oppia/oppia/issues/16438#issuecomment-1296807910>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/APEMZITJU2UWF2YXASNHG3TWF6E6XANCNFSM6AAAAAARRTYMFQ>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>

@ashish-patwal does that mean that 3.8.15 was giving errors?
@U8NWXD No, I think around the time we started working on the migration just 3.8.12 was available and then we just didn't update it. We will move to 3.8.15 ASAP
Just to make sure are we doing these changes just for the ci by editing the
yaml files or do we intend to edit in the core codebase also ?

On Wed, 2 Nov 2022, 23:58 Vojtěch Jelínek, ***@***.***> wrote:

> @U8NWXD <https://github.com/U8NWXD> No, I think around the time we
> started working on the migration just 3.8.12 was available and then we just
> didn't update it. We will move to 3.8.15 ASAP
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/oppia/oppia/issues/16438#issuecomment-1301051650>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/APEMZIWSR5JGKTWIFFLUJ2DWGKXDJANCNFSM6AAAAAARRTYMFQ>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>

@ashish-patwal Everything
@vojtechjelinek @ashish-patwal what's the current status on this? Is it being worked-on?

Resolving patch:
diff --git a/scripts/setup.py b/scripts/setup.py
--- a/scripts/setup.py
+++ b/scripts/setup.py
@@ -50,8 +50,8 @@ def create_directory(directory_path: str) -> None:
 # if it does not match the expected prefix.
 def test_python_version() -> None:
     running_python_version = '{0[0]}.{0[1]}.{0[2]}'.format(sys.version_info)
-    if running_python_version != '3.8.12':
-        print('Please use Python 3.8.12. Exiting...')
+    if running_python_version != '3.8.15':
+        print('Please use Python 3.8.15. Exiting...')
         # If OS is Windows, print helpful error message about adding Python to
         # path.
         if common.is_windows_os():


Test patch:
diff --git a/.github/workflows/backend_associated_test_file_check.yml b/.github/workflows/backend_associated_test_file_check.yml
--- a/.github/workflows/backend_associated_test_file_check.yml
+++ b/.github/workflows/backend_associated_test_file_check.yml
@@ -20,7 +20,7 @@ jobs:
       - uses: actions/checkout@v3
       - uses: actions/setup-python@v3
         with:
-          python-version: '3.8.12'
+          python-version: '3.8.15'
           architecture: 'x64'
       - uses: ./.github/actions/merge
       - name: Cache node modules and third_party/static
diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml
--- a/.github/workflows/backend_tests.yml
+++ b/.github/workflows/backend_tests.yml
@@ -21,7 +21,7 @@ jobs:
       - uses: actions/checkout@v3
       - uses: actions/setup-python@v3
         with:
-          python-version: '3.8.12'
+          python-version: '3.8.15'
           architecture: 'x64'
       - name: Cache node modules and third_party/static
         uses: actions/cache@v3
@@ -67,7 +67,7 @@ jobs:
       - uses: actions/checkout@v3
       - uses: actions/setup-python@v3
         with:
-          python-version: '3.8.12'
+          python-version: '3.8.15'
           architecture: 'x64'
       - name: Cache node modules
         uses: actions/cache@v3
diff --git a/.github/workflows/e2e_tests.yml b/.github/workflows/e2e_tests.yml
--- a/.github/workflows/e2e_tests.yml
+++ b/.github/workflows/e2e_tests.yml
@@ -19,7 +19,7 @@ jobs:
       - uses: actions/checkout@v3
       - uses: actions/setup-python@v3
         with:
-          python-version: '3.8.12'
+          python-version: '3.8.15'
           architecture: 'x64'
           cache: 'pip'
           cache-dependency-path: |
@@ -120,7 +120,7 @@ jobs:
       - uses: actions/checkout@v3
       - uses: actions/setup-python@v3
         with:
-          python-version: '3.8.12'
+          python-version: '3.8.15'
           architecture: 'x64'
           cache: 'pip'
           cache-dependency-path: |
@@ -175,7 +175,7 @@ jobs:
       - name: Run E2E Test ${{ matrix.suite }}
         if: ${{ steps.check-risk.outputs.is-low-risk != 0 }}
         run: xvfb-run -a --server-args="-screen 0, 1285x1000x24" python -m scripts.run_e2e_tests --skip-install --skip-build --suite=${{ matrix.suite }} --prod_env
-        env: 
+        env:
           VIDEO_RECORDING_IS_ENABLED: 0
       - name: Uploading webdriverio-video as Artifacts
         if: ${{ failure() }}
diff --git a/.github/workflows/eslint_tests.yml b/.github/workflows/eslint_tests.yml
--- a/.github/workflows/eslint_tests.yml
+++ b/.github/workflows/eslint_tests.yml
@@ -20,7 +20,7 @@ jobs:
       - uses: actions/checkout@v3
       - uses: actions/setup-python@v3
         with:
-          python-version: '3.8.12'
+          python-version: '3.8.15'
           architecture: 'x64'
       - uses: ./.github/actions/merge
       - name: Cache node modules and third_party/static
diff --git a/.github/workflows/frontend_tests.yml b/.github/workflows/frontend_tests.yml
--- a/.github/workflows/frontend_tests.yml
+++ b/.github/workflows/frontend_tests.yml
@@ -28,7 +28,7 @@ jobs:
           else
             JOB_STRATEGY_MATRIX=$(node -e "let r=[]; for(let i = 1; i <= ${{ env.standard-test-runs }}; i++) { r.push(i) }; console.log(JSON.stringify(r));")
             echo "::set-output name=job-strategy-matrix::$JOB_STRATEGY_MATRIX"
-          fi          
+          fi
   frontend-karma-tests:
     needs: generate-job-strategy-matrix
     runs-on:  ${{ matrix.os }}
@@ -49,7 +49,7 @@ jobs:
           echo $GITHUB_WORKSPACE
       - uses: actions/setup-python@v3
         with:
-          python-version: '3.8.12'
+          python-version: '3.8.15'
           architecture: 'x64'
       - uses: ./.github/actions/merge
       - name: Cache node modules and third_party/static
diff --git a/scripts/setup_test.py b/scripts/setup_test.py
--- a/scripts/setup_test.py
+++ b/scripts/setup_test.py
@@ -123,7 +123,7 @@ def mock_get(unused_var: str) -> None:
         version_info = collections.namedtuple(
             'version_info', ['major', 'minor', 'micro'])
         self.version_info_py38_swap = self.swap(
-            sys, 'version_info', version_info(major=3, minor=8, micro=12)
+            sys, 'version_info', version_info(major=3, minor=8, micro=15)
         )
         self.python2_print_swap = self.swap_with_checks(
             builtins,