<#22241 Trying to migrate a project using pants 2....
# github-notifications
c
#22241 Trying to migrate a project using pants 2.14 to latest (2.26) with custom python plugin New discussion created by adamhadani Hey all, I'm trying to migrate an existing monorepo using Pants
2.14.0
to the latest (
2.26.0
). I'm running into some issues with adapting an existing pants plugin we have I hope I can get some help with. I've worked through some issues already to do with import changes and convention changes e.g. using
.rules()
instead of
SubsystemRule(...)
but now getting a somewhat more cryptic error: ❯ pants 091930.20 [ERROR] Rule entry (TaskRule(output_type=<class 'dynamic_version.main.DynamicVersionSubsystem'>, parameters=FrozenDict({}), awaitables=(Get(ScopedOptions, Scope, ..),), masked_types=(), func=functools.partial(<function _construct_subsystem at 0x107977d80>, <class 'dynamic_version.main.DynamicVersionSubsystem'>), canonical_name='construct_scope_versioning', desc=None, level=<LogLevel.TRACE: 'trace'>, cacheable=True),) had an unexpected type: <class 'tuple'>. Rules either extend Rule or UnionRule, or are static functions decorated with @rule. The plugin file is quite compact so attaching here for completeness. It tries to basically create dynamic versioning for python packages: import os from pants.backend.python.util_rules.package_dists import SetupKwargs from pants.backend.python.util_rules.package_dists import SetupKwargsRequest from pants.engine.rules import rule, collect_rules from pants.engine.target import Target from pants.engine.unions import UnionRule from pants.option.option_types import StrOption from pants.option.subsystem import Subsystem class DynamicVersionSetupKwargsRequest(SetupKwargsRequest): @classmethod def is_applicable(cls, _: Target) -> bool: # We always use our custom
setup()
kwargs generator for
python_distribution
targets in # this repo. return True class DynamicVersionSubsystem(Subsystem): options_scope = "versioning" help = "Dynamic version subsystem - used when generating python package version" python_version = StrOption( default="0.0.1.dev1", help="version to use when publishing python packages", ) def rules(): return [ *collect_rules(), UnionRule(SetupKwargsRequest, DynamicVersionSetupKwargsRequest), DynamicVersionSubsystem.rules(), ] @rule async def setup_kwargs_plugin(request: DynamicVersionSetupKwargsRequest, dv_subsystem: DynamicVersionSubsystem) -> SetupKwargs: """ This function dynamically adds a version In order to pass the version in """ return SetupKwargs( {**request.explicit_kwargs, "version": dv_subsystem.python_version}, address=request.target.address ) any help appreciated.. pantsbuild/pants