Skip to content

Commit

Permalink
check if we are in a virtualenv when trying pip install
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangWaltenberger committed Feb 24, 2024
1 parent d23a7b5 commit 11889d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions smodels/tools/externalPythonTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@ def __init__(self, importname, optional=False ):
logger.error("could not find %s: %s" % (importname, e))

def compile ( self ):
import sys
cmd = ["install",self.name]
if sys.prefix == sys.base_prefix:
# we are *not* in a virtual env, so add '--user'
cmd = ["install","--user",self.name]
try:
import pip
pip.main(["install","--user",self.name] )
pip.main( cmd )
return
except (ImportError,AttributeError):
pass
try:
import pip._internal
pip._internal.main(["install","--user",self.name] )
pip._internal.main( cmd )
return
except (ImportError,AttributeError):
pass
Expand Down
2 changes: 1 addition & 1 deletion unittests/runCompleteTestSuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def parallel_run ( verbose, testNotebooks=False, reduced=False ):
from concurrencytest import ConcurrentTestSuite, fork_for_tests
except ImportError as e:
print ( "Need to install the module concurrencytest." )
print ( "pip install --user concurrencytest" )
print ( "pip install concurrencytest" )
return
from smodels.base import runtime

Expand Down

0 comments on commit 11889d3

Please sign in to comment.