Hi! So I’ve got a pants built python distribution ...
# general
w
Hi! So I’ve got a pants built python distribution A. I separately, have python distribution B and C. I’d like to pants build an uber package containing the sources A,B and C. A user would choose one of these distributions, but not both. However, because of the ownership rules this doesn’t seem possible. What options do I have? Or do I have to hack this together on the side. For further context, this is really for simplicity for users to have a single package to install. We could also publish multiple packages, but that has other complexities for us.
b
just ran into this. You'll need to have different resolves for each of the package groups you'll want. For the ones you want a dist for, create the dist with the appropriate resolve. Then for the ones where you want to bundle the sources, don't create dists for the submodules and instead let the dependency resolver for code bundle things up.
pants.toml
Copy code
core_libs = "resolves/core-libs/python/requirements.lock"
event_extraction = "resolves/event-detection/python/requirements.lock"
event_server = "resolves/event-detection/python/requirements.lock"
BUILD for a package
Copy code
python_sources(
    name="src",
    sources=["riithon_core/**/*.py"],
    resolve=parametrize("core_libs", "event_extraction", "event_server")
)

python_distribution(
    name = "dist",
    dependencies = [":src@resolve=core_libs",":src@resolve=event_extraction"],
    provides=python_artifact(
        name="riithon-core-corenlp-model",
        version="1.0.0"
    ),
    repositories = [ "@rii-dev" ]
)
BUILD for the event server
Copy code
python_sources(
    name="src",
    sources = ["riithon_core/**/*.py"],
    resolve = "event_server"
)
BUILD for the jumbo, note it is one directory level higher so that the dependency resolver will work
Copy code
python_distribution(
    name  = "event_server_wheel",
    provides=python_artifact(
        name = "riithon-core-event-server",
        version = "1.0.0"
    ),
    dependencies = ["./event_server:src",
        "resolves/core-libs/python:requirements@resolve=event_server",
        "resolves/event-detection/python:requirements@resolve=event_server"],
    repositories = [ "@rii-dev" ]
)
w
Thanks for this! I was going down a path of ghetto package, untar, repackage manually with a shell script…. I’ll give this a whirl.
b
note, there is no distribution in the hierarchy for the event_server resolve. it's only for the individual packages created for the event_extraction and core_libs.
otherwise it won't grab the code from the python src dependencies, but instead will grab it via the dists.