Пример #1
0
 def initialize_options(self):
     javadoc.outdir = 'javadoc'
     if not os.path.exists(javadoc.outdir):
         os.makedirs(javadoc.outdir)
     self.version = []
     if is_apple_jdk():
         self.javadoc = os.path.join(get_java_home(), 'Commands', 'javadoc')
     else:
         self.javadoc = os.path.join(get_java_home(), 'bin', 'javadoc')
Пример #2
0
 def initialize_options(self):
     javadoc.outdir = 'javadoc'
     if not os.path.exists(javadoc.outdir):
         os.makedirs(javadoc.outdir)
     self.version = []
     if is_apple_jdk():
         self.javadoc = os.path.join(get_java_home(), 'Commands', 'javadoc')
     else:
         self.javadoc = os.path.join(get_java_home(), 'bin', 'javadoc')
Пример #3
0
class javadoc(Command):
    outdir = None

    user_options = [
        ('javadoc=', None,
         'use javadoc (default: {0}/bin/javadoc)'.format(get_java_home())),
    ]

    def initialize_options(self):
        javadoc.outdir = 'javadoc'
        if not os.path.exists(javadoc.outdir):
            os.makedirs(javadoc.outdir)
        self.version = []
        if is_apple_jdk():
            self.javadoc = os.path.join(get_java_home(), 'Commands', 'javadoc')
        else:
            self.javadoc = os.path.join(get_java_home(), 'bin', 'javadoc')

    def finalize_options(self):
        self.version = self.distribution.metadata.get_version()
        self.java_files = self.distribution.java_files

    def run(self):
        spawn([
            self.javadoc, '-public', '-notimestamp', '-d',
            os.path.join(javadoc.outdir, self.version), '-sourcepath',
            'src/main/java', '-subpackages', 'jep'
        ])
Пример #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-' + 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))
Пример #5
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))
Пример #6
0
def get_files(pattern):
    ret = []
    for root, dirs, files in os.walk("src"):
        for f in files:
            if f.endswith(pattern):
                ret.append(os.path.join(root, f))
    return ret


def read_file(name):
    return codecs.open(os.path.join(os.path.dirname(__file__), name), encoding="utf-8").read()


if __name__ == "__main__":
    get_java_home()

    defines = [("PACKAGE", "jep"), ("USE_DEALLOC", 1), ("USE_NUMPY", numpy_found), ("VERSION", '"{0}"'.format(VERSION))]
    if is_windows():
        defines.append(("WIN32", 1))
        # Disable warnings about Secure CRT Functions in util.c and pyembed.c.
        defines.append(("_CRT_SECURE_NO_WARNINGS", 1))

    setup(
        name="jep",
        version=VERSION,
        description="Jep embeds CPython in Java",
        long_description=read_file("README.rst"),
        author="Jep Developers",
        author_email="*****@*****.**",
        url="https://github.com/mrj0/jep",
Пример #7
0
Файл: setup.py Проект: zhmch/jep
def get_files(pattern):
    ret = []
    for root, dirs, files in os.walk('src'):
        for f in files:
            if f.endswith(pattern):
                ret.append(os.path.join(root, f))
    return ret


def read_file(name):
    return codecs.open(os.path.join(os.path.dirname(__file__), name),
                       encoding='utf-8').read()


if __name__ == '__main__':
    get_java_home()

    defines = [
        ('PACKAGE', 'jep'),
        ('USE_DEALLOC', 1),
        ('JEP_NUMPY_ENABLED', numpy_found),
        ('VERSION', '"{0}"'.format(VERSION)),
    ]
    ldlib = sysconfig.get_config_var('LDLIBRARY')
    if ldlib:
        defines.append(('PYTHON_LDLIBRARY', '"' + ldlib + '"'))
    if is_windows():
        defines.append(('WIN32', 1))
        #Disable warnings about Secure CRT Functions in util.c and pyembed.c.
        defines.append(('_CRT_SECURE_NO_WARNINGS', 1))