Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Python3 support - Django #144

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
*.swp
*.~
*.py[co]
__pycache__/
.idea/
nohup.out
.gcloudignore
cloud_sql_proxy
.vscode/
.fuse_hidden*
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "sympy"]
path = sympy
url = git://github.com/sympy/sympy.git
url = https://github.com/sympy/sympy.git
[submodule "mpmath"]
path = mpmath
url = https://github.com/fredrik-johansson/mpmath
[submodule "static"]
path = static
url = git@github.com:sympy/sympy-web-static.git
url = https://github.com/sympy/sympy-web-static.git
81 changes: 81 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,87 @@ We use submodules to include external libraries in sympy-live::
This is sufficient to clone appropriate repositories in correct versions
into sympy-live (see git documentation on submodules for information).

Setting Up for Testing PR 144
-----------------------------
Here are the steps to be followed for testing the PR
https://github.com/sympy/sympy-live/pull/144. The following are
the steps to be followed for Ubuntu. The steps for other Operating Systems
could be reproduced similiarly.

You must have python3 installed. You can check your version by::

$ python3 -V

The version must be greater than 3.4. If not present you can install it by::

$ sudo apt install python3

You need to create the virtual environment and activate it::

$ sudo apt-get install python3-venv
$ python3 -m venv env
$ source env/bin/activate

SymPy Live uses MySQL for database purpose. So you need to setup mysql::

$ sudo apt-get install mysql-server
$ sudo apt-get install libmysqlclient-dev
$ sudo apt-get install python3-dev
$ sudo systemctl start mysql
$ sudo mysql

This will open mysql. You will now have to create a new database with name
{database_name}. Create a new user {user_name} and password {user_password}.
Grant all previleges to {user_name} on {database_name}::

mysql> CREATE DATABASE {database_name};
mysql> CREATE USER '{user_name}'@'localhost' IDENTIFIED BY '{user_password}';
mysql> FLUSH PRIVILEGES;
mysql> GRANT ALL PRIVILEGES ON *.* TO '{user_name}'@'localhost' IDENTIFIED BY '{user_password}';

These are the steps for MySQL v8.0.19. The above steps could be bit different for
you depending on the version of MySQL. You can check the MySQL documentation for
help. Using MySQL is not a compulsion. You can use any other DataBase for testing
but you must properly configure it.

To ensure that the database server launches after a reboot, run the following command::

$ sudo systemctl enable mysql

Now in settings.py set up the database for MySQL::

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '127.0.0.1', # DataBase's IP address
'PORT': '3306',
'NAME': '{database_name}',
'USER': '{user_name}',
'PASSWORD': '{user_password}',
}
}

Install dependencies from requirements.txt::

$ pip install -r requirements.txt

Migrate the changes so that all DataBase tables are created::

$ python3 manage.py makemigrations
$ python3 manage.py migrate
$ python3 manage.py createsuperuser # Admin. It will be used to login into admin panel

And finally you need to run the server::

$ python3 manage.py runserver

This runs the site on localhost. But before using the SymPy Live go to
admin panel http://127.0.0.1:8000/admin/. Login using the Admin details.
There you need to create new user 'anonymous'. You can keep password
anything but name must be exactly same as 'anonymous'.

Congratulations, now you can test the SymPy Live.

Development server
------------------

Expand Down
17 changes: 4 additions & 13 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
application: sympy-live-hrd
version: 58

runtime: python27
threadsafe: true
api_version: 1

libraries:
- name: numpy
version: latest
- name: matplotlib
version: latest
runtime: python37
entrypoint: gunicorn -b :8080 sympy_live.wsgi

handlers:
# redirect Sphinx extension
Expand Down Expand Up @@ -52,5 +42,6 @@ handlers:
# endpoint where you want the shell to run, e.g. /shell . You'll also probably
# want to add login: admin to restrict to admins only.
- url: .*
script: shell.application
# script: shell.application
script: auto
secure: always
23 changes: 23 additions & 0 deletions index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
indexes:

# AUTOGENERATED

# This index.yaml is automatically updated whenever the dev_appserver
# detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the above marker line (the line
# saying "# AUTOGENERATED"). If you want to manage some indexes
# manually, move them above the marker line. The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.

- kind: Searches
properties:
- name: private
- name: timestamp
direction: desc

- kind: Searches
properties:
- name: user_id
- name: timestamp
direction: desc
Comment on lines +13 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of these? I highly doubt that it is supported in Python3 runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was automatically generated while running dev_appserver for Python2 local testing. I think it should be removed.

21 changes: 21 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sympy_live.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Django==3.0.4
django-cors-headers==3.2.1
gunicorn==20.0.4
matplotlib==3.2.0
mysqlclient==1.4.6
numpy==1.18.1
scipy==1.4.1
Comment on lines +6 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we use these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were to be used in case we make SymPy Live more generic. I think I should remove them and address that issue separately.

1 change: 0 additions & 1 deletion settings.py

This file was deleted.

Loading