Skip to content

Commit

Permalink
Upgrade to Python 3.11 and GAE Gen 2 (#29)
Browse files Browse the repository at this point in the history
* Remove locked `google-auth` version

* This helps resolve the ResolutionImpossible error while installing
  packages from requirements.txt on Python 3.11

* Change runtime to `python311`

* Remove `libraries` entry from `app.yaml`

* Update `Jinja2` package for compatibility

* Enable legacy bundled services on Python3 runtime
* https://cloud.google.com/appengine/docs/standard/python3/services/access

* Drop `lib` dir

* Point `gae-sessions` to `python3-compat` branch

* Remove no longer supported fields from `app.yaml`
* https://cloud.google.com/appengine/docs/standard/python3/migrate-to-python3/config-files

* Remove `threadsafe` entry from `app.yaml`
* All apps are presumed to be threadsafe in Python3 runtime
* https://cloud.google.com/appengine/docs/standard/python3/migrate-to-python3/config-files

* Replace `handlers: script` value w/ `auto`
* https://cloud.google.com/appengine/docs/standard/python3/migrate-to-python3/config-files#python-3

* Remove `env_variables` section from `app.yaml`
* The `DJANGO_SETTINGS_MODULE` env variable had to be set to the name of the Django settings module, typically 'settings', before packages got imported back on the legacy Python2 runtime
* https://cloud.google.com/appengine/docs/legacy/standard/python/tools/using-libraries-python-27#django

* Remove ignored `appengine_config.py`
* https://cloud.google.com/appengine/migration-center/standard/migrate-to-second-gen/python-differences#configuration
* Replaced w/ a call to `wrap_wsgi_app`
* The new `wrap_wsgi_middleware` decorator is created to configure `SessionMiddleware`

* Replace `CURRENT_VERSION_ID` w/ `GAE_VERSION`

* `GAE_VERSION` holds the current version label of the service
* https://cloud.google.com/appengine/docs/standard/python3/runtime#environment_variables

* Determine environment using `GAE_ENV` variable

* Update `ae_helpers`

* Disable "file_cache is unavailable" warning

* This disables the following warning produced by `googleapiclient`

    WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth

* googleapis/google-api-python-client#299

* Add `.gcloudignore`
  • Loading branch information
dskecse authored Dec 28, 2023
1 parent c8bed63 commit 44a8315
Show file tree
Hide file tree
Showing 1,959 changed files with 80 additions and 362,541 deletions.
23 changes: 23 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file specifies files that are *not* uploaded to Google Cloud
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

# Python pycache:
__pycache__/
# Ignored by the build system
/setup.cfg

output/
tests/
venv/
19 changes: 3 additions & 16 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
runtime: python27
threadsafe: true
api_version: 1
runtime: python311
app_engine_apis: true # from https://pypi.org/project/appengine-python-standard/

handlers:
- url: /favicon\.ico
Expand All @@ -17,16 +16,4 @@ handlers:
static_dir: static/css

- url: .*
script: main.app

libraries:
- name: lxml
version: latest
- name: ssl
version: 2.7.11

builtins:
- appstats: on

env_variables:
DJANGO_SETTINGS_MODULE: 'settings'
script: auto
14 changes: 0 additions & 14 deletions appengine_config.py

This file was deleted.

4 changes: 2 additions & 2 deletions auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def oauth2_callback():
# When running locally, disable OAuthlib's HTTPs verification.
# This is to get rid of the following error in development:
# InsecureTransportError: (insecure_transport) OAuth 2 MUST utilize https.
if os.environ.get('HTTPS') == 'off':
if os.environ.get('GAE_ENV') == 'localdev':
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'

session = get_current_session()
Expand Down Expand Up @@ -122,7 +122,7 @@ def oauth2_callback():
ae_save(access_token, access_token_key)

try:
calendar_service = build('calendar', 'v3', credentials=credentials)
calendar_service = build('calendar', 'v3', credentials=credentials, cache_discovery=False)

# CalendarList#list API ref:
# https://developers.google.com/calendar/api/v3/reference/calendarList/list
Expand Down
2 changes: 1 addition & 1 deletion events_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_calendar_events(user, event_list):
# After obtaining an access token, your application can use that token to authorize API requests on behalf of a given user account.
# Use the user-specific authorization credentials to build a service object for the API that you want to call,
# and then use that object to make authorized API requests.
calendar_service = build('calendar', 'v3', credentials=credentials)
calendar_service = build('calendar', 'v3', credentials=credentials, cache_discovery=False)
for event in event_list:
insert_event(calendar_service, event.title, event.description, event.location, event.starttime, event.endtime,
user.calendar_id)
Expand Down
1 change: 0 additions & 1 deletion lib/Flask-1.1.2.dist-info/INSTALLER

This file was deleted.

28 changes: 0 additions & 28 deletions lib/Flask-1.1.2.dist-info/LICENSE.rst

This file was deleted.

137 changes: 0 additions & 137 deletions lib/Flask-1.1.2.dist-info/METADATA

This file was deleted.

49 changes: 0 additions & 49 deletions lib/Flask-1.1.2.dist-info/RECORD

This file was deleted.

Empty file.
6 changes: 0 additions & 6 deletions lib/Flask-1.1.2.dist-info/WHEEL

This file was deleted.

3 changes: 0 additions & 3 deletions lib/Flask-1.1.2.dist-info/entry_points.txt

This file was deleted.

1 change: 0 additions & 1 deletion lib/Flask-1.1.2.dist-info/top_level.txt

This file was deleted.

1 change: 0 additions & 1 deletion lib/Jinja2-2.10.1.dist-info/INSTALLER

This file was deleted.

31 changes: 0 additions & 31 deletions lib/Jinja2-2.10.1.dist-info/LICENSE

This file was deleted.

Loading

0 comments on commit 44a8315

Please sign in to comment.