def execute(args): p, args = parse_args(args) config = get_or_merge_config(None, **args.__dict__) variants = get_package_variants(args.recipe, config) set_language_env_vars(variants) channel_urls = args.__dict__.get('channel') or args.__dict__.get('channels') or () config.channel_urls = [] for url in channel_urls: # allow people to specify relative or absolute paths to local channels # These channels still must follow conda rules - they must have the # appropriate platform-specific subdir (e.g. win-64) if os.path.isdir(url): if not os.path.isabs(url): url = os.path.normpath(os.path.abspath(os.path.join(os.getcwd(), url))) url = url_path(url) config.channel_urls.append(url) config.override_channels = args.override_channels metadata_tuples = api.render(args.recipe, config=config, no_download_source=args.no_source) if args.output: with LoggingContext(logging.CRITICAL + 1): config.verbose = False config.debug = False paths = api.get_output_file_paths(metadata_tuples, config=config) print('\n'.join(sorted(paths))) else: logging.basicConfig(level=logging.INFO) for (m, _, _) in metadata_tuples: print(api.output_yaml(m, args.file))
def execute(args, print_results=True): p, args = parse_args(args) config = get_or_merge_config(None, **args.__dict__) variants = get_package_variants(args.recipe, config, variants=args.variants) set_language_env_vars(variants) channel_urls = args.__dict__.get('channel') or args.__dict__.get( 'channels') or () config.channel_urls = [] for url in channel_urls: # allow people to specify relative or absolute paths to local channels # These channels still must follow conda rules - they must have the # appropriate platform-specific subdir (e.g. win-64) if os.path.isdir(url): if not os.path.isabs(url): url = os.path.normpath( os.path.abspath(os.path.join(os.getcwd(), url))) url = url_path(url) config.channel_urls.append(url) config.override_channels = args.override_channels if args.output: config.verbose = False config.debug = False metadata_tuples = api.render(args.recipe, config=config, no_download_source=args.no_source, variants=args.variants) if print_results: if args.output: with LoggingContext(logging.CRITICAL + 1): paths = api.get_output_file_paths(metadata_tuples, config=config) print('\n'.join(sorted(paths))) else: logging.basicConfig(level=logging.INFO) for (m, _, _) in metadata_tuples: print("--------------") print("Hash contents:") print("--------------") pprint(m.get_hash_contents()) print("----------") print("meta.yaml:") print("----------") print(api.output_yaml(m, args.file, suppress_outputs=True)) else: return metadata_tuples
def execute(args, print_results=True): p, args = parse_args(args) config = get_or_merge_config(None, **args.__dict__) variants = get_package_variants(args.recipe, config, variants=args.variants) set_language_env_vars(variants) config.channel_urls = get_channel_urls(args.__dict__) config.override_channels = args.override_channels if args.output: config.verbose = False config.debug = False metadata_tuples = api.render(args.recipe, config=config, no_download_source=args.no_source, variants=args.variants) if args.file and len(metadata_tuples) > 1: log.warning( "Multiple variants rendered. " "Only one will be written to the file you specified ({}).".format( args.file)) if print_results: if args.output: with LoggingContext(logging.CRITICAL + 1): paths = api.get_output_file_paths(metadata_tuples, config=config) print('\n'.join(sorted(paths))) if args.file: m = metadata_tuples[-1][0] api.output_yaml(m, args.file, suppress_outputs=True) else: logging.basicConfig(level=logging.INFO) for (m, _, _) in metadata_tuples: print("--------------") print("Hash contents:") print("--------------") pprint(m.get_hash_contents()) print("----------") print("meta.yaml:") print("----------") print(api.output_yaml(m, args.file, suppress_outputs=True)) else: return metadata_tuples
def build(m, bld_bat, stats): with path_prepended(m.config.build_prefix): with path_prepended(m.config.host_prefix): env = environ.get_dict(m=m) env["CONDA_BUILD_STATE"] = "BUILD" # hard-code this because we never want pip's build isolation # https://github.com/conda/conda-build/pull/2972#discussion_r198290241 # # Note that pip env "NO" variables are inverted logic. # PIP_NO_BUILD_ISOLATION=False means don't use build isolation. # env["PIP_NO_BUILD_ISOLATION"] = False # some other env vars to have pip ignore dependencies. # we supply them ourselves instead. # See note above about inverted logic on "NO" variables env["PIP_NO_DEPENDENCIES"] = False env["PIP_IGNORE_INSTALLED"] = True # disable use of pip's cache directory. # See note above about inverted logic on "NO" variables env["PIP_NO_CACHE_DIR"] = False # set variables like CONDA_PY in the test environment env.update(set_language_env_vars(m.config.variant)) for name in 'BIN', 'INC', 'LIB': path = env['LIBRARY_' + name] if not isdir(path): os.makedirs(path) src_dir = m.config.work_dir if os.path.isfile(bld_bat): with open(bld_bat) as fi: data = fi.read() with open(join(src_dir, 'bld.bat'), 'w') as fo: # more debuggable with echo on fo.write('@echo on\n') for key, value in env.items(): if value: fo.write('set "{key}={value}"\n'.format(key=key, value=value)) if not m.uses_new_style_compiler_activation: fo.write( msvc_env_cmd(bits=m.config.host_arch, config=m.config, override=m.get_value('build/msvc_compiler', None))) # Reset echo on, because MSVC scripts might have turned it off fo.write('@echo on\n') fo.write('set "INCLUDE={};%INCLUDE%"\n'.format(env["LIBRARY_INC"])) fo.write('set "LIB={};%LIB%"\n'.format(env["LIBRARY_LIB"])) if m.config.activate and m.name() != 'conda': _write_bat_activation_text(fo, m) fo.write("REM ===== end generated header =====\n") fo.write(data) cmd = ['cmd.exe', '/c', 'bld.bat'] check_call_env(cmd, cwd=src_dir, stats=stats) fix_staged_scripts(join(m.config.host_prefix, 'Scripts'), config=m.config)
def build(m, bld_bat, stats): with path_prepended(m.config.build_prefix): with path_prepended(m.config.host_prefix): env = environ.get_dict(m=m) env["CONDA_BUILD_STATE"] = "BUILD" # hard-code this because we never want pip's build isolation # https://github.com/conda/conda-build/pull/2972#discussion_r198290241 # # Note that pip env "NO" variables are inverted logic. # PIP_NO_BUILD_ISOLATION=False means don't use build isolation. # env["PIP_NO_BUILD_ISOLATION"] = False # some other env vars to have pip ignore dependencies. # we supply them ourselves instead. # See note above about inverted logic on "NO" variables env["PIP_NO_DEPENDENCIES"] = False env["PIP_IGNORE_INSTALLED"] = True # pip's cache directory (PIP_NO_CACHE_DIR) should not be # disabled as this results in .egg-info rather than # .dist-info directories being created, see gh-3094 # set PIP_CACHE_DIR to a path in the work dir that does not exist. env['PIP_CACHE_DIR'] = m.config.pip_cache_dir # set variables like CONDA_PY in the test environment env.update(set_language_env_vars(m.config.variant)) for name in 'BIN', 'INC', 'LIB': path = env['LIBRARY_' + name] if not isdir(path): os.makedirs(path) src_dir = m.config.work_dir if os.path.isfile(bld_bat): with open(bld_bat) as fi: data = fi.read() with open(join(src_dir, 'bld.bat'), 'w') as fo: # more debuggable with echo on fo.write('@echo on\n') for key, value in env.items(): if value: fo.write('set "{key}={value}"\n'.format(key=key, value=value)) if not m.uses_new_style_compiler_activation: fo.write(msvc_env_cmd(bits=m.config.host_arch, config=m.config, override=m.get_value('build/msvc_compiler', None))) # Reset echo on, because MSVC scripts might have turned it off fo.write('@echo on\n') fo.write('set "INCLUDE={};%INCLUDE%"\n'.format(env["LIBRARY_INC"])) fo.write('set "LIB={};%LIB%"\n'.format(env["LIBRARY_LIB"])) if m.config.activate and m.name() != 'conda': _write_bat_activation_text(fo, m) fo.write("REM ===== end generated header =====\n") fo.write(data) cmd = ['cmd.exe', '/c', 'bld.bat'] check_call_env(cmd, cwd=src_dir, stats=stats) fix_staged_scripts(join(m.config.host_prefix, 'Scripts'), config=m.config)
def execute(args): p, args = parse_args(args) config = get_or_merge_config(None, **args.__dict__) variants = get_package_variants(args.recipe, config) set_language_env_vars(variants) metadata_tuples = api.render(args.recipe, config=config, no_download_source=args.no_source) if args.output: with LoggingContext(logging.CRITICAL + 1): paths = api.get_output_file_path(metadata_tuples) print('\n'.join(paths)) else: logging.basicConfig(level=logging.INFO) for (m, _, _) in metadata_tuples: print(api.output_yaml(m, args.file))
def write_test_scripts( metadata, env_vars, py_files, pl_files, lua_files, r_files, shell_files, trace="" ): if not metadata.config.activate or metadata.name() == "conda": # prepend bin (or Scripts) directory env_vars = utils.prepend_bin_path( env_vars, metadata.config.test_prefix, prepend_prefix=True ) if utils.on_win: env_vars["PATH"] = ( metadata.config.test_prefix + os.pathsep + env_vars["PATH"] ) # set variables like CONDA_PY in the test environment env_vars.update(set_language_env_vars(metadata.config.variant)) # Python 2 Windows requires that envs variables be string, not unicode env_vars = {str(key): str(value) for key, value in env_vars.items()} suffix = "bat" if utils.on_win else "sh" test_env_script = join( metadata.config.test_dir, "conda_test_env_vars.{suffix}".format(suffix=suffix) ) test_run_script = join( metadata.config.test_dir, "conda_test_runner.{suffix}".format(suffix=suffix) ) with open(test_env_script, "w") as tf: if not utils.on_win: tf.write("set {trace}-e\n".format(trace=trace)) if metadata.config.activate and not metadata.name() == "conda": ext = ".bat" if utils.on_win else "" tf.write( '{source} "{conda_root}activate{ext}" "{test_env}"\n'.format( conda_root=utils.root_script_dir + os.path.sep, source="call" if utils.on_win else "source", ext=ext, test_env=metadata.config.test_prefix, ) ) if utils.on_win: tf.write("IF %ERRORLEVEL% NEQ 0 exit /B 1\n") # In-case people source this, it's essential errors are not fatal in an interactive shell. if not utils.on_win: tf.write("set +e\n") _write_test_run_script( metadata, test_run_script, test_env_script, py_files, pl_files, lua_files, r_files, shell_files, trace, ) return test_run_script, test_env_script
def execute(args): p, args = parse_args(args) config = get_or_merge_config(None, **args.__dict__) variants = get_package_variants(args.recipe, config) set_language_env_vars(variants) metadata_tuples = api.render(args.recipe, config=config, no_download_source=args.no_source) if args.output: with LoggingContext(logging.CRITICAL + 1): paths = api.get_output_file_paths(metadata_tuples) print('\n'.join(sorted(paths))) else: logging.basicConfig(level=logging.INFO) for (m, _, _) in metadata_tuples: print(api.output_yaml(m, args.file))
def build(m, bld_bat, stats, provision_only=False): with path_prepended(m.config.host_prefix): with path_prepended(m.config.build_prefix): env = environ.get_dict(m=m) env["CONDA_BUILD_STATE"] = "BUILD" # hard-code this because we never want pip's build isolation # https://github.com/conda/conda-build/pull/2972#discussion_r198290241 # # Note that pip env "NO" variables are inverted logic. # PIP_NO_BUILD_ISOLATION=False means don't use build isolation. # env["PIP_NO_BUILD_ISOLATION"] = 'False' # some other env vars to have pip ignore dependencies. # we supply them ourselves instead. # See note above about inverted logic on "NO" variables env["PIP_NO_DEPENDENCIES"] = True env["PIP_IGNORE_INSTALLED"] = True # pip's cache directory (PIP_NO_CACHE_DIR) should not be # disabled as this results in .egg-info rather than # .dist-info directories being created, see gh-3094 # set PIP_CACHE_DIR to a path in the work dir that does not exist. env['PIP_CACHE_DIR'] = m.config.pip_cache_dir # tell pip to not get anything from PyPI, please. We have everything we need # locally, and if we don't, it's a problem. env["PIP_NO_INDEX"] = True # set variables like CONDA_PY in the test environment env.update(set_language_env_vars(m.config.variant)) for name in 'BIN', 'INC', 'LIB': path = env['LIBRARY_' + name] if not isdir(path): os.makedirs(path) work_script, env_script = write_build_scripts(m, env, bld_bat) if not provision_only and os.path.isfile(work_script): cmd = ['cmd.exe', '/c', os.path.basename(work_script)] # rewrite long paths in stdout back to their env variables if m.config.debug: rewrite_env = None else: rewrite_env = { k: env[k] for k in ['PREFIX', 'BUILD_PREFIX', 'SRC_DIR'] if k in env } print("Rewriting env in output: %s" % pprint.pformat(rewrite_env)) check_call_env(cmd, cwd=m.config.work_dir, stats=stats, rewrite_stdout_env=rewrite_env) fix_staged_scripts(join(m.config.host_prefix, 'Scripts'), config=m.config)
def build(m, bld_bat, stats, provision_only=False): with path_prepended(m.config.host_prefix): with path_prepended(m.config.build_prefix): env = environ.get_dict(m=m) env["CONDA_BUILD_STATE"] = "BUILD" # hard-code this because we never want pip's build isolation # https://github.com/conda/conda-build/pull/2972#discussion_r198290241 # # Note that pip env "NO" variables are inverted logic. # PIP_NO_BUILD_ISOLATION=False means don't use build isolation. # env["PIP_NO_BUILD_ISOLATION"] = 'False' # some other env vars to have pip ignore dependencies. # we supply them ourselves instead. # See note above about inverted logic on "NO" variables env["PIP_NO_DEPENDENCIES"] = True env["PIP_IGNORE_INSTALLED"] = True # pip's cache directory (PIP_NO_CACHE_DIR) should not be # disabled as this results in .egg-info rather than # .dist-info directories being created, see gh-3094 # set PIP_CACHE_DIR to a path in the work dir that does not exist. env['PIP_CACHE_DIR'] = m.config.pip_cache_dir # tell pip to not get anything from PyPI, please. We have everything we need # locally, and if we don't, it's a problem. env["PIP_NO_INDEX"] = True # set variables like CONDA_PY in the test environment env.update(set_language_env_vars(m.config.variant)) for name in 'BIN', 'INC', 'LIB': path = env['LIBRARY_' + name] if not isdir(path): os.makedirs(path) work_script, env_script = write_build_scripts(m, env, bld_bat) if not provision_only and os.path.isfile(work_script): cmd = ['cmd.exe', '/d', '/c', os.path.basename(work_script)] # rewrite long paths in stdout back to their env variables if m.config.debug: rewrite_env = None else: rewrite_env = { k: env[k] for k in ['PREFIX', 'BUILD_PREFIX', 'SRC_DIR'] if k in env } print("Rewriting env in output: %s" % pprint.pformat(rewrite_env)) check_call_env(cmd, cwd=m.config.work_dir, stats=stats, rewrite_stdout_env=rewrite_env) fix_staged_scripts(join(m.config.host_prefix, 'Scripts'), config=m.config)
def execute(args, print_results=True): p, args = parse_args(args) config = get_or_merge_config(None, **args.__dict__) variants = get_package_variants(args.recipe, config, variants=args.variants) set_language_env_vars(variants) config.channel_urls = get_channel_urls(args.__dict__) config.override_channels = args.override_channels if args.output: config.verbose = False config.debug = False metadata_tuples = api.render(args.recipe, config=config, no_download_source=args.no_source, variants=args.variants) if print_results: if args.output: with LoggingContext(logging.CRITICAL + 1): paths = api.get_output_file_paths(metadata_tuples, config=config) print('\n'.join(sorted(paths))) else: logging.basicConfig(level=logging.INFO) for (m, _, _) in metadata_tuples: print("--------------") print("Hash contents:") print("--------------") pprint(m.get_hash_contents()) print("----------") print("meta.yaml:") print("----------") print(api.output_yaml(m, args.file, suppress_outputs=True)) else: return metadata_tuples
def build(m, bld_bat, stats): with path_prepended(m.config.build_prefix): with path_prepended(m.config.host_prefix): env = environ.get_dict(config=m.config, m=m) env["CONDA_BUILD_STATE"] = "BUILD" # set variables like CONDA_PY in the test environment env.update(set_language_env_vars(m.config.variant)) for name in 'BIN', 'INC', 'LIB': path = env['LIBRARY_' + name] if not isdir(path): os.makedirs(path) src_dir = m.config.work_dir if os.path.isfile(bld_bat): with open(bld_bat) as fi: data = fi.read() with open(join(src_dir, 'bld.bat'), 'w') as fo: # more debuggable with echo on fo.write('@echo on\n') for key, value in env.items(): if value: fo.write('set "{key}={value}"\n'.format(key=key, value=value)) if not m.uses_new_style_compiler_activation: fo.write( msvc_env_cmd(bits=m.config.host_arch, config=m.config, override=m.get_value('build/msvc_compiler', None))) # Reset echo on, because MSVC scripts might have turned it off fo.write('@echo on\n') fo.write('set "INCLUDE={};%INCLUDE%"\n'.format(env["LIBRARY_INC"])) fo.write('set "LIB={};%LIB%"\n'.format(env["LIBRARY_LIB"])) if m.config.activate and m.name() != 'conda': _write_bat_activation_text(fo, m) fo.write("REM ===== end generated header =====\n") fo.write(data) cmd = ['cmd.exe', '/c', 'bld.bat'] check_call_env(cmd, cwd=src_dir, stats=stats) fix_staged_scripts(join(m.config.host_prefix, 'Scripts'), config=m.config)
def build(m, bld_bat, stats): with path_prepended(m.config.build_prefix): with path_prepended(m.config.host_prefix): env = environ.get_dict(config=m.config, m=m) env["CONDA_BUILD_STATE"] = "BUILD" # set variables like CONDA_PY in the test environment env.update(set_language_env_vars(m.config.variant)) for name in 'BIN', 'INC', 'LIB': path = env['LIBRARY_' + name] if not isdir(path): os.makedirs(path) src_dir = m.config.work_dir if os.path.isfile(bld_bat): with open(bld_bat) as fi: data = fi.read() with open(join(src_dir, 'bld.bat'), 'w') as fo: # more debuggable with echo on fo.write('@echo on\n') for key, value in env.items(): if value: fo.write('set "{key}={value}"\n'.format(key=key, value=value)) if not m.uses_new_style_compiler_activation: fo.write(msvc_env_cmd(bits=m.config.host_arch, config=m.config, override=m.get_value('build/msvc_compiler', None))) # Reset echo on, because MSVC scripts might have turned it off fo.write('@echo on\n') fo.write('set "INCLUDE={};%INCLUDE%"\n'.format(env["LIBRARY_INC"])) fo.write('set "LIB={};%LIB%"\n'.format(env["LIBRARY_LIB"])) if m.config.activate and m.name() != 'conda': _write_bat_activation_text(fo, m) fo.write("REM ===== end generated header =====\n") fo.write(data) cmd = ['cmd.exe', '/c', 'bld.bat'] check_call_env(cmd, cwd=src_dir, stats=stats) fix_staged_scripts(join(m.config.host_prefix, 'Scripts'), config=m.config)
def build(m, bld_bat): with path_prepended(m.config.build_prefix): env = environ.get_dict(config=m.config, m=m) env["CONDA_BUILD_STATE"] = "BUILD" # set variables like CONDA_PY in the test environment env.update(set_language_env_vars(m.config.variant)) for name in 'BIN', 'INC', 'LIB': path = env['LIBRARY_' + name] if not isdir(path): os.makedirs(path) src_dir = m.config.work_dir if os.path.isfile(bld_bat): with open(bld_bat) as fi: data = fi.read() with open(join(src_dir, 'bld.bat'), 'w') as fo: # more debuggable with echo on fo.write('@echo on\n') for key, value in env.items(): if value: fo.write('set "{key}={value}"\n'.format(key=key, value=value)) if not m.uses_new_style_compiler_activation: fo.write(msvc_env_cmd(bits=bits, config=m.config, override=m.get_value('build/msvc_compiler', None))) # Reset echo on, because MSVC scripts might have turned it off fo.write('@echo on\n') fo.write('set "INCLUDE={};%INCLUDE%"\n'.format(env["LIBRARY_INC"])) fo.write('set "LIB={};%LIB%"\n'.format(env["LIBRARY_LIB"])) if m.config.activate: fo.write('call "{conda_root}\\activate.bat" "{prefix}"\n'.format( conda_root=root_script_dir, prefix=m.config.build_prefix)) if m.is_cross: # HACK: we need both build and host envs "active" - i.e. on PATH, # and with their activate.d scripts sourced. Conda only # lets us activate one, though. This is a # vile hack to trick conda into "stacking" # two environments. # # Net effect: binaries come from host first, then build # # Conda 4.4 may break this by reworking the activate scripts. # ^^ shouldn't be true # In conda 4.4, export CONDA_MAX_SHLVL=2 to stack envs to two # levels deep. # conda 4.4 does require that a conda-meta/history file # exists to identify a valid conda environment history_file = join(m.config.host_prefix, 'conda-meta', 'history') if not isfile(history_file): if not isdir(dirname(history_file)): os.makedirs(dirname(history_file)) open(history_file, 'a').close() # removing this placeholder should make conda double-activate with conda 4.3 fo.write('set "PATH=%PATH:CONDA_PATH_PLACEHOLDER;=%"\n') fo.write('set CONDA_MAX_SHLVL=2\n') fo.write('call "{conda_root}\\activate.bat" "{prefix}"\n'.format( conda_root=root_script_dir, prefix=m.config.host_prefix)) fo.write("REM ===== end generated header =====\n") fo.write(data) cmd = ['cmd.exe', '/c', 'bld.bat'] check_call_env(cmd, cwd=src_dir) fix_staged_scripts(join(m.config.build_prefix, 'Scripts'))