I'm buiding an application that depends on some_package
(which is rather large) as installed through pip
or conda
. I would like to reuse parts of some_package
directly in the application; to that end, I have forked some_package
, installed it locally, and modified its functionality as needed. The application now depends on two (diverging) versions of the same package of the same name for different functionality.
How do I refer to the pip
/conda
managed ~/anaconda3/envs/my_env/lib/python3.7/site-packages/some_package/
for internal dependency, and the modified ~/my_project/dependencies/some_package/
for use in my application?
There are several questions on Stack Overflow, but they are either quite old or not the same question:
Python: Two packages with the same name; how do you specify which is loaded?
Is it possible to use two Python packages with the same name?
Importing from builtin library when module with same name exists
What I've tried:
conda develop <local package path>
: in this case, the site-package is not visible and breaks internal dependencies- changing the name of the local package folder and importing: there are internal references to the package name that would mean renaming everywhere, and create a management mess if I ever wish to pull new code on the fork
- a comment suggested
import some_package as package_dev
: this obviously won't work as I have no way to refer to both packages in the first place
In the linked questions (and others), there are a number of hacks that will kind of work but break the import system in subtle ways (reload, for package updates, etc). Is there a "pythonic"/recommended way to accomplish this?