Skip to content

Commit

Permalink
Virtual env improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsteffensmeier committed Dec 16, 2021
1 parent 0a8a727 commit 5217dff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 14 additions & 3 deletions commands/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,24 @@ def copy_scripts(self):
install_base=install.install_base,
install_platbase=install.install_platbase,
install_lib=install.install_lib,
virtual_env=os.environ.get('VIRTUAL_ENV') or '',
virtual_env='',
ld_library_path='',
ld_preload='',
pythonhome='',
pythonexecutable='',
)

if os.environ.get('VIRTUAL_ENV'):
if is_windows():
context['virtual_env'] = os.environ.get('VIRTUAL_ENV')
else:
context['virtual_env'] = '. %s/bin/activate' % os.environ.get('VIRTUAL_ENV')
if is_osx():
# OS X is setting sys.executable to java which is preventing it from finding site-packages in a venv
# setting PYTHONEXECUTABLE overrides sys.executable and helps find site-packages
context['pythonexecutable'] = 'export PYTHONEXECUTABLE = %s' % sys.executable


if not is_osx() and not is_windows():
context['ld_library_path'] = 'LD_LIBRARY_PATH="' + \
sysconfig.get_config_var('LIBDIR') + \
Expand All @@ -82,7 +94,7 @@ def copy_scripts(self):
if lib_python:
context['ld_preload'] = 'LD_PRELOAD="{0}"; export LD_PRELOAD'.format(
lib_python)
if is_osx():
if is_osx() and not os.environ.get('VIRTUAL_ENV'):
prefix = sysconfig.get_config_var('prefix')
exec_prefix = sysconfig.get_config_var('exec_prefix')
if prefix == exec_prefix:
Expand All @@ -92,7 +104,6 @@ def copy_scripts(self):
context['pythonhome'] = 'PYTHONHOME="{0}"; export PYTHONHOME'.format(
pythonhome)


for script in self.scripts:
if is_windows():
script = '{0}.bat'.format(script)
Expand Down
10 changes: 2 additions & 8 deletions src/main/scripts/jep
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#!/bin/sh

VIRTUAL_ENV={virtual_env}
export VIRTUAL_ENV

{virtual_env}
{pythonexecutable}
{pythonhome}
{ld_library_path}
{ld_preload}

if test "x$VIRTUAL_ENV" != "x"; then
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
fi

cp="{install_lib}jep/jep-{version}.jar"
if test "x$CLASSPATH" != "x"; then
cp="$cp":"$CLASSPATH"
Expand Down

0 comments on commit 5217dff

Please sign in to comment.