diff --git a/pyganja/__init__.py b/pyganja/__init__.py index abd71a6..8c53c96 100644 --- a/pyganja/__init__.py +++ b/pyganja/__init__.py @@ -1,3 +1,4 @@ from .script_api import * from .color import * +from ._version import __version__ diff --git a/pyganja/_version.py b/pyganja/_version.py new file mode 100644 index 0000000..a1de99d --- /dev/null +++ b/pyganja/_version.py @@ -0,0 +1,8 @@ +# Package versioning solution originally found here: +# http://stackoverflow.com/q/458550 + +# Store the version here so: +# 1) we don't load dependencies by storing it in __init__.py +# 2) we can import it in setup.py for the same reason +# 3) we can import it into your module +__version__ = '0.0.9' diff --git a/pyganja/script_api.py b/pyganja/script_api.py index b5c7b7a..af29971 100644 --- a/pyganja/script_api.py +++ b/pyganja/script_api.py @@ -6,6 +6,7 @@ from multiprocessing import Process import hashlib import webbrowser +import warnings from .GanjaScene import GanjaScene @@ -14,7 +15,9 @@ from .cefwindow import * CEFAVAILABLE = True except: - print('Failed to import cef_gui, cef functions will be unavailable') + warnings.warn( + 'Failed to import cef_gui, cef functions will be unavailable', + stacklevel=2) JUPYTERAVAILABLE = False try: @@ -22,7 +25,9 @@ from IPython import get_ipython JUPYTERAVAILABLE = True except: - print('Failed to import ipython, notebook rendering will be unavailable') + warnings.warn( + 'Failed to import ipython, notebook rendering will be unavailable', + stacklevel=2) def html_to_data_uri(html): @@ -35,7 +40,7 @@ def html_to_data_uri(html): def read_ganja(): dir_name = os.path.dirname(os.path.abspath(__file__)) ganja_filename = dir_name + '/static/ganja.js/ganja.js' - with open(ganja_filename, 'r') as ganja_file: + with open(ganja_filename, 'r', encoding='utf8') as ganja_file: output = ganja_file.read() return output @@ -81,7 +86,8 @@ def generate_notebook_js(script_json, sig=None, grid=True, scale=1.0, gl=True): data = data.map(x=>x.length==opts.mv_length?new Element(x):x); // add the graph to the page. canvas = this.graph(data, {gl: opts.gl, conformal: opts.conformal, grid: opts.grid, scale: opts.scale, useUnnaturalLineDisplayForPointPairs: true}); - canvas.options.h = h; canvas.options.p = p; + canvas.options.h = h; + canvas.options.p = p; // make it big. canvas.style.width = '100%'; canvas.style.height = '50vh'; @@ -100,9 +106,13 @@ def generate_notebook_js(script_json, sig=None, grid=True, scale=1.0, gl=True): window.open(url, '_blank'); }); } + window.addEventListener('resize', function() { + output.update(output.value); + }); a.onclick = screenshot var butnelem = element.append(a); }); + })(element); """ else: diff --git a/pyganja/static/ganja.js b/pyganja/static/ganja.js index 2e368ab..68b05cd 160000 --- a/pyganja/static/ganja.js +++ b/pyganja/static/ganja.js @@ -1 +1 @@ -Subproject commit 2e368ab70c4bb44da6556d67e96b4d6c8408949d +Subproject commit 68b05cd3dd7873846cc6461eb2ea728581e8652c diff --git a/setup.py b/setup.py index a60d56c..e049458 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,10 @@ from distutils.command.install import install from distutils.command.build import build from os import path +import os + +version_path = os.path.join('pyganja', '_version.py') +exec(open(version_path).read()) class build_with_submodules(build): def run(self): @@ -21,7 +25,7 @@ def run(self): setup( cmdclass={"build": build_with_submodules, "install": install_with_submodules}, name='pyganja', - version='0.0.8', + version=__version__, packages=find_packages(), url='https://github.com/hugohadfield/pyganja', license='',