-
-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local dependency and packaging #464
Comments
The issue is that you are installing this local package in editable-mode ( |
Sure but that's not exactly the philosophy when you use monorepo... My goal is to build independent packages using local dependencies from the same monorepo without publishing those artifacts to a registry (PyPi or local python registry). Something also discussed in the Poetry community: python-poetry/poetry#936 |
Maybe it would work if you specify the local package without |
Unfortunately I tried and it's failing:
The PDM version is |
You should define your pyproject.toml as follows: dependencies = [
"B @ file:///${PROJECT_ROOT}/relative/path/to/B"
]
|
I took me a while to find this solution, I feel for one this variable should be better documented around dependency handling, and should be utilized when adding local dependencies with |
This seems to not be working anymore.
runs into |
You can't refer to a package beyond the project root.
Simon Matejetz ***@***.***> 于2022年4月14日周四 17:34写道:
… This seems to not be working anymore.
dependencies = [
"B @ file:///${PROJECT_ROOT}/../relative/path/to/B"
]
runs into [KeyError]:('B', '0.0.1',
'file:///${PROJECT_ROOT}/../relative/path/to/B', False)
with some debugging it looks like this occurs because the key tuple in the
candidates dictionary has the resolved path
—
Reply to this email directly, view it on GitHub
<#464 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD4UNXT6ASWWRDRMRKJ4AXDVE7RDJANCNFSM45CKAULQ>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
@frostming this seems like a fairly arbitrary limitation, allowing it would very much help monorepos with conflicting dependencies between apps where a single project root isnt viable. Poetry supports this with the following syntax:
|
When I use this method, run
|
|
Could there be a new type of dependency that causes the projects to be “merged” into one for the purposes of building a distribution instead of including one as a path dependency (which like you say doesn’t work)? |
@adriangb why not put the local path dependencies under |
I don't think that works recursively right? That is, if A depends on B depends on C if I ask pdm to install A it will install A and B (because B is a dev dep of A) but not C. |
@frostming this makes sense now. I'm still learning Python packaging and appreciate you taking the time to answer. |
@frostming We are using PDM for some projects that are not published to a repo, but build to an exe instead. Do you have a similar use case @erikreppel? |
No, it doesn't |
Fair enough. Would you accept a feature request for it (I can open an issue in more detail)? Poetry supports it and together with dependency groups it makes for a nice simple monorepo solution: https://github.com/adriangb/python-monorepo. If not, no worries. |
@adriangb, here an alternative solution: create a "common-dev-deps" project/wheel that depends (production dependencies) on all your common development dependencies. Then dev-depend on this project/wheel in your different monorepo projects. This way they will stay in sync. Would that work for you? 🤔 |
No, monorepo projects can depend on each other |
OK, it seems I didn't quite understand your use-case 🙂 |
Not exactly. I want to have local deps (e.g. |
It seems like it's also impossible to use |
@adriangb Thanks for your git repo: https://github.com/adriangb/python-monorepo it is really helpful. |
I gave up on PDM (because of #464 (comment)) and used Poetry. Particularly with python-poetry/poetry#6845 merged Poetry is shaping up pretty nicely to handle Python monorepos. |
@txchen Here is one https://github.com/pdm-project/pdm-example-monorepo I set up recently |
That's cool @frostming ! I'll update my example repo. |
Could you clarify a couple of things? |
No, dev-dependencies in the sub-packages are not visible by the resolvers since it won't be built into the package metadata.
Because you resolve and install the dependencies in the top level project only1 and it specifies editable relative path dependencies, which will take precedence and override the normal dependencies with the same name in the sub packages. This is the main rule of how monorepo work in PDM.
There is a simple one in the docs on the main branch: https://pdm.fming.dev/dev/usage/advanced/#use-pdm-to-manage-a-monorepo Footnotes
|
Just to make sure I'm understanding, is there any way to install
👍🏻 I think you are right. The only situation where that makes sense is if you have subprojects with incompatible dependencies, but then you'd never be able to install the entire project at once, which defeats most of the purpose of a monorepo IMO. |
Fortunately, 2.5.0 is also released with multiple lockfile support. You can create a lockfile for each incompatible dependency (sub)set and run tasks against it. |
For those interested - working example of PDM monorepo https://github.com/Symas1/pdm-monorepo/tree/main |
How to do this?
|
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:
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:pyproject.toml
:(This looks an issue to me because the
pyproject.toml
is not portable anymore)pdm.lock
:__pypackages__
loooking like that:Install A
When I run
pdm install
I have: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 ?
The text was updated successfully, but these errors were encountered: