def execute(args): parser, args = parse_args(args) config = Config(**args.__dict__) build.check_external() # change globals in build module, see comment there as well 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 config.verbose = not args.quiet or args.debug if 'purge' in args.recipe: build.clean_build(config) return if 'purge-all' in args.recipe: build.clean_build(config) config.clean_pkgs() return action = None if args.output: action = output_action config.verbose = False config.quiet = True config.debug = False elif args.test: action = test_action elif args.source: action = source_action elif args.check: action = check_action if action: outputs = [action(recipe, config) for recipe in args.recipe] else: outputs = api.build(args.recipe, post=args.post, build_only=args.build_only, notest=args.notest, already_built=None, config=config, noverify=args.no_verify) if not args.output and len(utils.get_build_folders(config.croot)) > 0: build.print_build_intermediate_warning(config) return outputs
def execute(args): parser, args = parse_args(args) config = Config(**args.__dict__) build.check_external() # change globals in build module, see comment there as well config.channel_urls = args.channel or () config.override_channels = args.override_channels config.verbose = not args.quiet or args.debug if 'purge' in args.recipe: build.clean_build(config) return if 'purge-all' in args.recipe: build.clean_build(config) config.clean_pkgs() return set_language_env_vars(args, parser, config=config, execute=execute) action = None if args.output: action = output_action logging.basicConfig(level=logging.ERROR) config.verbose = False config.quiet = True elif args.test: action = test_action elif args.source: action = source_action elif args.check: action = check_action if action: for recipe in args.recipe: recipe_dir, need_cleanup = get_recipe_abspath(recipe) if not isdir(recipe_dir): sys.exit("Error: no such directory: %s" % recipe_dir) # this fully renders any jinja templating, throwing an error if any data is missing m, _, _ = render_recipe(recipe_dir, no_download_source=False, config=config) action(m, config) if need_cleanup: rm_rf(recipe_dir) else: api.build(args.recipe, post=args.post, build_only=args.build_only, notest=args.notest, keep_old_work=args.keep_old_work, already_built=None, config=config) if not args.output and len(build.get_build_folders(config.croot)) > 0: build.print_build_intermediate_warning(config)
def build_conda_pack(base_path, tmp): # First build the hexrdgui package recipe_path = str(base_path / '..' / 'conda.recipe') config = Config() config.channel = ['cjh1', 'conda-forge'] config.channel_urls = ['cjh1', 'conda-forge'] logger.info('Building hexrd conda package.') CondaBuild.build(recipe_path, config=config) logger.info('Creating new conda environment.') # Now create a new environment to install the package into env_prefix = str(tmp / package_env_name) Conda.run_command(Conda.Commands.CREATE, '--prefix', env_prefix, 'python=3.7') logger.info('Installing hexrdgui into new environment.') # Install hexrdgui into new environment params = [ Conda.Commands.INSTALL, '--prefix', env_prefix, '--channel', 'cjh1', '--channel', 'conda-forge', '--use-local', 'hexrdgui' ] if platform.system() == 'Darwin': params.append('python.app=2') Conda.run_command(*params) logger.info('Generating tar from environment using conda-pack.') # Now use conda-pack to great relocatable tar tar_path = str(tmp / 'hexrdgui.tar') CondaPack.pack(prefix=env_prefix, output=tar_path, format='tar') return tar_path
def execute(args): parser, args = parse_args(args) config = Config(**args.__dict__) build.check_external() # change globals in build module, see comment there as well channel_urls = args.channel 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 config.verbose = not args.quiet or args.debug if 'purge' in args.recipe: build.clean_build(config) return if 'purge-all' in args.recipe: build.clean_build(config) config.clean_pkgs() return set_language_env_vars(args, parser, config=config, execute=execute) action = None if args.output: action = output_action logging.basicConfig(level=logging.ERROR) config.verbose = False config.quiet = True elif args.test: action = test_action elif args.source: action = source_action elif args.check: action = check_action if action: for recipe in args.recipe: action(recipe, config) outputs = [] else: outputs = api.build(args.recipe, post=args.post, build_only=args.build_only, notest=args.notest, already_built=None, config=config, noverify=args.no_verify) if not args.output and len(utils.get_build_folders(config.croot)) > 0: build.print_build_intermediate_warning(config) return outputs
def execute(args): parser, args = parse_args(args) config = Config(**args.__dict__) build.check_external() # change globals in build module, see comment there as well config.channel_urls = args.channel or () config.override_channels = args.override_channels config.verbose = not args.quiet or args.debug if 'purge' in args.recipe: build.clean_build(config) return if 'purge-all' in args.recipe: build.clean_build(config) config.clean_pkgs() return if on_win: delete_trash(None) set_language_env_vars(args, parser, config=config, execute=execute) action = None if args.output: action = output_action logging.basicConfig(level=logging.ERROR) config.verbose = False config.quiet = True elif args.test: action = test_action elif args.source: action = source_action elif args.check: action = check_action if action: for recipe in args.recipe: recipe_dir, need_cleanup = get_recipe_abspath(recipe) if not isdir(recipe_dir): sys.exit("Error: no such directory: %s" % recipe_dir) # this fully renders any jinja templating, throwing an error if any data is missing m, _, _ = render_recipe(recipe_dir, no_download_source=False, config=config) action(m, config) if need_cleanup: rm_rf(recipe_dir) else: api.build(args.recipe, post=args.post, build_only=args.build_only, notest=args.notest, keep_old_work=args.keep_old_work, already_built=None, config=config) if not args.output and len(build.get_build_folders(config.croot)) > 0: build.print_build_intermediate_warning(config)
def build_conda_pack(base_path, tmp, hexrd_package_channel, hexrdgui_output_folder): # First build the hexrdgui package recipe_path = str(base_path / '..' / 'conda.recipe') config = Config() config.channel = ['cjh1', 'anaconda', 'conda-forge'] config.channel_urls = ['cjh1', 'anaconda', 'conda-forge'] if hexrdgui_output_folder is not None: config.output_folder = hexrdgui_output_folder if hexrd_package_channel is not None: config.channel.insert(0, 'hexrd-channel') config.channel_urls.insert(0, hexrd_package_channel) config.CONDA_PY = '38' logger.info('Building hexrdgui conda package.') CondaBuild.build(recipe_path, config=config) logger.info('Creating new conda environment.') # Now create a new environment to install the package into env_prefix = str(tmp / package_env_name) channels = ['--channel', 'anaconda', '--channel', 'conda-forge'] # For the mac we need to use our own version of Python built with the # latest SDK. See https://github.com/HEXRD/hexrdgui/issues/505 for # more details. So we add the HEXRD channel that has our Python package. if platform.system() == 'Darwin': channels = ['--channel', 'HEXRD'] + channels Conda.run_command(Conda.Commands.CREATE, '--prefix', env_prefix, *channels, 'python=3.8.4') hexrdgui_output_folder_uri = Path( hexrdgui_output_folder).absolute().as_uri() logger.info('Installing hexrdgui into new environment.') # Install hexrdgui into new environment params = [ Conda.Commands.INSTALL, '--prefix', env_prefix, '--channel', hexrdgui_output_folder_uri, '--channel', hexrd_package_channel, '--channel', 'cjh1', '--channel', 'anaconda', '--channel', 'conda-forge', 'hexrdgui' ] Conda.run_command(*params) logger.info('Generating tar from environment using conda-pack.') # Now use conda-pack to create relocatable archive archive_path = str(tmp / ('hexrdgui.%s' % archive_format)) CondaPack.pack(prefix=env_prefix, output=archive_path, format=archive_format) return archive_path
def build_conda_pack(base_path, tmp, hexrd_package_channel, hexrdgui_output_folder): # First build the hexrdgui package recipe_path = str(base_path / '..' / 'conda.recipe') config = Config() config.channel = ['cjh1', 'anaconda', 'conda-forge'] config.channel_urls = ['cjh1', 'anaconda', 'conda-forge'] if hexrdgui_output_folder is not None: config.output_folder = hexrdgui_output_folder if hexrd_package_channel is not None: config.channel.insert(0, 'hexrd-channel') config.channel_urls.insert(0, hexrd_package_channel) config.CONDA_PY = '38' logger.info('Building hexrdgui conda package.') CondaBuild.build(recipe_path, config=config) logger.info('Creating new conda environment.') # Now create a new environment to install the package into env_prefix = str(tmp / package_env_name) Conda.run_command(Conda.Commands.CREATE, '--prefix', env_prefix, 'python=3.8') hexrdgui_output_folder_uri = Path( hexrdgui_output_folder).absolute().as_uri() logger.info('Installing hexrdgui into new environment.') # Install hexrdgui into new environment params = [ Conda.Commands.INSTALL, '--prefix', env_prefix, '--channel', hexrdgui_output_folder_uri, '--channel', hexrd_package_channel, '--channel', 'cjh1', '--channel', 'anaconda', '--channel', 'conda-forge', 'hexrdgui' ] Conda.run_command(*params) logger.info('Generating tar from environment using conda-pack.') # Now use conda-pack to create relocatable archive archive_path = str(tmp / ('hexrdgui.%s' % archive_format)) CondaPack.pack(prefix=env_prefix, output=archive_path, format=archive_format) return archive_path
def execute(args): parser, args = parse_args(args) config = Config(**args.__dict__) build.check_external() # change globals in build module, see comment there as well config.channel_urls = args.channel or () config.override_channels = args.override_channels config.verbose = not args.quiet or args.debug if 'purge' in args.recipe: build.clean_build(config) return if 'purge-all' in args.recipe: build.clean_build(config) config.clean_pkgs() return set_language_env_vars(args, parser, config=config, execute=execute) action = None if args.output: action = output_action logging.basicConfig(level=logging.ERROR) config.verbose = False config.quiet = True elif args.test: action = test_action elif args.source: action = source_action elif args.check: action = check_action if action: for recipe in args.recipe: action(recipe, config) else: api.build(args.recipe, post=args.post, build_only=args.build_only, notest=args.notest, keep_old_work=args.keep_old_work, already_built=None, config=config, noverify=args.no_verify) if not args.output and len(build.get_build_folders(config.croot)) > 0: build.print_build_intermediate_warning(config)
def prepare(**kwargs): """ Prepare and configure the stage for mambabuild to run. The given **kwargs are passed to conda-build's Config which is the value returned by this function. """ config = Config(**kwargs) config.channel_urls = get_channel_urls(kwargs) init_api_context() config.output_folder = os.path.abspath(config.output_folder) if not os.path.exists(config.output_folder): mkdir_p(config.output_folder) print(f"Updating build index: {(config.output_folder)}\n") update_index(config.output_folder, verbose=config.debug, threads=1) return config
def execute(args): _parser, args = parse_args(args) config = Config(**args.__dict__) build.check_external() # change globals in build module, see comment there as well 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 config.verbose = not args.quiet or args.debug if 'purge' in args.recipe: build.clean_build(config) return if 'purge-all' in args.recipe: build.clean_build(config) config.clean_pkgs() return action = None outputs = None if args.output: action = output_action config.verbose = False config.quiet = True config.debug = False elif args.test: action = test_action elif args.source: action = source_action elif args.check: action = check_action if action == test_action: failed_recipes = [] recipes = [ item for sublist in [ glob(os.path.abspath(recipe)) if '*' in recipe else [recipe] for recipe in args.recipe ] for item in sublist ] for recipe in recipes: try: action(recipe, config) except: if not args.keep_going: raise else: failed_recipes.append(recipe) continue if failed_recipes: print("Failed recipes:") for recipe in failed_recipes: print(" - %s" % recipe) sys.exit(len(failed_recipes)) else: print("All tests passed") outputs = [] elif action: outputs = [action(recipe, config) for recipe in args.recipe] else: outputs = api.build(args.recipe, post=args.post, build_only=args.build_only, notest=args.notest, already_built=None, config=config, verify=args.verify, variants=args.variants) if not args.output and len(utils.get_build_folders(config.croot)) > 0: build.print_build_intermediate_warning(config) return outputs
def execute(args): _parser, args = parse_args(args) config = Config(**args.__dict__) build.check_external() # change globals in build module, see comment there as well config.channel_urls = get_channel_urls(args.__dict__) config.override_channels = args.override_channels config.verbose = not args.quiet or args.debug if 'purge' in args.recipe: build.clean_build(config) return if 'purge-all' in args.recipe: build.clean_build(config) config.clean_pkgs() return action = None outputs = None if args.output: action = output_action config.verbose = False config.quiet = True config.debug = False elif args.test: action = test_action elif args.source: action = source_action elif args.check: action = check_action if action == test_action: failed_recipes = [] recipes = [item for sublist in [glob(os.path.abspath(recipe)) if '*' in recipe else [recipe] for recipe in args.recipe] for item in sublist] for recipe in recipes: try: action(recipe, config) except: if not args.keep_going: raise else: failed_recipes.append(recipe) continue if failed_recipes: print("Failed recipes:") for recipe in failed_recipes: print(" - %s" % recipe) sys.exit(len(failed_recipes)) else: print("All tests passed") outputs = [] elif action: outputs = [action(recipe, config) for recipe in args.recipe] else: outputs = api.build(args.recipe, post=args.post, test_run_post=args.test_run_post, build_only=args.build_only, notest=args.notest, already_built=None, config=config, verify=args.verify, variants=args.variants) if not args.output and len(utils.get_build_folders(config.croot)) > 0: build.print_build_intermediate_warning(config) return outputs
def execute(args): parser, args = parse_args(args) config = Config(**args.__dict__) build.check_external() # change globals in build module, see comment there as well 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 config.verbose = not args.quiet or args.debug if 'purge' in args.recipe: build.clean_build(config) return if 'purge-all' in args.recipe: build.clean_build(config) config.clean_pkgs() return action = None outputs = None if args.output: action = output_action config.verbose = False config.quiet = True config.debug = False elif args.test: action = test_action elif args.source: action = source_action elif args.check: action = check_action if action == test_action: failed_recipes = [] recipes = [item for sublist in [glob(os.path.abspath(recipe)) if '*' in recipe else [recipe] for recipe in args.recipe] for item in sublist] for recipe in recipes: try: action(recipe, config) except: if not args.keep_going: raise else: failed_recipes.append(recipe) continue if failed_recipes: print("Failed recipes:") for recipe in failed_recipes: print(" - %s" % recipe) sys.exit(len(failed_recipes)) else: print("All tests passed") outputs = [] elif action: outputs = [action(recipe, config) for recipe in args.recipe] else: outputs = api.build(args.recipe, post=args.post, build_only=args.build_only, notest=args.notest, already_built=None, config=config, verify=args.verify, variants=args.variants) if not args.output and len(utils.get_build_folders(config.croot)) > 0: build.print_build_intermediate_warning(config) return outputs
def build_conda_pack(base_path, tmp, hexrd_package_channel, hexrdgui_output_folder): # First build the hexrdgui package recipe_path = str(base_path / '..' / 'conda.recipe') config = Config() config.channel = ['cjh1', 'anaconda', 'conda-forge'] config.channel_urls = ['cjh1', 'anaconda', 'conda-forge'] if hexrdgui_output_folder is not None: config.output_folder = hexrdgui_output_folder if hexrd_package_channel is not None: config.channel.insert(0, 'hexrd-channel') config.channel_urls.insert(0, hexrd_package_channel) # Determine the latest hexrd version in the hexrd_package_channel # (release or pre-release), and force that hexrd version to be used. params = [ Conda.Commands.SEARCH, '--channel', hexrd_package_channel, '--json', 'hexrd', ] output = Conda.run_command(*params) results = json.loads(output[0]) hexrd_version = results['hexrd'][-1]['version'] config.variant['hexrd_version'] = hexrd_version config.CONDA_PY = '38' logger.info('Building hexrdgui conda package.') CondaBuild.build(recipe_path, config=config) logger.info('Creating new conda environment.') # Now create a new environment to install the package into env_prefix = str(tmp / package_env_name) channels = ['--channel', 'anaconda', '--channel', 'conda-forge'] # For the mac we need to use our own version of Python built with the # latest SDK. See https://github.com/HEXRD/hexrdgui/issues/505 for # more details. So we add the HEXRD channel that has our Python package. if platform.system() == 'Darwin': channels = ['--channel', 'HEXRD'] + channels Conda.run_command(Conda.Commands.CREATE, '--prefix', env_prefix, *channels, 'python=3.8.4') hexrdgui_output_folder_uri = Path( hexrdgui_output_folder).absolute().as_uri() logger.info('Installing hexrdgui into new environment.') # Install hexrdgui into new environment params = [ Conda.Commands.INSTALL, '--prefix', env_prefix, '--channel', hexrdgui_output_folder_uri, '--channel', hexrd_package_channel, '--channel', 'cjh1', '--channel', 'anaconda', '--channel', 'conda-forge', f'hexrd=={hexrd_version}', 'hexrdgui' ] Conda.run_command(*params) # Override the libgfortran so we get a version that is # build with a SDK that is acceptable to the notary! if platform.system() == 'Darwin': params = [ Conda.Commands.INSTALL, '--prefix', env_prefix, '--channel', 'conda-forge', 'libgfortran=4.0.0' ] Conda.run_command(*params) logger.info('Generating tar from environment using conda-pack.') # Now use conda-pack to create relocatable archive archive_path = str(tmp / ('hexrdgui.%s' % archive_format)) CondaPack.pack(prefix=env_prefix, output=archive_path, format=archive_format) return archive_path