Skip to content

Commit

Permalink
fix: rescue docarray in setup (#4203)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobowitz committed Jan 24, 2022
1 parent 31641c5 commit 1f2c863
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,32 @@ def add_ac(k, v):
pass


def rescue_docarray():
"""Upgrading from 2.x to 3.x is broken (https://github.com/jina-ai/jina/issues/4194)
This function checks if docarray is broken and if so attempts to rescue it
"""
try:
import docarray as docarray

__docarray_version__ = docarray.__version__

except AttributeError:
# Being here means docarray is not installed correctly, attempt to reinstall it
# as recommended by pip https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program
import subprocess

subprocess.check_call(
[sys.executable, '-m', 'pip', 'uninstall', '--yes', 'docarray']
)
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'docarray'])


class PostDevelopCommand(develop):
"""Post-installation for development mode."""

def run(self):
develop.run(self)
rescue_docarray()
register_ac()


Expand All @@ -87,6 +108,7 @@ class PostInstallCommand(install):

def run(self):
install.run(self)
rescue_docarray()
register_ac()


Expand Down

0 comments on commit 1f2c863

Please sign in to comment.