Skip to content

Containerization: Relocate path-based dependencies from requirements.txt file to support containerization #429

@chang-annie

Description

@chang-annie

When rewriteLocalPathDepsInArchives is set to false, the containerization process writes local file paths into the METADATA file inside Poetry generated wheel files that reference monorepo dependencies. During Docker builds, these file paths cannot be resolved, causing build failures. We need to investigate strategies to reliably work around this issue. UV projects do not run into the same issue.

Example METADATA file:

Metadata-Version: 2.3
Name: python_containerization_experiment_lib
Version: 0.1.0.dev0
Summary: Util code for python containerization experiment lib
Requires-Python: >=3.12,<4
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: python-containerization-experiment-util @ file:///Users/anniechang/experiment-python-containerization/util

Example error message:

[INFO] DOCKER> 66.56 Processing /Users/anniechang/experiment-python-containerization/util (from python-containerization-experiment-lib==0.1.0.dev0)
[INFO] DOCKER> 66.56 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/Users/anniechang/experiment-python-containerization/util'

Steps to Reproduce

  1. Create a Poetry project with a Python application module and a docker module to package the application as a Docker image
  2. In the docker module, add the containerize-dependencies goal
  3. In the application module, set the rewriteLocalPathDepsInArchives to false
  4. Build the project and note that the build will fail at the docker module because it cannot resolve the local file path that was included in the generated wheel file
  5. (Optional) Unzip the generated wheel file - unzip path/to/generated_wheel.whl and note that there is local file path included in the METADATA file
Requires-Dist: python-containerization-experiment-util @ file:///Users/anniechang/experiment-python-containerization/util

Expected Behavior

Poetry project with monorepo dependencies should be able to successfully containerize when the rewriteLocalPathDepsInArchives is set to `false

Actual Behavior

Poetry project with monorepo dependency fails to containerize because local file path included in the generated wheel file.

Definition of Done:

  • Poetry projects should successfully containerize even with path dependencies
    • investigate and implement solution such that final Poetry generated wheel files do not include local file paths when rewriteLocalPathDepsInArchives is set to false
    • leave comment with potential solutions

Test Strategy

  • follow steps 1-3 in Steps to Reproduce
  • use the containerize-dependencies goal to create a Docker image for the for the docker module
  • confirm docker module is able to package the application as a Docker image and containerize successfully

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions