@@ -121,6 +121,37 @@ def test_byte_compile_optimized(self):
121121 found = os .listdir (os .path .join (cmd .build_lib , '__pycache__' ))
122122 self .assertEqual (sorted (found ), ['boiledeggs.%s.pyo' % imp .get_tag ()])
123123
124+ def test_dir_in_package_data (self ):
125+ """
126+ A directory in package_data should not be added to the filelist.
127+ """
128+ # See bug 19286
129+ sources = self .mkdtemp ()
130+ pkg_dir = os .path .join (sources , "pkg" )
131+
132+ os .mkdir (pkg_dir )
133+ open (os .path .join (pkg_dir , "__init__.py" ), "w" ).close ()
134+
135+ docdir = os .path .join (pkg_dir , "doc" )
136+ os .mkdir (docdir )
137+ open (os .path .join (docdir , "testfile" ), "w" ).close ()
138+
139+ # create the directory that could be incorrectly detected as a file
140+ os .mkdir (os .path .join (docdir , 'otherdir' ))
141+
142+ os .chdir (sources )
143+ dist = Distribution ({"packages" : ["pkg" ],
144+ "package_data" : {"pkg" : ["doc/*" ]}})
145+ # script_name need not exist, it just need to be initialized
146+ dist .script_name = os .path .join (sources , "setup.py" )
147+ dist .script_args = ["build" ]
148+ dist .parse_command_line ()
149+
150+ try :
151+ dist .run_commands ()
152+ except DistutilsFileError :
153+ self .fail ("failed package_data when data dir includes a dir" )
154+
124155 def test_dont_write_bytecode (self ):
125156 # makes sure byte_compile is not used
126157 dist = self .create_dist ()[1 ]
0 commit comments