Repository: spack/spack

Issue:
Error when using spack create with backports.ssl_match_hostname
When using `spack create` with backports.ssl_match_hostname, the following error occurs:

```
spack -d -v create https://pypi.io/packages/source/b/backports.ssl_match_hostname/backports.ssl_match_hostname-3.5.0.1.tar.gz
==> Error: Unknown namespace: backports
```


Discussion:
I'll take a look at this. The problem is that I don't think Spack knows how to handle a package name with a period in the middle. In the meantime, you can specify the name you want as a quick workaround:

```
$ spack create --name py-ssl-match-hostname https://pypi.io/packages/source/b/backports.ssl_match_hostname/backports.ssl_match_hostname-3.5.0.1.tar.gz
```


Resolving patch:
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -434,7 +434,6 @@ def create(parser, args):
     # Figure out a name and repo for the package.
     name, version = guess_name_and_version(url, args)
     spec = Spec(name)
-    name = spec.name.lower()  # factors out namespace, if any
     repo = find_repository(spec, args)
 
     tty.msg("This looks like a URL for %s version %s" % (name, version))
diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py
--- a/lib/spack/spack/url.py
+++ b/lib/spack/spack/url.py
@@ -305,6 +305,10 @@ def parse_name_offset(path, v=None):
             if match_string is stem:
                 start += offset
 
+            # package names should be lowercase and separated by dashes.
+            name = name.lower()
+            name = re.sub('[_.]', '-', name)
+
             return name, start, len(name)
 
     raise UndetectableNameError(path)


Test patch:
diff --git a/lib/spack/spack/test/url_parse.py b/lib/spack/spack/test/url_parse.py
--- a/lib/spack/spack/test/url_parse.py
+++ b/lib/spack/spack/test/url_parse.py
@@ -59,10 +59,10 @@ def test_wwwoffle_version(self):
 
     def test_version_sourceforge_download(self):
         self.check(
-            'foo_bar', '1.21',
+            'foo-bar', '1.21',
             'http://sourceforge.net/foo_bar-1.21.tar.gz/download')
         self.check(
-            'foo_bar', '1.21',
+            'foo-bar', '1.21',
             'http://sf.net/foo_bar-1.21.tar.gz/download')
 
     def test_no_version(self):
@@ -71,7 +71,7 @@ def test_no_version(self):
 
     def test_version_all_dots(self):
         self.check(
-            'foo.bar.la', '1.14', 'http://example.com/foo.bar.la.1.14.zip')
+            'foo-bar-la', '1.14', 'http://example.com/foo.bar.la.1.14.zip')
 
     def test_version_underscore_separator(self):
         self.check(
@@ -136,12 +136,12 @@ def test_version_internal_dash(self):
 
     def test_version_single_digit(self):
         self.check(
-            'foo_bar', '45',
+            'foo-bar', '45',
             'http://example.com/foo_bar.45.tar.gz')
 
     def test_noseparator_single_digit(self):
         self.check(
-            'foo_bar', '45',
+            'foo-bar', '45',
             'http://example.com/foo_bar45.tar.gz')
 
     def test_version_developer_that_hates_us_format(self):
@@ -151,7 +151,7 @@ def test_version_developer_that_hates_us_format(self):
 
     def test_version_regular(self):
         self.check(
-            'foo_bar', '1.21',
+            'foo-bar', '1.21',
             'http://example.com/foo_bar-1.21.tar.gz')
 
     def test_version_github(self):
@@ -216,7 +216,7 @@ def test_debian_style_2(self):
 
     def test_imagemagick_style(self):
         self.check(
-            'ImageMagick', '6.7.5-7',
+            'imagemagick', '6.7.5-7',
 
             'http://downloads.sf.net/project/machomebrew/mirror/ImageMagick-6.7.5-7.tar.bz2')
 
@@ -247,7 +247,7 @@ def test_openssl_version(self):
 
     def test_xaw3d_version(self):
         self.check(
-            'Xaw3d', '1.5E',
+            'xaw3d', '1.5E',
             'ftp://ftp.visi.com/users/hawkeyd/X/Xaw3d-1.5E.tar.gz')
 
     def test_fann_version(self):
@@ -324,5 +324,5 @@ def test_gcc_version_precedence(self):
 
     def test_github_raw_url(self):
         self.check(
-            'PowerParser', '2.0.7',
+            'powerparser', '2.0.7',
             'https://github.com/losalamos/CLAMR/blob/packages/PowerParser_v2.0.7.tgz?raw=true')