I'm trying to build a docker image for which I exp...
# general
w
I'm trying to build a docker image for which I expect to add dependencies to the context. It works as intended with a pex binary, but can't figure out how to do it with a python_distribution target. In my
docker_image
definition, I'm adding the python_distribution
src/python/dep1:dist
to the
dependencies
. But in my Dockerfile:
Copy code
COPY src.python.dep1/dist.whl /wheels/dep1.whl
returns a
COPY failed: file not found in build context or excluded by .dockerignore: stat src.python.dep1/dist.whl: file does not exist
Not clear in here how the syntax should be, is
.ext
supposed to be
.whl
in this context ?
n
Judging by the docs it should be named in a similar fashion as if you ran
./pants package src/python/dep1:dist
, so try that and verify that what's in your
Dockerfile
is the same as what's in
dist
.
r
w
thanks for sharing this thread, that seems very useful indeed. In my case the version of the python distribution is inferred using setuptools-scm, any idea how could I determine the appropriate version in the Dockerfile ? (the
X.X.X
in
<http://src.python.my|src.python.my>_package/my-package-X.X.X.whl)
h
Are you using Pants's setuptools-scm support, or is it external to pants?
w
Are you using Pants's setuptools-scm support
I might have missed it actually, how does this work ? Currently I'm using a homemade plugin to achieve this, something of the form :
Copy code
from setuptools_scm import get_version

@rule
async def setup_kwargs_plugin(request: CustomSetupKwargsRequest) -> SetupKwargs:
    """set package version using setuptools_scm
    """
    return SetupKwargs(
        {**request.explicit_kwargs, "version": get_version()}, address=request.target.address
    )