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))
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()
def copy_scripts(self): """Copy each script listed in 'self.scripts'; if it's marked as a Python script in the Unix way (first line matches 'first_line_re', ie. starts with "\#!" and contains "python"), then adjust the first line to refer to the current Python interpreter as we copy. """ self.mkpath(self.build_dir) outfiles = [] install = self.get_finalized_command('install') context = dict( version=self.distribution.metadata.get_version(), install_base=install.install_base, install_platbase=install.install_platbase, install_lib=install.install_lib, virtual_env=os.environ.get('VIRTUAL_ENV') or '', ld_library_path='', ld_preload='', ) if not is_osx() and not is_windows(): context['ld_library_path'] = 'LD_LIBRARY_PATH="' + \ sysconfig.get_config_var('LIBDIR') + \ ':{0}"; export LD_LIBRARY_PATH'.format( install.install_lib) # set the LD_PRELOAD environment variable if we can locate the # libpython<version>.so library. lib_python = get_libpython() if lib_python: context['ld_preload'] = 'LD_PRELOAD="{0}"; export LD_PRELOAD'.format( lib_python) for script in self.scripts: if is_windows(): script = '{0}.bat'.format(script) script = convert_path(script) outfile = os.path.join(self.build_dir, os.path.basename(script)) outfiles.append(outfile) if not self.force and not newer(script, outfile): log.debug("not copying %s (up-to-date)", script) continue # Always open the file, but ignore failures in dry-run mode -- # that way, we'll get accurate feedback if we can read the # script. try: f = open(script, "r") except IOError: if not self.dry_run: raise f = None log.info("copying and adjusting %s -> %s", script, self.build_dir) if not self.dry_run: outf = open(outfile, "w") outf.write(f.read().format(**context)) outf.close() if f: f.close() if os.name == 'posix': for file in outfiles: if self.dry_run: log.info("changing mode of %s", file) else: oldmode = os.stat(file)[ST_MODE] & 0o7777 newmode = (oldmode | 0o555) & 0o7777 if newmode != oldmode: log.info("changing mode of %s from %o to %o", file, oldmode, newmode) os.chmod(file, newmode)