Skip to content
Permalink
Browse files

[#1040] Allow build-module to set version from command line even when…

… dependencies.yml exists
  • Loading branch information...
heldinz authored and pepite committed Aug 16, 2011
1 parent f08d596 commit e7ab686af3a98feeaab8543fa00d7240d04ac117
Showing with 35 additions and 4 deletions.
  1. +35 −4 framework/pym/play/commands/modulesrepo.py
@@ -247,11 +247,13 @@ def list(app, args):
print "~ play install module (eg: play install scala)"
print "~"


def build(app, args, env):
ftb = env["basedir"]
version = None
name = None
fwkMatch = None
origModuleDefinition = None

try:
optlist, args = getopt.getopt(args, '', ['framework=', 'version=', 'require='])
@@ -271,10 +273,13 @@ def build(app, args, env):
if os.path.exists(deps_file):
f = open(deps_file)
deps = yaml.load(f.read())
self = deps["self"].split(" ")
versionCandidate = self.pop()
name = self.pop()
version = versionCandidate
if 'self' in deps:
splitted = deps["self"].split(" -> ")
if len(splitted) == 2:
nameAndVersion = splitted.pop().strip()
splitted = nameAndVersion.split(" ")
if len(splitted) == 2:
version = splitted.pop()
for dep in deps["require"]:
if isinstance(dep, basestring):
splitted = dep.split(" ")
@@ -289,6 +294,25 @@ def build(app, args, env):
if fwkMatch is None:
fwkMatch = raw_input("~ What are the playframework versions required? ")

if os.path.exists(deps_file):
f = open(deps_file)
deps = yaml.load(f.read())
if 'self' in deps:
splitted = deps["self"].split(" -> ")
f.close()
if len(splitted) == 2:
nameAndVersion = splitted.pop().strip()
splitted = nameAndVersion.split(" ")
if len(splitted) == 1:
try:
deps = open(deps_file).read()
origModuleDefinition = re.search(r'self:\s*(.*)\s*', deps).group(1)
modifiedModuleDefinition = '%s %s' % (origModuleDefinition, version)
replaceAll(deps_file, origModuleDefinition, modifiedModuleDefinition)
except:
pass


build_file = os.path.join(app.path, 'build.xml')
if os.path.exists(build_file):
print "~"
@@ -323,6 +347,13 @@ def build(app, args, env):
zip.close()

os.remove(manifest)

# Reset the module definition
if origModuleDefinition:
try:
replaceAll(deps_file, '%s %s' % (origModuleDefinition, version), origModuleDefinition)
except:
pass

print "~"
print "~ Done!"

0 comments on commit e7ab686

Please sign in to comment.
You can’t perform that action at this time.