@@ -670,11 +670,11 @@ def test_setup_requires_override_nspkg(self, use_setup_cfg):
670
670
671
671
with contexts .save_pkg_resources_state ():
672
672
with contexts .tempdir () as temp_dir :
673
- foobar_1_archive = os .path .join (temp_dir , 'foo.bar -0.1.tar.gz' )
674
- make_nspkg_sdist (foobar_1_archive , 'foo.bar ' , '0.1' )
673
+ foobar_1_archive = os .path .join (temp_dir , 'foo_bar -0.1.tar.gz' )
674
+ make_nspkg_sdist (foobar_1_archive , 'foo_bar ' , '0.1' )
675
675
# Now actually go ahead an extract to the temp dir and add the
676
676
# extracted path to sys.path so foo.bar v0.1 is importable
677
- foobar_1_dir = os .path .join (temp_dir , 'foo.bar -0.1' )
677
+ foobar_1_dir = os .path .join (temp_dir , 'foo_bar -0.1' )
678
678
os .mkdir (foobar_1_dir )
679
679
with tarfile .open (foobar_1_archive ) as tf :
680
680
tf .extraction_filter = lambda member , path : member
@@ -697,14 +697,14 @@ def test_setup_requires_override_nspkg(self, use_setup_cfg):
697
697
len(foo.__path__) == 2):
698
698
print('FAIL')
699
699
700
- if 'foo.bar -0.2' not in foo.__path__[0]:
700
+ if 'foo_bar -0.2' not in foo.__path__[0]:
701
701
print('FAIL')
702
702
"""
703
703
)
704
704
705
705
test_pkg = create_setup_requires_package (
706
706
temp_dir ,
707
- 'foo.bar ' ,
707
+ 'foo_bar ' ,
708
708
'0.2' ,
709
709
make_nspkg_sdist ,
710
710
template ,
@@ -1120,8 +1120,10 @@ def make_nspkg_sdist(dist_path, distname, version):
1120
1120
package with the same name as distname. The top-level package is
1121
1121
designated a namespace package).
1122
1122
"""
1123
-
1124
- parts = distname .split ('.' )
1123
+ # The project name might not contain periods. Replace dashes and
1124
+ # underscores with periods before constructing the namespace.
1125
+ namespace = distname .replace ('-' , '.' ).replace ('_' , '.' )
1126
+ parts = namespace .split ('.' )
1125
1127
nspackage = parts [0 ]
1126
1128
1127
1129
packages = ['.' .join (parts [:idx ]) for idx in range (1 , len (parts ) + 1 )]
0 commit comments