From 6c0cc75858ea8413b53f451b03fd7a613b070068 Mon Sep 17 00:00:00 2001 From: Jon Betts Date: Wed, 11 Oct 2017 17:39:17 +0100 Subject: [PATCH 1/2] TLS-107 - Correcting the script paths * Also marked as non-zip safe to be safe * This is because get_compiler_script() uses path concatentation --- MANIFEST.in | 2 +- setup.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 07e0d99..676241f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ include LICENSE include README.rst -include coffeescript/coffee-script.js \ No newline at end of file +include coffeescript/coffeescript.js \ No newline at end of file diff --git a/setup.py b/setup.py index 2dc62c2..478da8b 100755 --- a/setup.py +++ b/setup.py @@ -16,8 +16,9 @@ packages=['coffeescript'], package_dir={'coffeescript': 'coffeescript'}, package_data={ - 'coffeescript': ['coffee-script.js'], + 'coffeescript': ['coffeescript.js'], }, + zip_safe=False, long_description=long_description, url='https://github.com/doloopwhile/Python-CoffeeScript', From dcbfe5657c7aa63b7b35fc856e241876bd4c3d7d Mon Sep 17 00:00:00 2001 From: Jon Betts Date: Wed, 11 Oct 2017 18:30:17 +0100 Subject: [PATCH 2/2] TLS-107 - Using pkg_resources to be zip safe I can't currently get the tests to pass getting: TypeError: Object function Object() { [native code] } has no method 'assign' This is at least the same error I was getting before the commit --- coffeescript/__init__.py | 9 ++++----- setup.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/coffeescript/__init__.py b/coffeescript/__init__.py index ea8d25e..564b023 100755 --- a/coffeescript/__init__.py +++ b/coffeescript/__init__.py @@ -2,6 +2,8 @@ # -*- coding: ascii -*- from __future__ import division, unicode_literals, print_function +import pkg_resources + # Copyright (c) 2011 Omoto Kenji # Released under the MIT license. See `LICENSE` for details. @@ -47,7 +49,6 @@ get_compiler_script ''').split() -import os import io import execjs @@ -115,10 +116,8 @@ def get_compiler_script(): '''returns a CoffeeScript compiler script in JavaScript. which is used in coffeescript.compile() and coffeescript.compile_file() ''' - from os.path import dirname, join - filename = join(dirname(__file__), 'coffeescript.js') - with io.open(filename, encoding='utf8') as fp: - return fp.read() + return pkg_resources.resource_string( + 'coffeescript', 'coffeescript.js').decode('utf-8') def get_runtime(): diff --git a/setup.py b/setup.py index 478da8b..49c420b 100755 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ package_data={ 'coffeescript': ['coffeescript.js'], }, - zip_safe=False, + zip_safe=True, long_description=long_description, url='https://github.com/doloopwhile/Python-CoffeeScript',