summaryrefslogtreecommitdiff
path: root/lib/spack/spack/cmd/create.py
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2013-12-26 13:47:13 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2013-12-26 13:47:13 -0800
commit208db9b002db3cc4f5067060ee8d17e69de4d363 (patch)
tree6d8695fd3349b6d080512db6a262feec29b14942 /lib/spack/spack/cmd/create.py
parenta4cda9452449b7ef5c78d838f1315d69f0bdd1c7 (diff)
downloadspack-208db9b002db3cc4f5067060ee8d17e69de4d363.tar.gz
spack-208db9b002db3cc4f5067060ee8d17e69de4d363.tar.bz2
spack-208db9b002db3cc4f5067060ee8d17e69de4d363.tar.xz
spack-208db9b002db3cc4f5067060ee8d17e69de4d363.zip
More packaging documentation.
Diffstat (limited to 'lib/spack/spack/cmd/create.py')
-rw-r--r--lib/spack/spack/cmd/create.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index 0001c8556e..435b6c6a57 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -5,6 +5,7 @@ import re
from contextlib import closing
import spack
+import spack.cmd
import spack.package
import spack.packages as packages
import spack.tty as tty
@@ -45,11 +46,11 @@ class ${class_name}(Package):
versions = ${versions}
- def install(self, prefix):
+ def install(self, spec, prefix):
# FIXME: Modify the configure line to suit your build system here.
${configure}
- # FIXME:
+ # FIXME: Add logic to build and install here
make()
make("install")
""")
@@ -84,6 +85,15 @@ class ConfigureGuesser(object):
self.configure = '%s\n # %s' % (autotools, cmake)
+def make_version_dict(ver_hash_tuples):
+ max_len = max(len(str(v)) for v,hfg in ver_hash_tuples)
+ width = max_len + 2
+ format = "%-" + str(width) + "s : '%s',"
+ sep = '\n '
+ return '{ ' + sep.join(format % ("'%s'" % v, h)
+ for v, h in ver_hash_tuples) + ' }'
+
+
def create(parser, args):
url = args.url
@@ -118,8 +128,9 @@ def create(parser, args):
else:
urls = [spack.url.substitute_version(url, v) for v in versions]
if len(urls) > 1:
- tty.msg("Found %s versions of %s to checksum." % (len(urls), name),
- *["%-10s%s" % (v,u) for v, u in zip(versions, urls)])
+ tty.msg("Found %s versions of %s." % (len(urls), name),
+ *spack.cmd.elide_list(
+ ["%-10s%s" % (v,u) for v, u in zip(versions, urls)]))
print
archives_to_fetch = tty.get_number(
"Include how many checksums in the package file?",
@@ -130,17 +141,13 @@ def create(parser, args):
return
guesser = ConfigureGuesser()
- version_hashes = spack.cmd.checksum.get_checksums(
+ ver_hash_tuples = spack.cmd.checksum.get_checksums(
versions[:archives_to_fetch], urls[:archives_to_fetch],
first_stage_function=guesser)
- if not version_hashes:
+ if not ver_hash_tuples:
tty.die("Could not fetch any tarballs for %s." % name)
- sep = '\n '
- versions_string = '{ ' + sep.join(
- "'%s' : '%s'," % (v, h) for v, h in version_hashes) + ' }'
-
# Write out a template for the file
with closing(open(pkg_path, "w")) as pkg_file:
pkg_file.write(
@@ -149,7 +156,7 @@ def create(parser, args):
configure=guesser.configure,
class_name=class_name,
url=url,
- versions=versions_string))
+ versions=make_version_dict(ver_hash_tuples)))
# If everything checks out, go ahead and edit.
spack.editor(pkg_path)