diff --git a/source/ports/py_port/package/helper.py b/source/ports/py_port/package/metacall/__helper__.py similarity index 99% rename from source/ports/py_port/package/helper.py rename to source/ports/py_port/package/metacall/__helper__.py index de9b6f5d9..6a24bdb38 100644 --- a/source/ports/py_port/package/helper.py +++ b/source/ports/py_port/package/metacall/__helper__.py @@ -4,7 +4,6 @@ import shutil import tarfile import subprocess - import requests def file_size(num, suffix='B'): @@ -14,7 +13,6 @@ def file_size(num, suffix='B'): num /= 1024.0 return "%.1f%s%s" % (num, 'Yi', suffix) - def find_assets(patterns): api_url = 'https://api.github.com/repos/metacall/core/releases/latest' urls = [] @@ -26,7 +24,6 @@ def find_assets(patterns): urls.append(list(filter(regex.search, data))[0]) return urls - def download(urls): for url in urls: filename = '/tmp/{}'.format(url.split("/")[-1]) @@ -59,7 +56,6 @@ def download(urls): os.rename(filename + '.tmp', filename) - def unpack(files): for filename in files: filename = filename.split("/")[-1] @@ -67,20 +63,17 @@ def unpack(files): with tarfile.open(filename) as file: file.extractall() - def write_install_log(content): with open('/tmp/mc-install.tmp', 'w') as logger: logger.write('\n'.join(content)) shutil.move('/tmp/mc-install.tmp', '/usr/local/share/metacall/install') - def read_install_log(): with open('/usr/local/share/metacall/install', 'r') as logger: lines = logger.read().splitlines() return lines - def overwrite(src, dest): if os.path.isdir(src): if not os.path.isdir(dest): @@ -93,23 +86,19 @@ def overwrite(src, dest): shutil.copyfile(src, dest) yield str(dest) - def spawn(args): process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, error = process.communicate() return output, error, process.returncode - def pre_install(components): download(['https://raw.githubusercontent.com/metacall/core/develop/tools/metacall-runtime.sh']) args = ['bash', '/tmp/metacall-runtime.sh'] args = args + components subprocess.call(args) - def pre_install_prompt(): - answers = {'yes': True, 'y': True, 'no': False, 'n': False} components = ['python', 'ruby', 'netcore', 'v8', 'nodejs', 'ports'] args = [] @@ -133,7 +122,6 @@ def pre_install_prompt(): except KeyboardInterrupt: exit(1) - def install(ignore=False): if ignore is False: if os.path.isfile('/usr/local/bin/metacallcli'): @@ -194,11 +182,9 @@ def install(ignore=False): except KeyboardInterrupt: print('\nCanceled by user.') - def update(): install(ignore=True) - def uninstall(paths): for fp in paths: @@ -212,7 +198,6 @@ def uninstall(paths): exit(0) - def uninstall_prompt(): paths = read_install_log() message = '''This action would remove:\n {} @@ -236,4 +221,4 @@ def uninstall_prompt(): else: sys.stdout.write("Please respond with 'yes' or 'no' (or 'y' or 'n').\n") except KeyboardInterrupt: - exit(1) \ No newline at end of file + exit(1) diff --git a/source/ports/py_port/package/metacall/__init__.py b/source/ports/py_port/package/metacall/__init__.py index 660eacb30..2e3bf064e 100644 --- a/source/ports/py_port/package/metacall/__init__.py +++ b/source/ports/py_port/package/metacall/__init__.py @@ -3,12 +3,17 @@ import os import sys -# TODO: This is a nasty mock. It only will work if python port library (binary) is already installed and the -# environment variable correctly set up. This must be removed when metacall is correctly distributed -# and we can automate all distributions for all architectures, operative systems and all ports for all languages -sys.path.append(os.environ['PORT_LIBRARY_PATH']); +port_path = os.environ.get('PORT_LIBRARY_PATH') + +if not port_path: + port_path = '/usr/local/lib' + +sys.path.append(port_path); try: from _py_port import * except ImportError: - from _py_portd import * + try: + from _py_portd import * + except ImportError: + pass diff --git a/source/ports/py_port/package/setup.py b/source/ports/py_port/package/setup.py index 18acec754..4aca4752e 100644 --- a/source/ports/py_port/package/setup.py +++ b/source/ports/py_port/package/setup.py @@ -23,7 +23,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='0.1.9', + version='0.1.11', description='A library for providing inter-language foreign function interface calls', long_description=long_description, @@ -109,9 +109,9 @@ # pip to create the appropriate form of executable for the target platform. entry_points={ 'console_scripts': [ - 'metacall-install=helper:install', - 'metacall-uninstall=helper:uninstall_prompt', - 'metacall-update=helper:update' + 'metacall-install=metacall.__helper__:install', + 'metacall-uninstall=metacall.__helper__:uninstall_prompt', + 'metacall-update=metacall.__helper__:update' ], }, )