Skip to content

Local dependency and packaging #464

@nhuray

Description

@nhuray

Is your feature request related to a problem? Please describe.

Hi Dear community

I'm struggling to build and package an app depending on a local dependency using PDM.

So maybe it's because I'm quite new to python (long time I didn't code in that language), or because I did not understand some concepts related to PEP 582, so please excuse me if my question is obvious (or stupid).

So I want to bundle an AWS Lambda function (in Python) as a Docker image (let's name it A) following the documentation provided.

That function depends on a library (local dependency named B) which itself can bring some external dependencies (C, D, E).

So basically the dependency tree is something like:

├── A  (local)
│   └── B. (local)
│       ├── C (external)
│       ├── D (external)
│       └── E (external)

Add B as a local dependency into A project

When I add to project A the local dependency B running pdm add -e ../relative/path/to/B I have:

  • an absolute path in the pyproject.toml :
    dependencies = [
        "-e file:///Absolute/path/to/B#egg=B",
    ]
    

(This looks an issue to me because the pyproject.toml is not portable anymore)

  • a relative path in the pdm.lock :
name = "B"
sections = ["default"]
version = "0.0.1"
editable = true
path = "../relative/path/to/B"
  • a directory __pypackages__ loooking like that:
├── __pypackages__
│   └── 3.8
│       ├── bin
│       ├── include
│       └── lib
│           ├── B.egg-link
│           ├── easy-install.pth
│           └── A.egg-link

Install A

When I run pdm install I have:

[CHANGE IN 1.5.0]: dev-dependencies are included by default and can be excluded with `--prod` option
Synchronizing working set with lock file: 0 to add, 1 to update, 0 to remove

  ✔ Update B 0.0.1 -> 0.0.1 successful
Installing the project as an editable package...
  ✔ Update A 0.0.1 -> 0.0.1 successful

🎉 All complete!

Describe the solution you'd like

What I expect when I run pdm install in the A project is to resolve the local and external dependencies then install them to the __pypackages__ directory.

When I build the Docker image like that, I just need to copy the __pypackages__/3.8/lib directory.

So how do we do that ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⭐ enhancementImprovements for existing features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions