Hi, what is the syntax for copying a `python_distr...
# general
r
Hi, what is the syntax for copying a
python_distribution
(wheel) into a Dockerfile built by pants?
The doc says: ā€¢ The artifacts of any packageable targets are built, as if by running
./pants package
, and placed in the context using the artifact's
output_path
field. ā—¦ The
output_path
defaults to the scheme
<http://path.to|path.to>.directory/tgt_name.ext
, e.g.
src.python.helloworld/bin.pex
.
n
I believe the correct Dockerfile instruction would be
COPY <http://path.to|path.to>.directory/tgt_name.whl /opt/destination/directory
.
r
In my package build file, my target is defined as follow:
Copy code
python_distribution(
    name="dist",
    provides=python_artifact(
        name="my_package",
        version="0.1.0",
    ),
)
COPY <http://src.python.my|src.python.my>_package/dist.whl /tmp
failed (file does not exist).
n
Sorry. For wheels it might be a little different. Maybe try
COPY <http://src.python.my|src.python.my>_package/my-package-0.1.0.whl /tmp
r
Nope, still failing....
I tried a bunch of combinaisons, but none worked.
n
What's the output when you package the whl directly.
./pants package src/python:dist
And are you including
":dist"
as a dependency on the docker_image target?
r
Yes
Copy code
docker_image(
    name="my_docker_image",
    dependencies=[
        ...
        "src/python/my_package:dist",
    ],
)
Copy code
./pants package src/python/my_package:dist
09:56:17.93 [INFO] Wrote dist/my_package-0.1.0-py3-none-any.whl
09:56:17.93 [INFO] Wrote dist/my_package-0.1.0.tar.gz
n
Ahh
COPY my_package-0.1.0-py3-none-any.whl /tmp
should do it
šŸ™Œ 1
Weird how wheels and sdists don't get put into the same path.to.directory patterns
ā— 2
r
Thank you very much, it worked!
b
@hundreds-father-404 here's another case we might consider adding
output_path
field to
python_distribution
.
r
But yes, I agree with you. It's weird that
python_distribution
doesn't follow the documented scheme...
b
FYI y'all two ways to help for the future: ā€¢ Use
./pants package ...
and inspect where it is located in the
dist
dir. That'll be reflected in the docker context ā€¢ Use
./pants --no-process-cleanup ...
and inspect the sandbox created for the
docker build
process
šŸ‘ 1