Skip to content

Commit a7e06ed

Browse files
committed
Updating to install with Jython
Specifically, hacked a solution to install with Jython and the --trunk option. This avoids the use of pyutilib.virtualenv by simply checking out Pyomo and PyUtilib. Perhaps this is the beginning of the end for pyutilib.virtualenv? git-svn-id: https://software.sandia.gov/svn/pyomo/pyomo/trunk@11375 570ccb8d-5833-0410-9ce8-cbedd0da42eb
1 parent cf9d61c commit a7e06ed

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

scripts/pyomo_install

+41-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import zipfile
1515
import shutil
1616
import logging
1717
import tempfile
18+
import subprocess
1819
try:
1920
from urllib.request import pathname2url as pathname2url
2021
except ImportError:
@@ -84,8 +85,6 @@ def call_subprocess(cmd, options, stdout=False, cwd=None, env=None):
8485
"""
8586
A wrapper for subprocess.Popen that manages I/O in a consistent manner.
8687
"""
87-
import subprocess
88-
8988
if env is None:
9089
env = os.environ.copy()
9190
#
@@ -281,7 +280,7 @@ def install_virtualenv(options, srcdir=None, pip=None, pip_src=None):
281280
return pip, python_dir
282281

283282

284-
def install_from_trunk(pip, options):
283+
def install_from_trunk_vpy(pip, options):
285284
"""
286285
Installing from trunk (with vpy_install).
287286
"""
@@ -331,6 +330,41 @@ def install_from_trunk(pip, options):
331330
return pip
332331

333332

333+
def install_from_trunk_jython(pip, python_dir, options):
334+
"""
335+
Install from PyPI or from Zip File
336+
"""
337+
if options.venv:
338+
pip, python_dir = install_virtualenv(options, pip=pip)
339+
if options.venvonly:
340+
return
341+
options.venv = False
342+
#
343+
# Setup the sourc directory
344+
#
345+
srcDir = os.path.join(python_dir, 'src')
346+
if not os.path.exists( srcDir ):
347+
os.mkdir( srcDir )
348+
python_executable = os.path.basename(sys.executable)
349+
python = os.path.join(python_dir, 'bin', python_executable)
350+
#
351+
# Install 'nose' first
352+
#
353+
call_subprocess([pip, 'instally','nose'], options)
354+
#
355+
# Clone and install PyUtilib
356+
#
357+
cmd = [ 'git', 'clone', '-q', 'https://github.com/PyUtilib/pyutilib.git']
358+
call_subprocess(cmd, options, cwd=srcDir)
359+
call_subprocess([python, 'setup.py','develop'], options, cwd=os.path.join(srcDir,'pyutilib'))
360+
#
361+
# Checkout and install Pyomo
362+
#
363+
cmd = [ 'svn', 'checkout', '-q', 'https://software.sandia.gov/svn/public/pyomo/pyomo/trunk', 'pyomo' ]
364+
call_subprocess(cmd, options, cwd=srcDir)
365+
call_subprocess([python, 'setup.py','develop'], options, cwd=os.path.join(srcDir,'pyomo'))
366+
367+
334368
def install_from_src(pip, srcdir, pip_src, python_dir, options):
335369
#
336370
# Install from PyPI or from Zip File
@@ -741,7 +775,10 @@ virtual python environment is created in the 'pyomo' directory.
741775
# Install Pyomo
742776
#
743777
if options.trunk:
744-
pip = install_from_trunk(pip, options)
778+
if getattr(subprocess,'jython',False):
779+
pip = install_from_trunk_jython(pip, python_dir, options)
780+
else:
781+
pip = install_from_trunk_vpy(pip, options)
745782
elif options.zipfile or options.srcdir:
746783
offline = True # Force offline for now
747784
pip = install_from_src(pip, srcdir, pip_src, python_dir, options)

0 commit comments

Comments
 (0)