Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def detect_pip_exe():
"""
Returns the path to the pip version used. Factors in the available Python
version.
"""
from pybombs.config_manager import config_manager
if vcompare('>=', config_manager.get_python_version(), '3'):
default_pip = 'pip3'
else:
default_pip = 'pip2'
if sysutils.which(default_pip) is not None:
return default_pip
if sysutils.which('pip') is not None:
return 'pip'
return None
def __init__(self, logger):
ExternPackager.__init__(self, logger)
self.command = None
if sysutils.which('zypper') is not None:
self.command = 'zypper'
if sysutils.which('rpm') is not None:
self.fastcommand = 'rpm'
else:
self.fastcommand = None
def detect_pip_exe():
"""
Returns the path to the pip version used. Factors in the available Python
version.
"""
from pybombs.config_manager import config_manager
if vcompare('>=', config_manager.get_python_version(), '3'):
default_pip = 'pip3'
else:
default_pip = 'pip2'
if sysutils.which(default_pip) is not None:
return default_pip
if sysutils.which('pip') is not None:
return 'pip'
return None
def __init__(self, logger):
ExternPackager.__init__(self, logger)
self.command = None
if sysutils.which('zypper') is not None:
self.command = 'zypper'
if sysutils.which('rpm') is not None:
self.fastcommand = 'rpm'
else:
self.fastcommand = None
def supported(self):
"""
Check if we can even run 'pkg-config'. Return True if yes.
"""
return sysutils.which('pkg-config') is not None
def _write_env_file(self):
"""
Create a setup_env.sh file in the prefix
"""
prefix_recipe = get_prefix_recipe("default_prefix")
if prefix_recipe is None:
self.log.error("Could not find recipe for `{0}'".format(self.args.recipe))
return False
path = self.prefix.prefix_dir
if not sysutils.dir_is_writable(path):
self.log.error("Cannot write to prefix path `{0}'.".format(path))
return -1
try:
for fname, content in prefix_recipe.files.items():
sysutils.write_file_in_subdir(
path, fname, prefix_recipe.var_replace_all(content))
except (PBException, OSError, IOError):
return False
return True
def _write_env_file(self):
"""
Create a setup_env.sh file in the prefix
"""
prefix_recipe = get_prefix_recipe("default_prefix")
if prefix_recipe is None:
self.log.error("Could not find recipe for `{0}'".format(self.args.recipe))
return False
path = self.prefix.prefix_dir
if not sysutils.dir_is_writable(path):
self.log.error("Cannot write to prefix path `{0}'.".format(path))
return -1
try:
for fname, content in prefix_recipe.files.items():
sysutils.write_file_in_subdir(
path, fname, prefix_recipe.var_replace_all(content))
except (PBException, OSError, IOError):
return False
return True
def create_subdirs_and_files(path, dirs, files):
" Create subdirs and files "
sysutils.require_subdirs(path, [k for k, v in dirs.items() if v])
for fname, content in files.items():
sysutils.write_file_in_subdir(path, fname, prefix_recipe.var_replace_all(content))
def register_alias(alias, path):
Stores information about the current prefix being used.
"""
prefix_conf_dir = '.pybombs'
src_dir_name = 'src'
env_prefix_var = 'PYBOMBS_PREFIX'
env_srcdir_var = 'PYBOMBS_PREFIX_SRC'
inv_file_name = 'inventory.yml'
setup_env_key = 'setup_env'
default_config_info = {
'prefix_aliases': {},
'prefix_config_dir': {},
'env': {},
'recipes': {},
'packages': {'gnuradio': {'forcebuild': True}},
'categories': {'common': {'forcebuild': True}},
'python_ver': sysutils.get_interpreter_version(),
}
default_env_unix = { # These envs are non-portable
'PATH': "{prefix_dir}/bin:$PATH",
'PYTHONPATH': "{python_path}:$PYTHONPATH",
'LD_LIBRARY_PATH': "{prefix_dir}/lib:{prefix_dir}/lib64/:$LD_LIBRARY_PATH",
'LIBRARY_PATH': "{prefix_dir}/lib:{prefix_dir}/lib64/:$LIBRARY_PATH",
'PKG_CONFIG_PATH':
"{prefix_dir}/lib/pkgconfig:{prefix_dir}/lib64/pkgconfig:$PKG_CONFIG_PATH",
'GRC_BLOCKS_PATH': "{prefix_dir}/share/gnuradio/grc/blocks:$GRC_BLOCKS_PATH",
'PYBOMBS_PREFIX': "{prefix_dir}",
}
def __init__(self, args, cfg_list, select_prefix=None):
self.log = pb_logging.logger.getChild("ConfigManager.PrefixInfo")
self.prefix_dir = None
def __init__(self, logger):
ExternPackager.__init__(self, logger)
self.command = None
if sysutils.which('dnf') is not None:
self.command = 'dnf'
elif sysutils.which('yum') is not None:
self.command = 'yum'