示例#1
0
def invoke(*args, **kwargs):
    patch_stdout_stderr()
    method_to_call = getattr(args[0], args[1])
    return annotationsModifier(generatorModifier(abbreviateStackTrace(lambda: method_to_call(*args[2:], **kwargs))))
    

	
def main(path):
    patch_stdout_stderr()
    
    path = pkg_resources.normalize_path(path)
    moduleInstallationPrefix=path+os.sep+"inst"

    localSitePackages=localSitePackageFolder(moduleInstallationPrefix)
    
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)

    os.makedirs(localSitePackages)
    
    # The preferred approach to install a package is to use pip...
    call_pip('pandas==0.22', localSitePackages)
#     # check that the installation worked
#    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
#     import pandas# This fails intermittently

    # ...but - for some reason - pip breaks when we install the python synapse client
    # So we use 'setup' directly
    packageName = "synapseclient-1.9.2"
    
    if 'PYTHON_CLIENT_GITHUB_USERNAME' in os.environ and 'PYTHON_CLIENT_GITHUB_BRANCH' in os.environ:
        pythonClientGithubUsername = os.environ['PYTHON_CLIENT_GITHUB_USERNAME']
        pythonClientGithubBranch = os.environ['PYTHON_CLIENT_GITHUB_BRANCH']
        archivePrefix="synapsePythonClient-"+pythonClientGithubBranch
        archiveSuffix=".zip"
        url="https://github.com/"+pythonClientGithubUsername+"/synapsePythonClient/archive/"+pythonClientGithubBranch+archiveSuffix
    else:
        archivePrefix=packageName
        urlPrefix = "https://files.pythonhosted.org/packages/ed/fb/67055be256b6b0906d5627f3f39f5ba8db5737162ce619c04e8f9c2c2848/"
        archiveSuffix = ".tar.gz"
        url = urlPrefix+archivePrefix+archiveSuffix
    
    installPackage(packageName, url, archivePrefix, archiveSuffix, path, moduleInstallationPrefix)
        
    # check that the installation worked
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
    import synapseclient
    
    # When trying to 'synStore' a table we get the error:
    # pandas.Styler requires jinja2. Please install with `conda install Jinja2`
    # So let's install Jinja2 here:
    # https://stackoverflow.com/questions/43163201/pyinstaller-syntax-error-yield-inside-async-function-python-3-5-1

    # Jinja2 depends on MarkupSafe
    packageName = "MarkupSafe-1.0"
    linkPrefix = "https://pypi.python.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/"
    installedPackageFolderName="markupsafe"
    simplePackageInstall(packageName, installedPackageFolderName, linkPrefix, path, localSitePackages)
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
    #import markupsafe  # This fails intermittently

    packageName = "Jinja2-2.8.1"
    linkPrefix = "https://pypi.python.org/packages/5f/bd/5815d4d925a2b8cbbb4b4960f018441b0c65f24ba29f3bdcfb3c8218a307/"
    installedPackageFolderName="jinja2"
    simplePackageInstall(packageName, installedPackageFolderName, linkPrefix, path, localSitePackages)
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
示例#3
0
def main(path):
    patch_stdout_stderr()

    path = pkg_resources.normalize_path(path)
    moduleInstallationPrefix = path + os.sep + "inst"

    localSitePackages = localSitePackageFolder(moduleInstallationPrefix)

    addLocalSitePackageToPythonPath(moduleInstallationPrefix)

    os.makedirs(localSitePackages)

    # The preferred approach to install a package is to use pip...
    call_pip('pandas==0.22', localSitePackages)
    #     # check that the installation worked
    #    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
    #     import pandas# This fails intermittently

    # ...but - for some reason - pip breaks when we install the python synapse client
    # So we use 'setup' directly
    packageName = "synapseclient-1.9.3"

    if 'PYTHON_CLIENT_GITHUB_USERNAME' in os.environ and 'PYTHON_CLIENT_GITHUB_BRANCH' in os.environ:
        pythonClientGithubUsername = os.environ[
            'PYTHON_CLIENT_GITHUB_USERNAME']
        pythonClientGithubBranch = os.environ['PYTHON_CLIENT_GITHUB_BRANCH']
        archivePrefix = "synapsePythonClient-" + pythonClientGithubBranch
        archiveSuffix = ".zip"
        url = "https://github.com/" + pythonClientGithubUsername + "/synapsePythonClient/archive/" + pythonClientGithubBranch + archiveSuffix
    else:
        archivePrefix = packageName
        urlPrefix = "https://files.pythonhosted.org/packages/8d/00/d64d0887f5f215f19cf57789ea43d757c9576d343e96a62e6af23a201091/"
        archiveSuffix = ".tar.gz"
        url = urlPrefix + archivePrefix + archiveSuffix

    installPackage(packageName, url, archivePrefix, archiveSuffix, path,
                   moduleInstallationPrefix)

    # check that the installation worked
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
    import synapseclient

    # When trying to 'synStore' a table we get the error:
    # pandas.Styler requires jinja2. Please install with `conda install Jinja2`
    # So let's install Jinja2 here:
    # https://stackoverflow.com/questions/43163201/pyinstaller-syntax-error-yield-inside-async-function-python-3-5-1

    # Jinja2 depends on MarkupSafe
    packageName = "MarkupSafe-1.0"
    linkPrefix = "https://pypi.python.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/"
    installedPackageFolderName = "markupsafe"
    simplePackageInstall(packageName, installedPackageFolderName, linkPrefix,
                         path, localSitePackages)
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
    #import markupsafe  # This fails intermittently

    packageName = "Jinja2-2.8.1"
    linkPrefix = "https://pypi.python.org/packages/5f/bd/5815d4d925a2b8cbbb4b4960f018441b0c65f24ba29f3bdcfb3c8218a307/"
    installedPackageFolderName = "jinja2"
    simplePackageInstall(packageName, installedPackageFolderName, linkPrefix,
                         path, localSitePackages)
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
示例#4
0
def stdouterrCapture(function, abbreviateStackTrace=False):
    patch_stdout_stderr()
    return function()
