-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Support for mutually exclusive dependencies across groups (e.g. path dependencies during development only) #1168
Comments
The solution to this existing problem requires some kind tof "redirection": the "path dependencies" contain the exact path, while another "type of dependency" would allow each user to configure ("redirect to") its exact path. Actually, not even a new type of dependency is needed, as long as the user can override and re-direct any regular dependency to its own path. |
@ankostis , I agree that allowing the user to override -- e.g. with commandline arguments -- during the install step would meet my requirements here. Something like:
It would probably still be required that the dependency at that local path matched the version specified in my |
I'm currently facing the same challenges as described. Basically, I have a number of library packages and a number of app packages using those libraries, and would like to:
The problem seems to be a disconnect between path dependencies,
I've tried (and failed) on some workarounds:
Found some partial / potential workarounds, though none of these cover all requirements:
And also:
I think this problem would be solved if there was a configurable package resolver - eg. you could configure it to first look up the package name in a particular directory and if it exists then install it as path dependency, else go look for a git repo |
I'm facing this issue while maintaining two poetry-managed libraries. I did the following: ~/src/dep$ poetry install
~/src/dep$ cd ../main/
~/src/main$ poetry install
~/src/main$ echo $HOME/src/dep >> $VIRTUAL_ENV/lib/python3.6/site-packages/easy-install.pth
~/src/main$ python -c 'import dep; print(dep.__file__)'
/home/.../src/deps/dep.py
~/src/main$ That's not the best solution, but still fire and forget. |
I too am in a similar situation. I'm substituting a dependency (e.g. |
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Um, yes this is still relevant! Unless something has changed this is still just as broken/incomplete as it was when the issue was created. |
@sdispater , could we get feedback on this issue? |
Poetry does not support different dependencies during development: <python-poetry/poetry#1168>
I'm using path dependencies similar to some of the others who've followed up is this issue already, but am interesting in having those dependencies built and installed into the virtual env just like anything else, not as "editable" installs using .egg-link metadata. My goal is to be able to use the virtual env as input to a process that builds a platform package (.deb in my case). Being able to control the type of installation separately from the type of source would be quite handy. |
Any update on this? |
Can anyone weigh in on what are the obstacles for this functionality, so we could begin working on eliminating them? |
@hozn Your use case sounds very similar to one I have porposed at #2270. It would be good to get more eyes on that one and possibly feedback as a way to solve this. Additionally, there is also #755 which might be another solution once implemented. However, that will only work if you are okay working with VCS copies. This would also imply that you can simply use something like git-submodules, which might not be ideal. @idmitrievsky at the moment, I do not think there is a specific solution proposed here. If #2270 would be a solution that would be awesome, it is something I do want to work on soon once we have some feedback. If poetry were to allow for dev dependencies to override specified dependencies, this would sort of break the locking mechanism itself. A possible compromise might be to allow for a local configuration that allows for the pre-pending of certain paths in the project's virtualenv without using it to determine dependencies or update lockfile etc. If that is something that is desirable, I do think that will sit well inside a plugin once the plugin system is completed. |
@abn thank you for your response! I will keep an eye on the plugin system then. |
Add me to the list of those facing this issue. My team is working on a large django project that incorporates multiple python apps (eventually installed on multiple nodes) and shared local libraries. While I already sold them on moving to poetry, getting a dev environment set up currently seems to more of a hassle than it's worth. I'd prefer to wait than use the work-arounds others have mentioned for simulating an editable install. @abn I like your #2270 proposal and would like to help with any feedback/planning to get things rolling ASAP. My gitlab ticket of moving our project to poetry is going to hang until one of the proposed solutions gets implemented. |
Would this work? I'd create a seperate pyproject.toml in a new folder which lists all of my main package's in-company dependencies as editable path dependencies. I then run |
Hello everyone, |
I'm also facing a similar challenge working with a "main" application that uses a shared library that I have added as a Git submodule. Apologies in advanced I'm pretty new to poetry, coming from conda and manual venv. I want to be able to work on the shared library, and interact with it's Git repo, but a CI/CD produced version of the shared library from my private Azure Artifacts feed when I build my application (in a Docker container). I had expected behaviour similar to what I think the OP suggested where the local path was used when I Using something like:
I think this partially mitigates the issue the OP mentions about co-workers organizing their projects differently.... I have the luxury of "forcing" a project layout by using a Git submodule, but regardless I think this would still be useful? |
How about having separate toml files for various environments. ? |
If you haven't tried it, yarn has a nice feature for this called |
@janhurst I have exactly the same issue that you do. Our production docker containers use poetry to build a wheel before installing it in a fresh image. Currently the shared library in the |
I have made https://pypi.org/project/poetry-dev/ in order to support this use case. |
I can see where this kind of request might get bogged down if you're creating potentially conflicting constraints with disjoint groups. However for my usecase, which brought me to this issue, i feel like just deferring the install-time ( And by "resolution", i mean that a path dependency will ensure the existence of the path before it checks whether or not it will ultimately be installed. Whereas for non-path dependencies, there really isn't any resolution of that sort until it's being installed (afaik). If the lockfile is not outdated, the path must have existed at the time of the EDIT: poet-plugin initially seemed like a solution, but it appears to not be invoked early enough to avoid the path existence check |
It seems like you have have come across the wrong issue -- you might be looking for #668 instead? |
aha! dunno how i missed that. Although they do feel very very related. I'll go subscribe there instead :P |
To be clear to any onlookers:
|
That's a nice to have, but the main use case in my suggestion is running stuff from the terminal or CI pipeline, and stuff just works if they import dev-only dependencies, e.g., test files importing from other test files. |
I think there's two things being conflated there. A dev-only dependency, i.e., another distribution, will "just work" when it's installed, because it's installed like any other distribution, and added to If you want things in your If you do not want to make that folder a separate distribution, then you would need to manually add it to your I don't think this is something Poetry should handle "magically", because:
This also seems like a very different concern from what this ticket is about, as summarised by #1168 (comment). |
Hi, Was looking for a similar issue before opening a "feature request" and seems this one is related to what I was looking for. Seems that poetry, even if in dedicated groups, build the dependencies tree based on all groups. So, is there any chance to add something similar as If not related with this issue and think it should be a separate "Feature Request", let me know. Regards, |
Seems like a related request, since even though the original request was more focused on having different versions of the same library in different groups, e.g. one pathed at dev-time, and one semver'd at non-dev time, if the pathed version of the used library itself depends on a different set libraries than the published version, the locked package set is bifurcated based on dev/non-dev, which seems to be the crux of your use-case as well. One concern with a bifurcated package set based on groups (which applies to dev/non-dev too) is that there's no way to represent that in a wheel generated by |
I have an issue that at first I thought was relevant to this ticket, but now I think not so much. It may just be a niche use case if this ticket were resolved. It is probably like a feature request for poetry-core and/or pip. I'll delete this comment later. I have a core library and a cli library. cli depends on core and declares core in When I
But when I
The workaround is pretty simple: editable install cli first, then editable install core. I hoped that when I ran It would be nice if I could have core declared as both a non-local dependency for production, and a local path dependency for development, like how this issue describes. If I request a non-editable install with pip I might hope the non-local dependency is selected, and if I request an editable install with pip I might hope the local path dependency is selected (and built+installed as editable as well). I think this might depend on the To disclaim again, I'm aware this may be too opinionated/unintuitive/niche, or that I am expecting too much coordination between pip and the build backend. |
Some more thoughts on this in an issue which I just closed as "mostly a dupe", for those collecting more info, somewhat specific to the non-dev dependency having a specified |
|
This is pretty nice! Unfortunately, if you use dependencies from pypi, it won't work: [tool.poetry.group.production.dependencies]
library-1 = { version = "0.1.0", source = "my-source } Maybe poetry should not check for this? |
I wrote some tooling to help with the use case... Sorry it's using the dev-dependencies thingie: It works pretty well. The key for the root dev project is this pydev=true. The tooling is called stew. The relevant commands for the use case:
I'm not sure it works with the new poetry groups at all, by the way. It's also opiniated around git. |
Same issue for me =-( I develop project with few services. Some of this services depends on our library (shared-lib). In develop process we need to do some changes in that library in editable mode. For better development experience. So I tried solve the problem in this way, but it's not working:
I got an error:
This could be used like this:
Is any solutions for this case? |
Hi Any new update or development for this? |
Question
I believe this issue is related to #668 -- or some of the comments therein -- but I believe my workflow / use case is also a little different from the origin of that issue.
Here's the background / what I'm trying to accomplish:
Here's how I would do this with setuptools / pip:
my-app
e.g.) has arequirements.txt
file that has loose enough versions of my shared libraries so that it'll be satisfied by the next version that I'm working on. For example, ifmy-app
will use an updatedmy-lib1
version 4.1 andmy-lib2
version 1.12.3, I might have the following inmy-app/requirements.txt
:pip install -r requirements.txt && python setup.py develop
(Sometimespip install -e .
would also work, but the behavior was a little more consistent actually usingpython setup.py develop
. Argh, the mess that is python packaging !?!)pip install -r requirements.txt
in my main application; because I'd already donepython setup.py develop
I'd have installed (symlinked) in the right versions to satisfy formy-lib1
andmy-lib2
.my-app
was pushed to build server, it'd find the versions it needed.This all works reasonably well, though the initial environment setup is a pain. I'm really hoping to move to Poetry but I also feel that I "need" an equivalent to the above.
I can use "path dependencies" to point to my local shared libraries, but then these aren't going to work when it actually goes to build on the CI server (or on anyone else's workstation if they organize their files differently):
If I specify the same dependency in
[tool.poetry.dependencies]
and[tool.poetry.dev-dependencies]
, it seems to always pick the one from the non-dev deps:But even if this did work, ideally the solution wouldn't involve me using path dependencies at all, since (in this case) these are specific to how my workstation is setup -- a coworker may organize things differently.
So, is there a current solution to solving this problem? Perhaps I've missed something in reading the docs. Thanks for any help!
The text was updated successfully, but these errors were encountered: