diff --git a/python/makewheel.py b/python/makewheel.py index a5b683aa63..f13ad110ce 100644 --- a/python/makewheel.py +++ b/python/makewheel.py @@ -1,14 +1,26 @@ #!/usr/bin/env python -import sys,os +import sys,os,site -# find python script to activate the virtual environment and source it +base = os.path.abspath('buildwheel') if sys.platform == 'win32': - virtenv=os.path.join('buildwheel','Scripts','activate_this.py') + bin_dir=os.path.join(base,'Scripts') else: - virtenv=os.path.join('buildwheel','bin','activate_this.py') + bin_dir=os.path.join(base,'bin') -exec(open(virtenv).read(), {'__file__': virtenv}) +# prepend bin to PATH, set venv path +os.environ["PATH"] = os.pathsep.join([bin_dir] + os.environ.get("PATH", "").split(os.pathsep)) +os.environ["VIRTUAL_ENV"] = base + +# add the virtual environments libraries to the host python import mechanism +prev_length = len(sys.path) +for lib in "__LIB_FOLDERS__".split(os.pathsep): + path = os.path.realpath(os.path.join(bin_dir, lib)) + site.addsitedir(path) +sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length] + +sys.real_prefix = sys.prefix +sys.prefix = base # update pip and install all requirements to build the wheel os.system('python -m pip install --upgrade pip')