0

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:

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?

anon01
  • 10,618
  • 8
  • 35
  • 58
  • Just import with different name: `import a as a_custom` – Nache Jul 05 '19 at 17:31
  • Why is it a management mess to rename the package? Can't you just do a find and replace of all the internal references? – fgoudra Jul 05 '19 at 20:11
  • recursively renaming `some_package` to `some_package_dev` and `conda develop project_name -n env_name` appears to have worked for now. – anon01 Jul 05 '19 at 21:20

0 Answers0