Skip to content

Commit

Permalink
python 3: misc final tweaks before deploying live on py 3 runtime!
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Dec 13, 2019
1 parent d2bd58b commit ade44ae
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 23 deletions.
13 changes: 2 additions & 11 deletions .circleci/config.yml
Expand Up @@ -20,32 +20,23 @@ jobs:
name: Base dependencies
command: |
apt-get install -y python3
# use oauth-dropins master at head. (see pip install -e below.)
cd /tmp
git clone https://github.com/snarfed/oauth-dropins.git
cd oauth-dropins
# TODO: remove once we merge into master
git checkout python3-ndb
git submodule sync
git submodule update --init
- run:
name: Python 3 dependencies
command: |
apt-get install -y python3-venv python3-dev
python3 -m venv local3
. local3/bin/activate
pip install -e /tmp/oauth-dropins/
pip install -U -r requirements.txt
pip install coverage coveralls
- run:
name: Test Python 3
command: |
. local3/bin/activate
CLOUDSDK_CORE_PROJECT=granary-demo gcloud beta emulators datastore start --consistency=1.0 < /dev/null >& /dev/null &
CLOUDSDK_CORE_PROJECT=granary-demo gcloud beta emulators datastore start --no-store-on-disk --consistency=1.0 --host-port=localhost:8089 < /dev/null >& /dev/null &
sleep 5s
DATASTORE_EMULATOR_HOST=localhost:8081 DATASTORE_DATASET=granary-demo python3 -m coverage run --source=. --omit=appengine_config.py,cron.py,granary/tests/\*,local3/\*,oauth-dropins/\*,old_apps/\*,setup.py,test_\*,\*_live_test.py -m unittest discover -v
DATASTORE_EMULATOR_HOST=localhost:8089 DATASTORE_DATASET=granary-demo python3 -m coverage run --source=. --omit=appengine_config.py,cron.py,granary/tests/\*,local3/\*,oauth-dropins/\*,old_apps/\*,setup.py,test_\*,\*_live_test.py -m unittest discover -v
kill %1
PYTHONPATH= python ./instagram_live_test.py --debug || true
python -m coverage html -d /tmp/coverage_html
Expand Down
4 changes: 1 addition & 3 deletions .gcloudignore
Expand Up @@ -15,6 +15,7 @@
*.so
.git*

__pycache__/
.coverage/
.git*/
coverage/
Expand All @@ -38,6 +39,3 @@ TAGS
TAGS/
test/
tests/

# drop if this doesn't break gcloud app deploy?
# script (dev).tmpl
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -287,9 +287,9 @@ Changelog
---
### 3.0 - unreleased

* Migrate demo app and API to the [App Engine Standard Python 3 runtime](https://cloud.google.com/appengine/docs/standard/python3/).

### 2.3 - unreleased
_Breaking changes:_
* _Python 2 is no longer supported!_ Including the [App Engine Standard Python 2 runtime](https://cloud.google.com/appengine/docs/standard/python/). On the plus side, the [App Engine Standard Python 3 runtime](https://cloud.google.com/appengine/docs/standard/python3/) is now supported! See this [list of differences](https://cloud.google.com/appengine/docs/standard/python3/python-differences) for more details.
* Migrate demo app and API to the App Engine Standard Python 3 runtime.
* Instagram:
* Scraping: fetch 50 likes instead of 24. ([snarfed/bridgy#898](https://github.com/snarfed/bridgy/issues/898))
* RSS:
Expand Down
9 changes: 4 additions & 5 deletions app.yaml
@@ -1,8 +1,7 @@
# https://cloud.google.com/appengine/docs/standard/python3/config/appref

# application: granary-demo
# version: 2
default_expiration: 1h
# default_expiration: 1h
runtime: python37
entrypoint: gunicorn -b :$PORT app:application

Expand All @@ -14,8 +13,8 @@ automatic_scaling:

handlers:
- url: /(static/bootstrap.*\.css)
static_files: local/lib/python2.7/site-packages/oauth_dropins/\1
upload: local/lib/python2.7/site-packages/oauth_dropins/static/bootstrap.*\.css
static_files: oauth_dropins/\1
upload: oauth_dropins/static/bootstrap.*\.css

- url: /static
static_dir: static
Expand All @@ -29,7 +28,7 @@ handlers:
upload: static/favicon.ico

- url: /oauth_dropins/static
static_dir: local/lib/python2.7/site-packages/oauth_dropins/static
static_dir: oauth_dropins/static

- url: /.+
script: auto
Expand Down
3 changes: 3 additions & 0 deletions granary/appengine_config.py
Expand Up @@ -9,3 +9,6 @@
message='URLFetch does not support granular timeout')
warnings.filterwarnings('ignore',
message='.*No parser was explicitly specified.*')
if DEBUG:
warnings.filterwarnings('ignore', module='google.auth',
message='Your application has authenticated using end user credentials')
2 changes: 1 addition & 1 deletion granary/facebook.py
Expand Up @@ -1814,7 +1814,7 @@ def _scraped_datetime(tag):
"""
try:
parsed = dateutil.parser.parse(tag.get_text(strip=True), default=now_fn())
return parsed.isoformat(util.T)
return parsed.isoformat('T')
except (ValueError, OverflowError):
logging.warning("Couldn't parse datetime string %r", tag, exc_info=True)

Expand Down
8 changes: 8 additions & 0 deletions index.yaml
@@ -0,0 +1,8 @@
indexes:
# AUTOGENERATED

# This index.yaml is automatically updated whenever the Cloud Datastore
# emulator detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the "# AUTOGENERATED" marker line above.
# If you want to manage some indexes manually, move them above the marker line.

1 change: 1 addition & 0 deletions oauth_dropins
1 change: 1 addition & 0 deletions requirements.txt
@@ -1,3 +1,4 @@
git+https://github.com/snarfed/oauth-dropins.git@python3-ndb#egg=oauth_dropins
gunicorn~=20.0
mox3~=0.28
webapp2>=3.0.0b1
Expand Down

0 comments on commit ade44ae

Please sign in to comment.