Hi everyone. Me again. Does Pants support publish...
# welcome
t
Hi everyone. Me again. Does Pants support publishing libraries into an internal PyPi repository? I can package them but the command
./pants publish ::
does nothing. I am using poetry and the packaged libraries sit in the default
dist/
folder. I generate a few so will ideally like to publish whatever has landed into that folder. I tried to find info in here and the github repo, but had no luck. All I get is that I might need to do an
experimental_shell_command
but I suspect I am not the 1st person to look into this. Thanks in advance!!
r
Hi, are you generating these libraries using pants or poetry?
If you are using pants then you can set-it up as suggested here https://www.pantsbuild.org/docs/python-publish-goal
t
pants package. I have this wee macro:
Copy code
# flake8: noqa: F821
def poetry_distribution(name, **kwargs):
    resources(name="package_data", sources=["pyproject.toml", "README.md"])

    python_distribution(
        name="dist",
        dependencies=[":package_data", f"src/python/{name}/src", "//:root"],
        provides=python_artifact(
            name=f"{name}_poc"
        ),
        generate_setup=False,
    )
r
That should work then with the doc I posted.
t
I will have a try then. how did I miss that? šŸ˜„ Thanks!
šŸ™ 1
any way to tell that python distribution to pick that info from the pants.toml file? There I got this
Copy code
[python-repos]
indexes.add = ["<https://nexus3>…
It is ok if not possible, just avoiding duplication.
actually, ignore as that index is for the pull, not the push
r
I am not sure about the indexes.add repo. The doc only talks about using it from
.pypirc
or directly providing it in the
repositories
. The other option would be using twine env var ``TWINE_REPOSITORY_URL` . At the end none of them avoid duplication though.
šŸ‘ 1
t
hi @refined-addition-53644. Is this feature a new addition? I have modified the macro as this:
Copy code
python_distribution(
        name="dist",
        dependencies=[":package_data", f"src/python/{name}/src", "//:root"],
        repositories=[
            "<https://nexus3.url/repository/pypi-bla/>"
        ],
        provides=python_artifact(
            name=f"{name}_poc",
            version="0.0.0.test"
        ),
        generate_setup=False
I am trying with pants 2.15.0rc3 but getting the following message:
w
sanity check: you have the experimental python backend enabled?
"pants.backend.experimental.python"
in
[GLOBAL].backend_packages
list
šŸ’Æ 1
šŸ™Œ 1
t
me bad šŸ˜„ Thanks @worried-painter-31382! It works!!