Changeset 9502


Ignore:
Timestamp:
Dec 18, 2014 10:43:48 PM (4 years ago)
Author:
wehart
Message:

Explicitly searching for pip and the site-packages
directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyomo/trunk/scripts/pyomo_install

    r9494 r9502  
    133133        raise SystemExit(1)
    134134    return exe
     135
     136
     137def find_pip(tempdir):
     138    """
     139    Find the pip executable in the specified directory.   This
     140    executable is returned, if found.
     141
     142    Also, look for a site-packages directory, which is added to the PYTHONPATH.
     143    """
     144    filename = None
     145    for root, dirs, files in os.walk(tempdir):
     146        if filename is None:
     147            for fname in files:
     148                if fname == 'pip' or fname == 'pip.exe':
     149                    filename = os.path.join(root, fname)
     150        for dir_ in dirs:
     151            if dir_ == 'site-packages':
     152                #print("HERE %s" % os.path.join(root, dir_))
     153                os.environ['PYTHONPATH'] = os.path.join( root, dir_ )
     154    if not filename is None:
     155        return filename
     156    print("ERROR: Problem installing pip.  No pip executable found after installing pip in "+tempdir)
     157    raise SystemExit(1)
    135158
    136159
     
    362385        print("\n************* Installing pip *******************")
    363386    install_pip(upgrade=options.zipfile is None, user=False, quiet=not options.verbose)
    364     pip = os.path.abspath(os.path.join(pyomo_install_tempdir, sys.exec_prefix[1:], 'bin', 'pip'))
    365     if not os.path.exists(pip):
    366         pip = os.path.abspath(os.path.join(pyomo_install_tempdir, sys.exec_prefix[1:], 'local', 'bin', 'pip'))
    367     if not os.path.exists(pip):
    368         print("ERROR: Problem installing pip: Executable %s is not found."+pip)
    369         raise SystemExit(1)
    370     #
    371     if True:
     387    pip = find_pip(pyomo_install_tempdir)
     388
     389    if False:
     390        # This logic is now embedded in find_pip()
    372391        tmp = []
    373392        import site
Note: See TracChangeset for help on using the changeset viewer.