Ejemplo n.º 1
0
    def install(self):
        build_ext = self.get_finalized_command('build_ext')
        jep_built_path = build_ext.get_outputs()[0]
        version = self.distribution.metadata.get_version()

        if os.path.isdir(self.build_dir):
            jep_install_dir = os.path.join(self.install_dir, 'jep')
            if not os.path.exists(jep_install_dir):
                os.makedirs(jep_install_dir)

            # let's put the native lib in site-packages/jep where it belongs
            lib_copied = self.copy_file(
                jep_built_path,
                os.path.join(jep_install_dir, os.path.basename(jep_built_path)))

            # let's copy the jar file too
            jar_name = 'jep-{0}.jar'.format(version)
            jar_copied = self.copy_file(
                os.path.join('build', 'java', jar_name),
                os.path.join(jep_install_dir, jar_name))

            # let's copy the jep package to site-packages
            py_copied = self.copy_tree(
                os.path.join(self.build_dir, 'jep'),
                jep_install_dir)

            # now let's give it a link that works for Java
            # System.loadLibrary("jep")
            link_native_lib(jep_install_dir, jep_built_path)
        else:
            self.warn("'%s' does not exist -- no Python modules to install" %
                      self.build_dir)
            return
Ejemplo n.º 2
0
    def run(self):
        # make sure we're testing the latest
        self.run_command('build')

        # setup java classpath
        version = self.distribution.metadata.get_version()
        classpath = os.path.join(self.java_build, 'jep-' + version + '.jar')
        classpath += os.pathsep + os.path.join(self.java_build, 'jep-' + version + '-test.jar')
        classpath += os.pathsep + 'src/test/python/lib/sqlitejdbc-v056.jar'
        classpath += os.pathsep + 'src/test/python/lib/fakenetty.jar'

        # setup environment variables
        environment = {}
        if not is_osx() and not is_windows():
            environment['LD_LIBRARY_PATH'] = sysconfig.get_config_var('LIBDIR')
        # http://bugs.python.org/issue20614
        if is_windows():
            environment['SYSTEMROOT'] = os.environ['SYSTEMROOT']

        java_path = os.path.join(get_java_home(), 'bin')
        # if multiple versions of python are installed, this helps ensure the right
        # version is used
        executable = sys.executable
        if executable:
            py_path = os.path.dirname(executable)
            # java_path before python_path because py_path might point to a
            # default system path, like /usr/bin, which can contain other java
            # executables. Since all the subprocesses are Java running jep it
            # is very important to get the right java.
            environment['PATH'] = java_path + os.pathsep + py_path + os.pathsep + os.environ['PATH']
        else:
            environment['PATH'] = java_path + os.pathsep + os.environ['PATH']
        venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)
        if not venv:
            # PYTHONHOME helps locate libraries but should not be set in a virtual env
            prefix = sysconfig.get_config_var('prefix')
            exec_prefix = sysconfig.get_config_var('exec_prefix')
            if prefix == exec_prefix:
                environment['PYTHONHOME'] = prefix
            else:
                environment['PYTHONHOME'] = prefix + ':' + exec_prefix

        # find the jep library and makes sure it's named correctly
        build_ext = self.get_finalized_command('build_ext')
        jep_lib = build_ext.get_outputs()[0]
        built_dir = os.path.dirname(jep_lib)
        link_native_lib(built_dir, jep_lib)
        
        environment['PYTHONPATH'] = self.get_finalized_command('build').build_lib

        # actually kick off the tests
        import subprocess
        args = [os.path.join(java_path, 'java'),
                '-classpath', '{0}'.format(classpath),
                'jep.Run', 'src/test/python/runtests.py']
        p = subprocess.Popen(args, env=environment)
        rc = p.wait()
        if rc != 0:
            raise DistutilsExecError("Unit tests failed with exit status %d" % (rc))
