Load two different python packages with the same name as gracefully as possible

25 Views Asked by At

There are two PyPi modules by the name of coinbase (v2 interface) and coinbase-advanced-py (v3 interface). Regardless of the PyPi names, they both import simply as coinbase. I want to use both packages in a monolithic package I'm building and I'm looking for the least hackish way to do it. All I can do right now is rename the directories under site-packages after install, which seems to do the trick, but it messes up PIP and just feels like the wrong way to do it.

Is there any cleaver way of perhaps doing this by using some arcane PIP switch, or calling setuptools programmatically?

I realize I should follow the docs and move everything to V3, but despite the assertions, some of the V2 features (ACH banking) still are not in V3. Plus there is a bit of "I want" involved here that I can't seem to let go.

Currently what I'm doing is:

  1. pip install coinbase
  2. rename site-package\coinbase to site-pacckage\coinbase_v2
  3. pip install coinbase-advanced-py
  4. rename site-package\coinbase to site-pacckage\coinbase_v3
  5. import coinbase_v2, coinbase_v3

But this process does mess with pip show coinbase and other pip inventory functions.

0

There are 0 best solutions below