Skip to content

Commit

Permalink
Merge pull request #154 from sympy/py3-runtime
Browse files Browse the repository at this point in the history
Migrate to Python 3 runtime of Google App Engine
  • Loading branch information
aktech committed Jun 12, 2020
2 parents 4244dc2 + 6c29453 commit 17b9f0e
Show file tree
Hide file tree
Showing 38 changed files with 262 additions and 316 deletions.
19 changes: 19 additions & 0 deletions .gcloudignore
@@ -0,0 +1,19 @@
# This file specifies files that are *not* uploaded to Google Cloud Platform
# 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
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

3 changes: 1 addition & 2 deletions .travis.yml
@@ -1,6 +1,6 @@
language: python
python:
- '2.7'
- '3.7'

services:
- docker
Expand All @@ -18,7 +18,6 @@ script:
- docker-compose exec app casperjs test app/test

before_deploy:
- docker cp gamma_app:/usr/src/app/lib lib
- openssl aes-256-cbc -K $encrypted_2fd045226a67_key -iv $encrypted_2fd045226a67_iv
-in client-secret.json.enc -out client-secret.json -d
- version=$(if [ ! -z "$TRAVIS_TAG" ]; then echo $(cut -d'-' -f2 <<<"$TRAVIS_TAG"); else echo "$TRAVIS_BRANCH"; fi)
Expand Down
84 changes: 2 additions & 82 deletions README.rst
Expand Up @@ -28,15 +28,6 @@ Clone sympy_gamma repository::
$ git clone git://github.com/sympy/sympy_gamma.git
$ cd sympy_gamma

We use submodules to include external libraries in sympy_gamma::

$ git submodule init
$ git submodule update

This is sufficient to clone appropriate repositories in correct versions
into sympy_gamma (see git documentation on submodules for information).


Development Server
------------------

Expand Down Expand Up @@ -80,11 +71,6 @@ the google cloud console for the project::

$ gcloud init

You need to to create ``lib`` (libraries) before deploying, make sure the development
server is up and running via ``docker-compose``, as mentioned above and create
libraries folder to package with the following command::

$ docker cp gamma_app:/usr/src/app/lib lib

Assuming that sympy_gamma works properly (also across different mainstream web
browsers), you can upload your changes to Google App Engine, replacing the
Expand Down Expand Up @@ -127,17 +113,11 @@ Testing on the App Engine
-------------------------

It's usually a good idea to test big changes on the App Engine itself before
deploying, as ``dev_appserver.py`` can only simulate the App Engine.
deploying, as local environment can only simulate the App Engine.
Currently, there is no testing server set up as there is for SymPy
Live. However, you can set up your own testing server (it's free, though it
requires a cell phone to set up).

You need to to create ``lib`` (libraries) before deploying, make sure the development
server is up and running via ``docker-compose``, as mentioned above and create
libraries folder to package with the following command::

$ docker cp gamma_app:/usr/src/app/lib lib

Either way, to test, you will need to edit the Project ID in the deploy command
mentioned above with your Project ID and the version you want to deploy to::

Expand Down Expand Up @@ -168,17 +148,6 @@ to be checked with an actual device. (In Google Chrome, for instance, open
up the developer console, click the gear icon in the lower right, then
select Overrides.)

GAE development server allows to use any Python interpreter, but Google
App Engine uses Python 2.5, so if the default Python isn't 2.5, then make
sure to test your changes to the server part, if it runs properly on 2.5.
Also don't use any modules that aren't supported by GAE. Note that GAE now
supports Python 2.7 and that this is what is currently deployed.

If the App Engine configuration needs to be changed (e.g. to update the
NumPy version), change ``app.yaml.template`` and generate again. The
Travis-CI script uses this to generate and deploy testing/production
versions automatically.


Running Tests
-------------
Expand All @@ -189,60 +158,11 @@ via ``docker-compose`` and run the following command::
$ docker-compose exec app nosetests app/test -vv
$ docker-compose exec app casperjs test app/test

Pulling changes
---------------

In projects that don't use submodules, pulling changes boils down to::

$ git pull origin master

in the simplest case. SymPy Gamma, however, requires additional effort::

$ git submodule update

The former command assures that if there were any changes to submodules
of the super-project, then those submodules will get updated to new
versions. This is related to the following section. The latter command
regenerates the configuration.

Updating SymPy
--------------

Make sure that you followed instructions above and SymPy's submodule is
properly initialized. Assuming that you are in the directory where SymPy
Gamma was cloned, issue::

$ cd sympy/
$ git fetch origin
$ git checkout sympy-0.7.0
$ cd ..
$ git add .
$ git commit -m "Updated SymPy to version 0.7.0"

Now if you issue::

$ git show -v

you should get::

commit 5138e824dc9fd46c243eea2d7c9581a9e58feb08
Author: Mateusz Paprocki <mattpap@gmail.com>
Date: Wed Jul 6 07:45:19 2011 +0200