Ejemplo n.º 3
0
    def run(self):
        # make sure we're testing the latest
        self.run_command('build')

        # setup java classpath
        version = self.distribution.metadata.get_version()
        classpath = os.path.join(self.java_build, 'jep-' + version + '.jar')
        classpath += os.pathsep + os.path.join(self.java_build, 'jep-' + version + '-test.jar')
        classpath += os.pathsep + 'tests/lib/sqlitejdbc-v056.jar'
        classpath += os.pathsep + 'tests/lib/fakenetty.jar'

        # setup environment variables
        environment = {}
        if not is_osx() and not is_windows():
            environment['LD_LIBRARY_PATH'] = sysconfig.get_config_var('LIBDIR')

            # set the LD_PRELOAD environment variable if we can locate the
            # libpython<version>.so library.
            lib_python = get_libpython()
            if lib_python:
                environment['LD_PRELOAD'] = lib_python

        # http://bugs.python.org/issue20614
        if is_windows():
            environment['SYSTEMROOT'] = os.environ['SYSTEMROOT']

        java_path = os.path.join(get_java_home(), 'bin')
        # if multiple versions of python are installed, this helps ensure the right
        # version is used
        executable = sys.executable
        if executable:
            py_path = os.path.dirname(executable)
            environment['PATH'] = py_path + os.pathsep + java_path + os.pathsep + os.environ['PATH']
        else:
            environment['PATH'] = java_path + os.pathsep + os.environ['PATH']

        # find the jep library and makes sure it's named correctly
        build_ext = self.get_finalized_command('build_ext')
        jep_lib = build_ext.get_outputs()[0]
        built_dir = os.path.dirname(jep_lib)
        link_native_lib(built_dir, jep_lib)

        # actually kick off the tests
        import subprocess
        args = [os.path.join(java_path, 'java'),
                '-classpath', '{0}'.format(classpath),
                '-Djava.library.path={0}'.format(built_dir),
                'jep.Run', 'tests/runtests.py']
        p = subprocess.Popen(args, env=environment)
        rc = p.wait()
        if rc != 0:
            raise DistutilsExecError("Unit tests failed with exit status %d" % (rc))
Ejemplo n.º 4
0
    def run(self):
        # make sure we're testing the latest
        self.run_command('build')

        # setup java classpath
        version = self.distribution.metadata.get_version()
        classpath = os.path.join(self.java_build, 'jep-' + version + '.jar')
        classpath += os.pathsep + os.path.join(self.java_build, 'jep.test-' + version + '.jar')
        classpath += os.pathsep + 'tests/lib/sqlitejdbc-v056.jar'
        classpath += os.pathsep + 'tests/lib/fakenetty.jar'

        # setup environment variables
        environment = {}
        if not is_osx() and not is_windows():
            environment['LD_LIBRARY_PATH'] = sysconfig.get_config_var('LIBDIR')

            # set the LD_PRELOAD environment variable if we can locate the
            # libpython<version>.so library.
            lib_python = get_libpython()
            if lib_python:
                environment['LD_PRELOAD'] = lib_python

        # http://bugs.python.org/issue20614
        if is_windows():
            environment['SYSTEMROOT'] = os.environ['SYSTEMROOT']

        # if multiple versions of python are installed, this helps ensure the right
        # version is used
        executable = sys.executable
        if executable:
            environment['PATH'] = os.path.dirname(executable) + os.pathsep + os.environ['PATH']

        # find the jep library and makes sure it's named correctly
        build_ext = self.get_finalized_command('build_ext')
        jep_lib = build_ext.get_outputs()[0]
        built_dir = os.path.dirname(jep_lib)
        link_native_lib(built_dir, jep_lib)

        # actually kick off the tests
        import subprocess
        args = ['java',
                '-classpath', '{0}'.format(classpath),
                '-Djava.library.path={0}'.format(built_dir),
                'jep.Run', 'tests/runtests.py']
        p = subprocess.Popen(args, env=environment)
        p.wait()