def create(cls, options, build_root=None, change_calculator=None): """ :param Options options: An `Options` instance to use. :param string build_root: The build root. :param ChangeCalculator change_calculator: A `ChangeCalculator` for calculating changes. """ # Determine the literal target roots. spec_roots = cls.parse_specs(options.target_specs, build_root) # Determine `Changed` arguments directly from options to support pre-`Subsystem` # initialization paths. changed_options = options.for_scope('changed') changed_request = ChangedRequest.from_options(changed_options) logger.debug('spec_roots are: %s', spec_roots) logger.debug('changed_request is: %s', changed_request) if change_calculator and changed_request.is_actionable(): if spec_roots: # We've been provided spec roots (e.g. `./pants list ::`) AND a changed request. Error out. raise InvalidSpecConstraint('cannot provide changed parameters and target specs!') # We've been provided no spec roots (e.g. `./pants list`) AND a changed request. Compute # alternate target roots. changed_addresses = change_calculator.changed_target_addresses(changed_request) logger.debug('changed addresses: %s', changed_addresses) return ChangedTargetRoots(tuple(changed_addresses)) return LiteralTargetRoots(spec_roots)
def create(cls, options=None, args=None, build_root=None, change_calculator=None): """ :param Options options: An `Options` instance to use, if available. :param string args: Raw cli args to use for parsing if an `Options` instance isn't available. :param string build_root: The build root. :param ChangeCalculator change_calculator: A `ChangeCalculator` for calculating changes. """ if not options: assert args is not None, 'must pass `args` if not passing `options`' options, _ = OptionsInitializer(OptionsBootstrapper(args=args)).setup(init_logging=False) # Determine the literal target roots. spec_roots = cls.parse_specs(options.target_specs, build_root) # Determine `Changed` arguments directly from options to support pre-`Subsystem` initialization paths. changed_options = options.for_scope('changed') changed_request = ChangedRequest.from_options(changed_options) logger.debug('args are: %s', args) logger.debug('spec_roots are: %s', spec_roots) logger.debug('changed_request is: %s', changed_request) if change_calculator and changed_request.is_actionable(): if spec_roots: # We've been provided spec roots (e.g. `./pants list ::`) AND a changed request. Error out. raise InvalidSpecConstraint('cannot provide changed parameters and target specs!') # We've been provided no spec roots (e.g. `./pants list`) AND a changed request. Compute # alternate target roots. changed_addresses = change_calculator.changed_target_addresses(changed_request) logger.debug('changed addresses: %s', changed_addresses) return ChangedTargetRoots(changed_addresses) return LiteralTargetRoots(spec_roots)
def create(cls, options=None, args=None, build_root=None, change_calculator=None): """ :param Options options: An `Options` instance to use, if available. :param string args: Raw cli args to use for parsing if an `Options` instance isn't available. :param string build_root: The build root. :param ChangeCalculator change_calculator: A `ChangeCalculator` for calculating changes. """ if not options: assert args is not None, 'must pass `args` if not passing `options`' options, _ = OptionsInitializer(OptionsBootstrapper(args=args)).setup(init_logging=False) # Determine the literal target roots. spec_roots = cls.parse_specs(options.target_specs, build_root) # Determine `Changed` arguments directly from options to support pre-`Subsystem` initialization paths. changed_options = options.for_scope('changed') changed_request = ChangedRequest.from_options(changed_options) logger.debug('args are: %s', args) logger.debug('spec_roots are: %s', spec_roots) logger.debug('changed_request is: %s', changed_request) if change_calculator and changed_request.is_actionable(): if spec_roots: # We've been provided spec roots (e.g. `./pants list ::`) AND a changed request. Error out. raise InvalidSpecConstraint('cannot provide changed parameters and target specs!') # We've been provided no spec roots (e.g. `./pants list`) AND a changed request. Compute # alternate target roots. changed_addresses = change_calculator.changed_target_addresses(changed_request) logger.debug('changed addresses: %s', changed_addresses) return ChangedTargetRoots(tuple(SingleAddress(a.spec_path, a.target_name) for a in changed_addresses)) return LiteralTargetRoots(spec_roots)
def create(cls, options, build_root=None, change_calculator=None): """ :param Options options: An `Options` instance to use. :param string build_root: The build root. :param ChangeCalculator change_calculator: A `ChangeCalculator` for calculating changes. """ # Determine the literal target roots. spec_roots = cls.parse_specs(options.target_specs, build_root) # Determine `Changed` arguments directly from options to support pre-`Subsystem` # initialization paths. changed_options = options.for_scope('changed') changed_request = ChangedRequest.from_options(changed_options) logger.debug('spec_roots are: %s', spec_roots) logger.debug('changed_request is: %s', changed_request) if change_calculator and changed_request.is_actionable(): if spec_roots: # We've been provided spec roots (e.g. `./pants list ::`) AND a changed request. Error out. raise InvalidSpecConstraint('cannot provide changed parameters and target specs!') # We've been provided no spec roots (e.g. `./pants list`) AND a changed request. Compute # alternate target roots. changed_addresses = change_calculator.changed_target_addresses(changed_request) logger.debug('changed addresses: %s', changed_addresses) return TargetRoots(tuple(SingleAddress(a.spec_path, a.target_name) for a in changed_addresses)) return TargetRoots(spec_roots)
def create(cls, options, session, symbol_table, build_root=None): """ :param Options options: An `Options` instance to use. :param session: The Scheduler session :param symbol_table: The symbol table :param string build_root: The build root. """ # Determine the literal target roots. spec_roots = cls.parse_specs(options.target_specs, build_root) # Determine `Changed` arguments directly from options to support pre-`Subsystem` # initialization paths. changed_options = options.for_scope('changed') changed_request = ChangedRequest.from_options(changed_options) # Determine the `--owner-of=` arguments provided from the global options owned_files = options.for_global_scope().owner_of logger.debug('spec_roots are: %s', spec_roots) logger.debug('changed_request is: %s', changed_request) logger.debug('owned_files are: %s', owned_files) scm = get_scm() change_calculator = ChangeCalculator(session, symbol_table, scm) if scm else None owner_calculator = OwnerCalculator( session, symbol_table) if owned_files else None targets_specified = sum(1 for item in (changed_request.is_actionable(), owned_files, spec_roots) if item) if targets_specified > 1: # We've been provided a more than one of: a change request, an owner request, or spec roots. raise InvalidSpecConstraint( 'Multiple target selection methods provided. Please use only one of ' '--changed-*, --owner-of, or target specs') if change_calculator and changed_request.is_actionable(): # We've been provided no spec roots (e.g. `./pants list`) AND a changed request. Compute # alternate target roots. changed_addresses = change_calculator.changed_target_addresses( changed_request) logger.debug('changed addresses: %s', changed_addresses) return TargetRoots( tuple( SingleAddress(a.spec_path, a.target_name) for a in changed_addresses)) if owner_calculator and owned_files: # We've been provided no spec roots (e.g. `./pants list`) AND a owner request. Compute # alternate target roots. owner_addresses = owner_calculator.owner_target_addresses( owned_files) logger.debug('owner addresses: %s', owner_addresses) return TargetRoots( tuple( SingleAddress(a.spec_path, a.target_name) for a in owner_addresses)) return TargetRoots(spec_roots)
def create(cls, options, session, symbol_table, build_root=None, exclude_patterns=None, tags=None): """ :param Options options: An `Options` instance to use. :param session: The Scheduler session :param symbol_table: The symbol table :param string build_root: The build root. """ # Determine the literal target roots. spec_roots = cls.parse_specs( target_specs=options.target_specs, build_root=build_root, exclude_patterns=exclude_patterns, tags=tags) # Determine `Changed` arguments directly from options to support pre-`Subsystem` # initialization paths. changed_options = options.for_scope('changed') changed_request = ChangedRequest.from_options(changed_options) # Determine the `--owner-of=` arguments provided from the global options owned_files = options.for_global_scope().owner_of logger.debug('spec_roots are: %s', spec_roots) logger.debug('changed_request is: %s', changed_request) logger.debug('owned_files are: %s', owned_files) scm = get_scm() change_calculator = ChangeCalculator(scheduler=session, symbol_table=symbol_table, scm=scm) if scm else None owner_calculator = OwnerCalculator(scheduler=session, symbol_table=symbol_table) if owned_files else None targets_specified = sum(1 for item in (changed_request.is_actionable(), owned_files, spec_roots) if item) if targets_specified > 1: # We've been provided a more than one of: a change request, an owner request, or spec roots. raise InvalidSpecConstraint( 'Multiple target selection methods provided. Please use only one of ' '--changed-*, --owner-of, or target specs' ) if change_calculator and changed_request.is_actionable(): # We've been provided no spec roots (e.g. `./pants list`) AND a changed request. Compute # alternate target roots. changed_addresses = change_calculator.changed_target_addresses(changed_request) logger.debug('changed addresses: %s', changed_addresses) dependencies = tuple(SingleAddress(a.spec_path, a.target_name) for a in changed_addresses) return TargetRoots([Specs(dependencies=dependencies, exclude_patterns=exclude_patterns, tags=tags)]) if owner_calculator and owned_files: # We've been provided no spec roots (e.g. `./pants list`) AND a owner request. Compute # alternate target roots. owner_addresses = owner_calculator.owner_target_addresses(owned_files) logger.debug('owner addresses: %s', owner_addresses) dependencies = tuple(SingleAddress(a.spec_path, a.target_name) for a in owner_addresses) return TargetRoots([Specs(dependencies=dependencies, exclude_patterns=exclude_patterns, tags=tags)]) return TargetRoots(spec_roots)
def create(cls, options, session, symbol_table, build_root=None, exclude_patterns=None, tags=None): """ :param Options options: An `Options` instance to use. :param session: The Scheduler session :param symbol_table: The symbol table :param string build_root: The build root. """ # Determine the literal target roots. spec_roots = cls.parse_specs(target_specs=options.target_specs, build_root=build_root, exclude_patterns=exclude_patterns, tags=tags) # Determine `Changed` arguments directly from options to support pre-`Subsystem` # initialization paths. changed_options = options.for_scope('changed') changed_request = ChangedRequest.from_options(changed_options) # Determine the `--owner-of=` arguments provided from the global options owned_files = options.for_global_scope().owner_of logger.debug('spec_roots are: %s', spec_roots) logger.debug('changed_request is: %s', changed_request) logger.debug('owned_files are: %s', owned_files) targets_specified = sum(1 for item in (changed_request.is_actionable(), owned_files, spec_roots) if item) if targets_specified > 1: # We've been provided more than one of: a change request, an owner request, or spec roots. raise InvalidSpecConstraint( 'Multiple target selection methods provided. Please use only one of ' '--changed-*, --owner-of, or target specs') if changed_request.is_actionable(): scm = get_scm() if not scm: raise InvalidSpecConstraint( 'The --changed-* options are not available without a recognized SCM (usually git).' ) changed_files = cls.changed_files( scm, changes_since=changed_request.changes_since, diffspec=changed_request.diffspec) # We've been provided no spec roots (e.g. `./pants list`) AND a changed request. Compute # alternate target roots. request = OwnersRequest(sources=tuple(changed_files), include_dependees=str( changed_request.include_dependees)) changed_addresses, = session.product_request( BuildFileAddresses, [request]) logger.debug('changed addresses: %s', changed_addresses) dependencies = tuple( SingleAddress(a.spec_path, a.target_name) for a in changed_addresses) return TargetRoots([ Specs(dependencies=dependencies, exclude_patterns=exclude_patterns, tags=tags) ]) if owned_files: # We've been provided no spec roots (e.g. `./pants list`) AND a owner request. Compute # alternate target roots. request = OwnersRequest(sources=tuple(owned_files), include_dependees=str('none')) owner_addresses, = session.product_request(BuildFileAddresses, [request]) logger.debug('owner addresses: %s', owner_addresses) dependencies = tuple( SingleAddress(a.spec_path, a.target_name) for a in owner_addresses) return TargetRoots([ Specs(dependencies=dependencies, exclude_patterns=exclude_patterns, tags=tags) ]) return TargetRoots(spec_roots)
def create(cls, options, session, build_root=None, exclude_patterns=None, tags=None): """ :param Options options: An `Options` instance to use. :param session: The Scheduler session :param string build_root: The build root. """ # Determine the literal target roots. spec_roots = cls.parse_specs( target_specs=options.target_specs, build_root=build_root, exclude_patterns=exclude_patterns, tags=tags) # Determine `Changed` arguments directly from options to support pre-`Subsystem` # initialization paths. changed_options = options.for_scope('changed') changed_request = ChangedRequest.from_options(changed_options) # Determine the `--owner-of=` arguments provided from the global options owned_files = options.for_global_scope().owner_of logger.debug('spec_roots are: %s', spec_roots) logger.debug('changed_request is: %s', changed_request) logger.debug('owned_files are: %s', owned_files) targets_specified = sum(1 for item in (changed_request.is_actionable(), owned_files, spec_roots.dependencies) if item) if targets_specified > 1: # We've been provided more than one of: a change request, an owner request, or spec roots. raise InvalidSpecConstraint( 'Multiple target selection methods provided. Please use only one of ' '--changed-*, --owner-of, or target specs' ) if changed_request.is_actionable(): scm = get_scm() if not scm: raise InvalidSpecConstraint( 'The --changed-* options are not available without a recognized SCM (usually git).' ) changed_files = cls.changed_files( scm, changes_since=changed_request.changes_since, diffspec=changed_request.diffspec) # We've been provided no spec roots (e.g. `./pants list`) AND a changed request. Compute # alternate target roots. request = OwnersRequest(sources=tuple(changed_files), include_dependees=str(changed_request.include_dependees)) changed_addresses, = session.product_request(BuildFileAddresses, [request]) logger.debug('changed addresses: %s', changed_addresses) dependencies = tuple(SingleAddress(a.spec_path, a.target_name) for a in changed_addresses) return TargetRoots(Specs(dependencies=dependencies, exclude_patterns=exclude_patterns, tags=tags)) if owned_files: # We've been provided no spec roots (e.g. `./pants list`) AND a owner request. Compute # alternate target roots. request = OwnersRequest(sources=tuple(owned_files), include_dependees=str('none')) owner_addresses, = session.product_request(BuildFileAddresses, [request]) logger.debug('owner addresses: %s', owner_addresses) dependencies = tuple(SingleAddress(a.spec_path, a.target_name) for a in owner_addresses) return TargetRoots(Specs(dependencies=dependencies, exclude_patterns=exclude_patterns, tags=tags)) return TargetRoots(spec_roots)