Updated SymPy to version 0.7.0

diff --git a/sympy b/sympy
index df7a135..c9470ac 160000
--- a/sympy
+++ b/sympy
@@ -1 +1 @@
-Subproject commit df7a135a4ff7eca361ebbb07ccbeabf8654a8d80
+Subproject commit c9470ac4f44e7dacfb026cf74529db3ec0822145

This was done for SymPy's version 0.7.0, so in future updates of SymPy replace
0.7.0 with appropriate newer version (e.g. 0.7.1) and you are done (of course
particular SHA signatures will be different in your case). If unsure, refer to
``git help submodule`` or git book: http://book.git-scm.com/5_submodules.html.
Update the version in requirements.txt file.

Original info
-------------
Expand Down
26 changes: 7 additions & 19 deletions app.yaml
@@ -1,13 +1,8 @@
runtime: python27
threadsafe: true
api_version: 1
default_expiration: "1h"
runtime: python37

handlers:
- url: /static
static_dir: static
secure: always

# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /favicon\.ico
static_files: static/images/favicon.ico
upload: static/images/favicon\.ico
Expand All @@ -18,20 +13,13 @@ handlers:
upload: google5acf6d2992c8237d.html
secure: always

- url: /static
static_dir: static/

- url: /.*
script: main.application
script: auto
secure: always

libraries:
- name: django
version: "1.11"
- name: numpy
version: "1.6.1"
- name: ssl
version: "latest"
- name: grpcio
version: "1.0.0"

env_variables:
GOOGLE_APPLICATION_CREDENTIALS: "client-secret.json"
PROJECT_ID: "sympy-gamma-hrd"
2 changes: 1 addition & 1 deletion app/logic/diffsteps.py
Expand Up @@ -7,7 +7,7 @@

from sympy.core.function import AppliedUndef
from sympy.functions.elementary.trigonometric import TrigonometricFunction
from sympy.strategies.core import switch, identity
from sympy.strategies.core import switch
from six.moves import map
from six.moves import range
from six.moves import zip
Expand Down
6 changes: 2 additions & 4 deletions app/logic/intsteps.py
@@ -1,12 +1,10 @@
from __future__ import absolute_import
import sympy
import collections
from contextlib import contextmanager
from . import stepprinter
from .stepprinter import functionnames, Rule, replace_u_var
from .stepprinter import replace_u_var

from sympy.integrals.manualintegrate import (
manualintegrate, _manualintegrate, integral_steps, evaluates,
_manualintegrate, integral_steps, evaluates,
ConstantRule, ConstantTimesRule, PowerRule, AddRule, URule,
PartsRule, CyclicPartsRule, TrigRule, ExpRule, LogRule, ArctanRule,
AlternativeRule, DontKnowRule, RewriteRule
Expand Down
4 changes: 2 additions & 2 deletions app/logic/logic.py
Expand Up @@ -84,7 +84,7 @@ def eval(self, s):
def handle_error(self, s, e):
if isinstance(e, SyntaxError):
error = {
"msg": e.msg,
"msg": str(e),
"offset": e.offset
}
if e.text:
Expand All @@ -97,7 +97,7 @@ def handle_error(self, s, e):
elif isinstance(e, ValueError):
return [
{"title": "Input", "input": s},
{"title": "Error", "input": s, "error": e.message}
{"title": "Error", "input": s, "error": str(e)}
]
else:
trace = traceback.format_exc()
Expand Down
1 change: 0 additions & 1 deletion app/logic/resultsets.py
Expand Up @@ -3,7 +3,6 @@
import json
import itertools
import sympy
from sympy.core.function import FunctionClass
from sympy.core.symbol import Symbol
import docutils.core
from . import diffsteps
Expand Down
9 changes: 8 additions & 1 deletion app/logic/utils.py
Expand Up @@ -6,7 +6,7 @@
import sys
import ast
import re
from StringIO import StringIO
from io import StringIO
import sympy

from sympy.core.relational import Relational
Expand Down Expand Up @@ -260,6 +260,10 @@ def visit_Name(self, node):
if not self.call:
self.call = node

def visit_NameConstant(self, node):
if not self.call:
self.call = node

# From https://stackoverflow.com/a/739301/262727
def ordinal(n):
if 10 <= n % 100 < 20:
Expand Down Expand Up @@ -306,6 +310,9 @@ def arguments(string_or_node, evaluator):
return Arguments(name, args, kwargs)
elif isinstance(node, ast.Name):
return Arguments(node.id, [], {})

elif isinstance(node, ast.NameConstant):
return Arguments(node.value, [], {})
return None

re_calls = re.compile(r'(Integer|Symbol|Float|Rational)\s*\([\'\"]?([a-zA-Z0-9\.]+)[\'\"]?\s*\)')
Expand Down
1 change: 0 additions & 1 deletion app/settings.py

This file was deleted.

0 comments on commit 17b9f0e

Please sign in to comment.