Python os.pathsep() Examples
The following are 30
code examples of os.pathsep().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: install_solc.py From py-solc with MIT License | 7 votes |
def is_executable_available(program): def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) fpath = os.path.dirname(program) if fpath: if is_exe(program): return True else: for path in os.environ["PATH"].split(os.pathsep): path = path.strip('"') exe_file = os.path.join(path, program) if is_exe(exe_file): return True return False
Example #2
Source File: monorepo_build.py From llvm-zorg with Apache License 2.0 | 6 votes |
def static_analyzer_benchmarks_builder(): """Run static analyzer benchmarks""" header("Static Analyzer Benchmarks") benchmark_script = conf.workspace + "/utils-analyzer/SATestBuild.py" benchmarks_dir = conf.workspace + "/test-suite-ClangAnalyzer/" compiler_bin_dir = conf.workspace + "/host-compiler/bin/" scanbuild_bin_dir = conf.workspace + "/tools-scan-build/bin/" old_path = os.environ.get("PATH", "") env = dict(os.environ, PATH=compiler_bin_dir + os.pathsep + scanbuild_bin_dir + os.pathsep + old_path) benchmark_cmd = [benchmark_script, "--strictness", "0" ] run_cmd(benchmarks_dir, benchmark_cmd, env=env) footer()
Example #3
Source File: select_jdk.py From mx with GNU General Public License v2.0 | 6 votes |
def get_shell_commands(args, jdk, extra_jdks): setvar_format = get_setvar_format(args.shell) shell_commands = StringIO() print(setvar_format % ('JAVA_HOME', jdk), file=shell_commands) if extra_jdks: print(setvar_format % ('EXTRA_JAVA_HOMES', os.pathsep.join(extra_jdks)), file=shell_commands) path = os.environ.get('PATH').split(os.pathsep) if path: jdk_bin = join(jdk, 'bin') old_java_home = os.environ.get('JAVA_HOME') replace = join(old_java_home, 'bin') if old_java_home else None if replace in path: path = [e if e != replace else jdk_bin for e in path] else: path = [jdk_bin] + path print(setvar_format % ('PATH', get_PATH_sep(args.shell).join(path)), file=shell_commands) return shell_commands.getvalue().strip()
Example #4
Source File: conf.py From tox with MIT License | 6 votes |
def generate_draft_news(): home = "https://github.com" issue = "{}/issue".format(home) fragments_path = ROOT_SRC_TREE_DIR / "docs" / "changelog" for pattern, replacement in ( (r"[^`]@([^,\s]+)", r"`@\1 <{}/\1>`_".format(home)), (r"[^`]#([\d]+)", r"`#pr\1 <{}/\1>`_".format(issue)), ): for path in fragments_path.glob("*.rst"): path.write_text(re.sub(pattern, replacement, path.read_text())) env = os.environ.copy() env["PATH"] += os.pathsep.join( [os.path.dirname(sys.executable)] + env["PATH"].split(os.pathsep), ) changelog = subprocess.check_output( ["towncrier", "--draft", "--version", "DRAFT"], cwd=str(ROOT_SRC_TREE_DIR), env=env, ).decode("utf-8") if "No significant changes" in changelog: content = "" else: note = "*Changes in master, but not released yet are under the draft section*." content = "{}\n\n{}".format(note, changelog) (ROOT_SRC_TREE_DIR / "docs" / "_draft.rst").write_text(content)
Example #5
Source File: common.py From tox with MIT License | 6 votes |
def base_discover(envconfig): base_python = envconfig.basepython spec = PythonSpec.from_name(base_python) # 1. check passed in discover elements discovers = envconfig.config.option.discover if not discovers: discovers = os.environ.get(str("TOX_DISCOVER"), "").split(os.pathsep) for discover in discovers: if os.path.exists(discover): cur_spec = exe_spec(discover, envconfig.basepython) if cur_spec is not None and cur_spec.satisfies(spec): return spec, cur_spec.path # 2. check current if spec.name is not None and CURRENT.satisfies(spec): return spec, CURRENT.path return spec, None
Example #6
Source File: setup.py From PyOptiX with MIT License | 6 votes |
def save_pyoptix_conf(nvcc_path, compile_args, include_dirs, library_dirs, libraries): try: config = ConfigParser() config.add_section('pyoptix') config.set('pyoptix', 'nvcc_path', nvcc_path) config.set('pyoptix', 'compile_args', os.pathsep.join(compile_args)) config.set('pyoptix', 'include_dirs', os.pathsep.join(include_dirs)) config.set('pyoptix', 'library_dirs', os.pathsep.join(library_dirs)) config.set('pyoptix', 'libraries', os.pathsep.join(libraries)) tmp = NamedTemporaryFile(mode='w+', delete=False) config.write(tmp) tmp.close() config_path = os.path.join(os.path.dirname(sys.executable), 'pyoptix.conf') check_call_sudo_if_fails(['cp', tmp.name, config_path]) check_call_sudo_if_fails(['cp', tmp.name, '/etc/pyoptix.conf']) check_call_sudo_if_fails(['chmod', '644', config_path]) check_call_sudo_if_fails(['chmod', '644', '/etc/pyoptix.conf']) except Exception as e: print("PyOptiX configuration could not be saved. When you use pyoptix.Compiler, " "nvcc path must be in PATH, OptiX library paths must be in LD_LIBRARY_PATH, and pyoptix.Compiler " "attributes should be set manually.")
Example #7
Source File: test_interpreters.py From tox with MIT License | 6 votes |
def test_find_alias_on_path(monkeypatch, tmp_path, mocker): reporter.update_default_reporter(Verbosity.DEFAULT, Verbosity.DEBUG) magic = tmp_path / "magic{}".format(os.path.splitext(sys.executable)[1]) os.symlink(sys.executable, str(magic)) monkeypatch.setenv( str("PATH"), os.pathsep.join([str(tmp_path)] + os.environ.get(str("PATH"), "").split(os.pathsep)), ) class envconfig: basepython = "magic" envname = "pyxx" config = mocker.MagicMock() config.return_value.option.return_value.discover = [] detected = py.path.local.sysfind("magic") assert detected t = tox_get_python_executable(envconfig).lower() assert t == str(magic).lower()
Example #8
Source File: system_info.py From recruit with Apache License 2.0 | 6 votes |
def __init__(self, default_lib_dirs=default_lib_dirs, default_include_dirs=default_include_dirs, verbosity=1, ): self.__class__.info = {} self.local_prefixes = [] defaults = {'library_dirs': os.pathsep.join(default_lib_dirs), 'include_dirs': os.pathsep.join(default_include_dirs), 'runtime_library_dirs': os.pathsep.join(default_runtime_dirs), 'rpath': '', 'src_dirs': os.pathsep.join(default_src_dirs), 'search_static_first': str(self.search_static_first), 'extra_compile_args': '', 'extra_link_args': ''} self.cp = ConfigParser(defaults) self.files = [] self.files.extend(get_standard_file('.numpy-site.cfg')) self.files.extend(get_standard_file('site.cfg')) self.parse_config_files() if self.section is not None: self.search_static_first = self.cp.getboolean( self.section, 'search_static_first') assert isinstance(self.search_static_first, int)
Example #9
Source File: wspbus.py From cherrypy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _extend_pythonpath(env): """Prepend current working dir to PATH environment variable if needed. If sys.path[0] is an empty string, the interpreter was likely invoked with -m and the effective path is about to change on re-exec. Add the current directory to $PYTHONPATH to ensure that the new process sees the same path. This issue cannot be addressed in the general case because Python cannot reliably reconstruct the original command line (http://bugs.python.org/issue14208). (This idea filched from tornado.autoreload) """ path_prefix = '.' + os.pathsep existing_path = env.get('PYTHONPATH', '') needs_patch = ( sys.path[0] == '' and not existing_path.startswith(path_prefix) ) if needs_patch: env['PYTHONPATH'] = path_prefix + existing_path
Example #10
Source File: configparserwrapper.py From CAMISIM with Apache License 2.0 | 6 votes |
def _get_full_path(value): """ convert string to absolute normpath. @param value: some string to be converted @type value: basestring @return: absolute normpath @rtype: basestring """ assert isinstance(value, basestring) parent_directory, filename = os.path.split(value) if not parent_directory and not os.path.isfile(value): for path in os.environ["PATH"].split(os.pathsep): path = path.strip('"') exe_file = os.path.join(path, filename) if os.path.isfile(exe_file): value = exe_file break value = os.path.expanduser(value) value = os.path.normpath(value) value = os.path.abspath(value) return value
Example #11
Source File: select_jdk.py From mx with GNU General Public License v2.0 | 6 votes |
def apply_selection(args, jdk, extra_jdks): print('JAVA_HOME=' + jdk) if extra_jdks: print('EXTRA_JAVA_HOMES=' + os.pathsep.join(extra_jdks)) if args.shell_file: with open(args.shell_file, 'w') as fp: print(get_shell_commands(args, jdk, extra_jdks), file=fp) else: env = get_suite_env_file(args.suite_path) if env: with open(env, 'a') as fp: print('JAVA_HOME=' + jdk, file=fp) if extra_jdks: print('EXTRA_JAVA_HOMES=' + os.pathsep.join(extra_jdks), file=fp) print('Updated', env) else: print() print('To apply the above environment variable settings, eval the following in your shell:') print() print(get_shell_commands(args, jdk, extra_jdks))
Example #12
Source File: processor.py From pyspectator with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __get_processor_name(cls): cpu_name = None os_name = platform.system() if os_name == 'Windows': cpu_name = platform.processor() elif os_name == 'Darwin': os.environ['PATH'] = os.environ['PATH'] + os.pathsep + '/usr/sbin' command = ('sysctl', '-n', 'machdep.cpu.brand_string') output = subprocess.check_output(command) if output: cpu_name = output.decode().strip() elif os_name == 'Linux': all_info = subprocess.check_output('cat /proc/cpuinfo', shell=True) all_info = all_info.strip().split(os.linesep.encode()) for line in all_info: line = line.decode() if 'model name' not in line: continue cpu_name = re.sub('.*model name.*:', str(), line, 1).strip() break return cpu_name
Example #13
Source File: utils.py From maya-command-search with GNU General Public License v3.0 | 6 votes |
def findSearchIcon(): """ Loop over all paths in the XBMLANGPATH variable and see if custom icon can be found, if this is not the case a maya default one will be returned. :return: CMD search icon. :rtype: QIcon """ # construct all icon paths paths = [] if os.environ.get("XBMLANGPATH"): paths = os.environ.get("XBMLANGPATH").split(os.pathsep) paths.append(os.path.join(os.path.split(__file__)[0], "icons")) # find icon for path in paths: filepath = os.path.join(path, "rjCMDSearch.png") if os.path.exists(filepath): return QIcon(filepath) return QIcon(":/cmdWndIcon.png") # ----------------------------------------------------------------------------
Example #14
Source File: rnaseq_unc_pipeline.py From toil-scripts with Apache License 2.0 | 6 votes |
def which(program): import os def is_exe(f): return os.path.isfile(f) and os.access(f, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: for path in os.environ["PATH"].split(os.pathsep): path = path.strip('"') exe_file = os.path.join(path, program) if is_exe(exe_file): return exe_file return None
Example #15
Source File: core_library.py From toonapilib with MIT License | 6 votes |
def get_binary_path(executable, logging_level='INFO'): """Gets the software name and returns the path of the binary.""" if sys.platform == 'win32': if executable == 'start': return executable executable = executable + '.exe' if executable in os.listdir('.'): binary = os.path.join(os.getcwd(), executable) else: binary = next((os.path.join(path, executable) for path in os.environ['PATH'].split(os.pathsep) if os.path.isfile(os.path.join(path, executable))), None) else: venv_parent = get_venv_parent_path() venv_bin_path = os.path.join(venv_parent, '.venv', 'bin') if not venv_bin_path in os.environ.get('PATH'): if logging_level == 'DEBUG': print(f'Adding path {venv_bin_path} to environment PATH variable') os.environ['PATH'] = os.pathsep.join([os.environ['PATH'], venv_bin_path]) binary = shutil.which(executable) return binary if binary else None
Example #16
Source File: build.py From llvm-zorg with Apache License 2.0 | 6 votes |
def static_analyzer_benchmarks_builder(): """Run static analyzer benchmarks""" header("Static Analyzer Benchmarks") benchmark_script = conf.workspace + "/utils-analyzer/SATestBuild.py" benchmarks_dir = conf.workspace + "/test-suite-ClangAnalyzer/" compiler_bin_dir = conf.workspace + "/host-compiler/bin/" scanbuild_bin_dir = conf.workspace + "/tools-scan-build/bin/" old_path = os.environ.get("PATH", "") env = dict(os.environ, PATH=compiler_bin_dir + os.pathsep + scanbuild_bin_dir + os.pathsep + old_path) benchmark_cmd = [benchmark_script, "--strictness", "0" ] run_cmd(benchmarks_dir, benchmark_cmd, env=env) footer()
Example #17
Source File: main.py From recipes-py with Apache License 2.0 | 6 votes |
def _strip_virtualenv(): # Prune all evidence of VPython/VirtualEnv out of the environment. This means # that recipe engine 'unwraps' vpython VirtualEnv path/env manipulation. # Invocations of `python` from recipes should never inherit the recipe # engine's own VirtualEnv. # Set by VirtualEnv, no need to keep it. os.environ.pop('VIRTUAL_ENV', None) # Set by VPython, if recipes want it back they have to set it explicitly. os.environ.pop('PYTHONNOUSERSITE', None) # Look for "activate_this.py" in this path, which is installed by VirtualEnv. # This mechanism is used by vpython as well to sanitize VirtualEnvs from # $PATH. os.environ['PATH'] = os.pathsep.join([ p for p in os.environ.get('PATH', '').split(os.pathsep) if not os.path.isfile(os.path.join(p, 'activate_this.py')) ])
Example #18
Source File: install.py From py-solc with MIT License | 6 votes |
def is_executable_available(program): def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) fpath = os.path.dirname(program) if fpath: if is_exe(program): return True else: for path in os.environ["PATH"].split(os.pathsep): path = path.strip('"') exe_file = os.path.join(path, program) if is_exe(exe_file): return True return False
Example #19
Source File: filesystem.py From py-solc with MIT License | 6 votes |
def is_executable_available(program): def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) fpath = os.path.dirname(program) if fpath: if is_exe(program): return True else: for path in os.environ["PATH"].split(os.pathsep): path = path.strip('"') exe_file = os.path.join(path, program) if is_exe(exe_file): return True return False
Example #20
Source File: compat.py From core with MIT License | 6 votes |
def remove_googleapiclient(): """Check if the compatibility must be maintained The Maya 2018 version tries to import the `http` module from Maya2018/plug-ins/MASH/scripts/googleapiclient/http.py in stead of the module from six.py. This import conflict causes a crash Avalon's publisher. This is due to Autodesk adding paths to the PYTHONPATH environment variable which contain modules instead of only packages. """ keyword = "googleapiclient" # reconstruct python paths python_paths = os.environ["PYTHONPATH"].split(os.pathsep) paths = [path for path in python_paths if keyword not in path] os.environ["PYTHONPATH"] = os.pathsep.join(paths)
Example #21
Source File: lib.py From core with MIT License | 6 votes |
def which(program): """Locate `program` in PATH Arguments: program (str): Name of program, e.g. "python" """ def is_exe(fpath): if os.path.isfile(fpath) and os.access(fpath, os.X_OK): return True return False for path in os.environ["PATH"].split(os.pathsep): for ext in os.getenv("PATHEXT", "").split(os.pathsep): fname = program + ext.lower() abspath = os.path.join(path.strip('"'), fname) if is_exe(abspath): return abspath return None
Example #22
Source File: lib.py From core with MIT License | 6 votes |
def which_app(app): """Locate `app` in PATH Arguments: app (str): Name of app, e.g. "python" """ for path in os.environ["PATH"].split(os.pathsep): fname = app + ".toml" abspath = os.path.join(path.strip('"'), fname) if os.path.isfile(abspath): return abspath return None
Example #23
Source File: rnaseq_unc_tcga_versions.py From toil-scripts with Apache License 2.0 | 6 votes |
def which(program): import os def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: for path in os.environ["PATH"].split(os.pathsep): path = path.strip('"') exe_file = os.path.join(path, program) if is_exe(exe_file): return exe_file return None
Example #24
Source File: util.py From pyspelling with MIT License | 6 votes |
def which(executable): """See if executable exists.""" location = None if os.path.basename(executable) != executable: if os.path.isfile(executable): location = executable else: paths = [x for x in os.environ["PATH"].split(os.pathsep) if not x.isspace()] paths.extend([x for x in os.environ.get("TOX_SPELL_PATH", "").split(os.pathsep) if not x.isspace()]) for path in paths: exe = os.path.join(path, executable) if os.path.isfile(exe): location = exe break return location
Example #25
Source File: build_release.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
def call_tox(toxenv, *args, python=sys.executable): """Call tox. Args: toxenv: Which tox environment to use *args: The arguments to pass. python: The python interpreter to use. """ env = os.environ.copy() env['PYTHON'] = python env['PATH'] = os.environ['PATH'] + os.pathsep + os.path.dirname(python) subprocess.run( [sys.executable, '-m', 'tox', '-vv', '-e', toxenv] + list(args), env=env, check=True)
Example #26
Source File: setup.py From coala-quickstart with GNU Affero General Public License v3.0 | 5 votes |
def set_python_path(path): if 'PYTHONPATH' in os.environ: user_paths = os.environ['PYTHONPATH'].split(os.pathsep) user_paths.insert(0, path) os.environ['PYTHONPATH'] = os.pathsep.join(user_paths) else: os.environ['PYTHONPATH'] = path
Example #27
Source File: sk1-launcher.py From sk1-wx with GNU General Public License v3.0 | 5 votes |
def get_path_var(): paths = os.environ["PATH"].split(os.pathsep) ret = [] for path in paths: for item in RESTRICTED: if item not in path: ret.append(path) return os.pathsep.join(ret)
Example #28
Source File: config.py From honeybee with GNU General Public License v3.0 | 5 votes |
def _which(program): """Find executable programs. Args: program: Full file name for the program (e.g. rad.exe) Returns: File directory and full path to program in case of success. None, None in case of failure. """ def is_exe(fpath): # Make sure it's not part of Dive installation as DIVA doesn't # follow the standard structure folder for Daysim and Radiance if os.name == 'nt' and fpath.upper().find("DIVA"): return False # Return true if file exists and is executable return os.path.isfile(fpath) and os.access(fpath, os.X_OK) # check for the file in all path in environment for path in os.environ["PATH"].split(os.pathsep): # strip "" from Windows path exe_file = os.path.join(path.strip('"'), program) if is_exe(exe_file): return path, exe_file # couldn't find it! return None :| return None, None
Example #29
Source File: asciidoc2html.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
def call(self, src: pathlib.Path, dst: pathlib.Path, *args): """Call asciidoc for the given files. Args: src: The source .asciidoc file. dst: The destination .html file, or None to auto-guess. *args: Additional arguments passed to asciidoc. """ print("Calling asciidoc for {}...".format(src.name)) assert self._cmd is not None # for mypy cmdline = self._cmd[:] if dst is not None: cmdline += ['--out-file', str(dst)] cmdline += args cmdline.append(str(src)) # So the virtualenv's Pygments is found bin_path = pathlib.Path(sys.executable).parent try: env = os.environ.copy() env['HOME'] = str(self._homedir) env['PATH'] = str(bin_path) + os.pathsep + env['PATH'] subprocess.run(cmdline, check=True, env=env) except (subprocess.CalledProcessError, OSError) as e: self._failed = True utils.print_error(str(e)) print("Keeping modified sources in {}.".format(self._homedir), file=sys.stderr) sys.exit(1)
Example #30
Source File: test_system_info.py From recruit with Apache License 2.0 | 5 votes |
def setup(self): """ Create the libraries """ # Create 2 sources and 2 libraries self._dir1 = mkdtemp() self._src1 = os.path.join(self._dir1, 'foo.c') self._lib1 = os.path.join(self._dir1, 'libfoo.so') self._dir2 = mkdtemp() self._src2 = os.path.join(self._dir2, 'bar.c') self._lib2 = os.path.join(self._dir2, 'libbar.so') # Update local site.cfg global simple_site, site_cfg site_cfg = simple_site.format(**{ 'dir1': self._dir1, 'lib1': self._lib1, 'dir2': self._dir2, 'lib2': self._lib2, 'pathsep': os.pathsep, 'lib2_escaped': _shell_utils.NativeParser.join([self._lib2]) }) # Write site.cfg fd, self._sitecfg = mkstemp() os.close(fd) with open(self._sitecfg, 'w') as fd: fd.write(site_cfg) # Write the sources with open(self._src1, 'w') as fd: fd.write(fakelib_c_text) with open(self._src2, 'w') as fd: fd.write(fakelib_c_text) # We create all class-instances def site_and_parse(c, site_cfg): c.files = [site_cfg] c.parse_config_files() return c self.c_default = site_and_parse(get_class('default'), self._sitecfg) self.c_temp1 = site_and_parse(get_class('temp1'), self._sitecfg) self.c_temp2 = site_and_parse(get_class('temp2'), self._sitecfg)