Skip to content

Commit 1e60a8f

Browse files
committed
Changes to get github working within pyomo_install.
1 parent 53b5881 commit 1e60a8f

File tree

2 files changed

+46
-40
lines changed

2 files changed

+46
-40
lines changed

pyutilib/virtualenv/header.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import StringIO
2222
except ImportError:
2323
import io as StringIO
24+
import string
2425
import zipfile
2526
import shutil
2627
import string
@@ -235,7 +236,7 @@ class Repository(object):
235236

236237
def __init__(self, name, **kwds):
237238
class _TEMP_(object):
238-
def __init__( self, root=None, trunk=None, github=None,
239+
def __init__( self, root=None, trunk=None,
239240
release=None, tag=None, pyname=None, pypi=None,
240241
dev=False, username=None, install=True, rev=None,
241242
local=None, platform=None, version=None,
@@ -338,7 +339,6 @@ def initialize(self, config):
338339
self.tag = None
339340
self.release_root = None
340341
#
341-
self.github = config.github
342342
self.pypi = config.pypi
343343
self.local = config.local
344344
self.platform = config.platform
@@ -369,7 +369,7 @@ def initialize(self, config):
369369
self.install = config.install
370370

371371
def guess_versions(self):
372-
if self.config.github is None and not self.config.root is None:
372+
if not self.config.root is None and not '.git' in self.config.root:
373373
if not self.offline:
374374
if using_subversion and not sys.platform.startswith('win'):
375375
rootdir_output = subprocess.Popen(['svn','ls',self.config.root], stdout=subprocess.PIPE).communicate()[0]
@@ -405,8 +405,7 @@ def guess_versions(self):
405405
self.release = None
406406
self.release_root = None
407407
else:
408-
# NOTE: this forces the use of github, which wasn't the intent
409-
self.trunk = self.config.github
408+
self.trunk = self.config.root
410409
if not self.config.trunk is None:
411410
if self.trunk is None:
412411
self.trunk = self.config.trunk
@@ -430,8 +429,6 @@ def write_config(self, OUTPUT):
430429
print('[%s]' % config.name)
431430
if not config.root is None:
432431
print('root=%s' % config.root)
433-
if not config.github is None:
434-
print('github=%s' % config.github)
435432
if not config.trunk is None:
436433
print('trunk=%s' % config.trunk)
437434
if not config.tag is None:
@@ -513,23 +510,37 @@ def perform_install(self, dir=None, install=True, preinstall=False):
513510
print("-----------------------------------------------------------------")
514511
print(" Installing branch")
515512
print(" Checking out source for package "+self.name)
513+
print(" %s %s" % (str(using_git), str(self.root)))
516514
if self.local:
517515
print(" Package dir: "+self.local)
518-
elif using_git and not self.github is None:
519-
print(" Git dir: "+self.github)
516+
elif using_git and not self.root is None:
517+
if '%23' in self.root:
518+
self.root = self.root.split('%23')[0]
519+
elif '#' in self.root:
520+
self.root = self.root.split('#')[0]
521+
print(" Git dir: "+self.root)
520522
else:
521523
print(" Subversion dir: "+self.pkgdir)
522524
if os.path.exists(dir):
523525
print(" No checkout required")
524526
print("-----------------------------------------------------------------")
525-
elif using_git and not self.github is None:
527+
elif using_git and not self.root is None and '.git' in self.root:
526528
print("-----------------------------------------------------------------")
527529
try:
528-
self.run([self.git, 'clone', self.github, dir])
530+
if '%23' in self.root:
531+
branch= ['-b', self.root.split('%23')[1]]
532+
url= self.root.split('%23')[0]
533+
elif '#' in self.root:
534+
branch= ['-b', self.root.split('#')[1]]
535+
url= self.root.split('#')[0]
536+
else:
537+
branch = []
538+
url= self.root
539+
self.run([self.git, 'clone'] + branch + [url, dir])
529540
except OSError:
530541
err,tb = sys.exc_info()[1:3] # BUG?
531542
print("")
532-
print("Error checkout software %s with git at %s" % (self.name,self.github))
543+
print("Error checkout software %s with git at %s" % (self.name,self.root))
533544
print(str(err))
534545
print("Traceback:")
535546
import traceback
@@ -886,12 +897,6 @@ def modify_parser(self, parser):
886897
dest='localize',
887898
default=False)
888899

889-
parser.add_option('--git',
890-
help='Checkout with git if the github URL is provided',
891-
action='store_true',
892-
dest='using_git',
893-
default=False)
894-
895900
parser.add_option('--pypi-url',
896901
help='Specify the url for the PyPI package index used for online installation',
897902
action='store',
@@ -966,8 +971,6 @@ def adjust_options(self, options, args):
966971
# Determine if the git command is available
967972
#
968973
global using_git
969-
if not options.using_git:
970-
using_git = False
971974
if using_git:
972975
try:
973976
sys.stdout.flush()

pyutilib/virtualenv/vpy_install.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,6 +3346,7 @@ def optionxform(self, option):
33463346
import StringIO
33473347
except ImportError:
33483348
import io as StringIO
3349+
import string
33493350
import zipfile
33503351
import shutil
33513352
import string
@@ -3560,7 +3561,7 @@ class Repository(object):
35603561

35613562
def __init__(self, name, **kwds):
35623563
class _TEMP_(object):
3563-
def __init__( self, root=None, trunk=None, github=None,
3564+
def __init__( self, root=None, trunk=None,
35643565
release=None, tag=None, pyname=None, pypi=None,
35653566
dev=False, username=None, install=True, rev=None,
35663567
local=None, platform=None, version=None,
@@ -3663,7 +3664,6 @@ def initialize(self, config):
36633664
self.tag = None
36643665
self.release_root = None
36653666
#
3666-
self.github = config.github
36673667
self.pypi = config.pypi
36683668
self.local = config.local
36693669
self.platform = config.platform
@@ -3694,7 +3694,7 @@ def initialize(self, config):
36943694
self.install = config.install
36953695

36963696
def guess_versions(self):
3697-
if self.config.github is None and not self.config.root is None:
3697+
if not self.config.root is None and not '.git' in self.config.root:
36983698
if not self.offline:
36993699
if using_subversion and not sys.platform.startswith('win'):
37003700
rootdir_output = subprocess.Popen(['svn','ls',self.config.root], stdout=subprocess.PIPE).communicate()[0]
@@ -3730,8 +3730,7 @@ def guess_versions(self):
37303730
self.release = None
37313731
self.release_root = None
37323732
else:
3733-
# NOTE: this forces the use of github, which wasn't the intent
3734-
self.trunk = self.config.github
3733+
self.trunk = self.config.root
37353734
if not self.config.trunk is None:
37363735
if self.trunk is None:
37373736
self.trunk = self.config.trunk
@@ -3755,8 +3754,6 @@ def write_config(self, OUTPUT):
37553754
print('[%s]' % config.name)
37563755
if not config.root is None:
37573756
print('root=%s' % config.root)
3758-
if not config.github is None:
3759-
print('github=%s' % config.github)
37603757
if not config.trunk is None:
37613758
print('trunk=%s' % config.trunk)
37623759
if not config.tag is None:
@@ -3838,23 +3835,37 @@ def perform_install(self, dir=None, install=True, preinstall=False):
38383835
print("-----------------------------------------------------------------")
38393836
print(" Installing branch")
38403837
print(" Checking out source for package "+self.name)
3838+
print(" %s %s" % (str(using_git), str(self.root)))
38413839
if self.local:
38423840
print(" Package dir: "+self.local)
3843-
elif using_git and not self.github is None:
3844-
print(" Git dir: "+self.github)
3841+
elif using_git and not self.root is None:
3842+
if '%23' in self.root:
3843+
self.root = self.root.split('%23')[0]
3844+
elif '#' in self.root:
3845+
self.root = self.root.split('#')[0]
3846+
print(" Git dir: "+self.root)
38453847
else:
38463848
print(" Subversion dir: "+self.pkgdir)
38473849
if os.path.exists(dir):
38483850
print(" No checkout required")
38493851
print("-----------------------------------------------------------------")
3850-
elif using_git and not self.github is None:
3852+
elif using_git and not self.root is None and '.git' in self.root:
38513853
print("-----------------------------------------------------------------")
38523854
try:
3853-
self.run([self.git, 'clone', self.github, dir])
3855+
if '%23' in self.root:
3856+
branch= ['-b', self.root.split('%23')[1]]
3857+
url= self.root.split('%23')[0]
3858+
elif '#' in self.root:
3859+
branch= ['-b', self.root.split('#')[1]]
3860+
url= self.root.split('#')[0]
3861+
else:
3862+
branch = []
3863+
url= self.root
3864+
self.run([self.git, 'clone'] + branch + [url, dir])
38543865
except OSError:
38553866
err,tb = sys.exc_info()[1:3] # BUG?
38563867
print("")
3857-
print("Error checkout software %s with git at %s" % (self.name,self.github))
3868+
print("Error checkout software %s with git at %s" % (self.name,self.root))
38583869
print(str(err))
38593870
print("Traceback:")
38603871
import traceback
@@ -4211,12 +4222,6 @@ def modify_parser(self, parser):
42114222
dest='localize',
42124223
default=False)
42134224

4214-
parser.add_option('--git',
4215-
help='Checkout with git if the github URL is provided',
4216-
action='store_true',
4217-
dest='using_git',
4218-
default=False)
4219-
42204225
parser.add_option('--pypi-url',
42214226
help='Specify the url for the PyPI package index used for online installation',
42224227
action='store',
@@ -4291,8 +4296,6 @@ def adjust_options(self, options, args):
42914296
# Determine if the git command is available
42924297
#
42934298
global using_git
4294-
if not options.using_git:
4295-
using_git = False
42964299
if using_git:
42974300
try:
42984301
sys.stdout.flush()

0 commit comments

Comments
 (0)