so, I've written a plugin to inject a `version` on...
# plugins
a
so, I've written a plugin to inject a
version
on setup.py for when you run
pants package
But it's hardcoded and not entirely helpful. Is there an easy way to add a
--version
flag to the
package
goal? oh ding, this is ez. Create a new "subsystem" give it a "--version" option. Then in your rule that modifys your setup.py options use request your subsystem type (via typed dependency-injection) and 💥 ezpz
💯 1
h
Yep, exactly! Although I don't think that's super intuitive per se and it could be documented better
a
stuck again tho.
Copy code
Common mistake: requesting the type of target you want in the @goal_rule signature
Doesn't seem to be picking up my targets that are a type of
CompanynamePythonDistribution(Target)
h
What are you trying to do?
a
for all
CompanynamePythonDistribution
target subtypes (that overwrites the version number) Run twine or whatev to upload it to pypi
the former bit works,
./pants package --company-version=1234.00
will spit out a file with that as the version number
Copy code
class InfloaiPublishPySubsystem(GoalSubsystem):
    name = "company-publish-py"
    help = "Publish company python packages"



class CompanyPublishPy(Goal):
    subsystem_cls = CompanyPublishPySubsystem



async def _publish(console: Console, distribution: Target):
    console.print_stdout("Publishing:", distribution)


@goal_rule
async def company_publish_py(console: Console, targets: Targets) -> CompanyPublishPy:
    for target in targets:
        console.print_stdout(f"X {target!r}")
        if not target.has_field(CompanyPythonDistribution):
            continue

        await _publish(console, target)

    return CompanyPublishPy(exit_code=1)
./pants company-publish ::
loops through all the targets, but doesn't pick up the targets
ohh, because those are fields, not targets
I'm guessing
isinstance(target, CompanyPythonDistribution)
is wrong?
hm, gotta pick this up tomorrow I think.