<#22424 How to set isolated virtual env for a spec...
# github-notifications
c
#22424 How to set isolated virtual env for a specific python package in a mono repo New discussion created by sokui Hi community, I have a question about developing in a python monorepo. I know we can use
resolve
and
lockfile
to generate the exported virtual env for any dependencies you like. But I want to streamline it for each package in a monorepo. What I want to achieve is that I can switch to any package's dedicated virtual env (meaning no other dependencies from other packages) in the monorepo. The problem for
resolve
is that if you make packge1's dependency to use
resolve="package1"
, then for package2 which depends on package1, you should also make
resolve="package1"
in order to include all the dependencies for its virtual env. But this means the package1's virtual env will also include package2's dependencies which is not what we want. So one way to make a fully isolated virtual env is that assuming we have a lib1, and package1, package2 which both depends on lib1, then we should do following: • for lib1's dependencies, we make
resolve=parametrize("lib1", "package1", "package2")
• for package1, we make it
resolve="package1"
, • for package2 we make it
resolve="package2"
. So in this case, we can export these three virtual envs for these three packages. But the thing is that we the monorepo has lots packages who depend on each other, this method becomes unscalable. If a lib is needed by N packages, then it needs
resolve=parametrize("lib1", "package1", "package2", ... , "packageN")
. I am think is it possible to reuse
resolve
, for example: • for lib1, we make
resolve="lib1"
• for package1, we make it
resolve="package1", resolve_reuse=["lib1", ...]
, • for package2 we make it
resolve="package2", resolve_reuse=["lib1", ...]
. Do we have something similar like this or there is some other way to do it? pls advise. thank you! pantsbuild/pants