示例#5
0
def main(path):
    patch_stdout_stderr()

    path = pkg_resources.normalize_path(path)
    moduleInstallationPrefix = path + os.sep + "inst"

    localSitePackages = localSitePackageFolder(moduleInstallationPrefix)

    addLocalSitePackageToPythonPath(moduleInstallationPrefix)

    os.makedirs(localSitePackages)

    # the least error prone way to install packages at runtime is by invoking
    # pip via a subprocess, although it's not straightforward to do so here.
    for package in (
            'pandas==0.22',

            # we install requests up front because it's a dependency of synapseclient anyway
            # but also comes with certifi which will give us some root CA certs which aren't
            # available otherwise on MacOS on python > 3.6 due to openssl changes
            # and which we'll need to exercise the branch build option below if since we
            # download via https.
            'requests>=2.22.0',
    ):
        pip_install(package, localSitePackages)

    if 'PYTHON_CLIENT_GITHUB_USERNAME' in os.environ and 'PYTHON_CLIENT_GITHUB_BRANCH' in os.environ:
        # install via a branch, development option

        pythonClientGithubUsername = os.environ[
            'PYTHON_CLIENT_GITHUB_USERNAME']
        pythonClientGithubBranch = os.environ['PYTHON_CLIENT_GITHUB_BRANCH']
        archivePrefix = "synapsePythonClient-" + pythonClientGithubBranch
        archiveSuffix = ".zip"
        url = "https://github.com/" + pythonClientGithubUsername + "/synapsePythonClient/archive/" + pythonClientGithubBranch + archiveSuffix
        installPackage(
            "{}-{}".format(SYNAPSE_CLIENT_PACKAGE_NAME,
                           SYNAPSE_CLIENT_PACKAGE_VERSION),
            url,
            archivePrefix,
            archiveSuffix,
            path,
            moduleInstallationPrefix,
        )

    else:
        # if not installing from a branch, install the package via pip
        pip_install(
            "synapseclient[{}]=={}".format(
                os.environ.get('SYNAPSE_PYTHON_CLIENT_EXTRAS', ''),
                SYNAPSE_CLIENT_PACKAGE_VERSION), localSitePackages)

    # check that the installation worked
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
    import synapseclient

    if platform.system() != 'Windows':
        # on linux and mac we can install these via a pip subprocess...
        for package in (
                "MarkupSafe=={}".format(MARKUPSAFE_VERSION),
                "Jinja2=={}".format(JINJA_VERSION),
        ):
            pip_install(package, localSitePackages)

    else:
        # ...but on windows installing via a subprocess breaks seemingly with the wheel install,
        # so we use the creative sideloading as below.

        # Jinja2 depends on MarkupSafe
        packageName = "MarkupSafe-{}".format(MARKUPSAFE_VERSION)
        linkPrefix = "https://files.pythonhosted.org/packages/b9/2e/64db92e53b86efccfaea71321f597fa2e1b2bd3853d8ce658568f7a13094/"
        installedPackageFolderName = "markupsafe"
        simplePackageInstall(packageName, installedPackageFolderName,
                             linkPrefix, path, localSitePackages)
        addLocalSitePackageToPythonPath(moduleInstallationPrefix)
        #import markupsafe  # This fails intermittently

        packageName = "Jinja2-{}".format(JINJA_VERSION)
        linkPrefix = "https://files.pythonhosted.org/packages/64/a7/45e11eebf2f15bf987c3bc11d37dcc838d9dc81250e67e4c5968f6008b6c/"
        installedPackageFolderName = "jinja2"
        simplePackageInstall(packageName, installedPackageFolderName,
                             linkPrefix, path, localSitePackages)
        addLocalSitePackageToPythonPath(moduleInstallationPrefix)
        #import jinja2 # This fails intermittently

    addLocalSitePackageToPythonPath(moduleInstallationPrefix)