summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-09-19 09:43:45 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2014-09-19 09:43:45 -0700
commit115d06967770e411511698ad0b19e46063dc156c (patch)
tree836d094196d8009bd03a833660a369d1bfaf5d8f
parentde030c9932d16bd7204f5e4fc13741da2233948e (diff)
parent39acca4b43d5febdb07b2bb2edbbcd89cece10b1 (diff)
downloadspack-115d06967770e411511698ad0b19e46063dc156c.tar.gz
spack-115d06967770e411511698ad0b19e46063dc156c.tar.bz2
spack-115d06967770e411511698ad0b19e46063dc156c.tar.xz
spack-115d06967770e411511698ad0b19e46063dc156c.zip
Merge branch 'develop'
-rw-r--r--lib/spack/spack/cmd/create.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index c98162aca7..5f6350c8e8 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -36,7 +36,7 @@ import spack.cmd
import spack.cmd.checksum
import spack.package
import spack.url
-from spack.util.naming import mod_to_class
+from spack.util.naming import *
import spack.util.crypto as crypto
from spack.util.executable import which
@@ -128,21 +128,22 @@ def create(parser, args):
url = args.url
# Try to deduce name and version of the new package from the URL
- name, version = spack.url.parse_name_and_version(url)
-
- # Use a user-supplied name if one is present
- name = kwargs.get(args, 'alternate_name', False)
- if args.name:
- name = args.name
-
+ version = spack.url.parse_version(url)
if not version:
tty.die("Couldn't guess a version string from %s." % url)
- if not name:
- tty.die("Couldn't guess a name for this package. Try running:", "",
- "spack create --name <name> <url>")
-
- if not spack.db.valid_name(name):
+ # Try to guess a name. If it doesn't work, allow the user to override.
+ if args.alternate_name:
+ name = args.alternate_name
+ else:
+ try:
+ name = spack.url.parse_name(url, version)
+ except spack.url.UndetectableNameError, e:
+ # Use a user-supplied name if one is present
+ tty.die("Couldn't guess a name for this package. Try running:", "",
+ "spack create --name <name> <url>")
+
+ if not valid_module_name(name):
tty.die("Package name can only contain A-Z, a-z, 0-9, '_' and '-'")
tty.msg("This looks like a URL for %s version %s." % (name, version))