@@ -138,14 +138,21 @@ def _compile_importlib(self):
138
138
bin_site = self .fixtures .enter_context (os_helper .temp_dir ())
139
139
c_resources = pathlib .Path (bin_site , 'c_resources' )
140
140
sources = pathlib .Path (resources .__file__ ).parent
141
- shutil .copytree (sources , c_resources , ignore = lambda * _ : ['__pycache__' ])
142
141
143
- for dirpath , _ , filenames in os .walk (c_resources ):
142
+ for dirpath , dirnames , filenames in os .walk (sources ):
143
+ try :
144
+ dirnames .remove ('__pycache__' )
145
+ except ValueError :
146
+ pass
147
+ source_dir_path = pathlib .Path (dirpath )
148
+ dir_relpath = pathlib .Path (source_dir_path ).relative_to (sources )
149
+ c_dir_path = c_resources .joinpath (dir_relpath )
144
150
for filename in filenames :
145
- source_path = pathlib .Path (dirpath ) / filename
146
- cfile = source_path .with_suffix ('.pyc' )
147
- py_compile .compile (source_path , cfile )
148
- pathlib .Path .unlink (source_path )
151
+ if filename .endswith ('.py' ):
152
+ source_path = source_dir_path / filename
153
+ cfile = c_dir_path .joinpath (filename ).with_suffix ('.pyc' )
154
+ py_compile .compile (source_path , cfile )
155
+ print (source_path , cfile )
149
156
self .fixtures .enter_context (import_helper .DirsOnSysPath (bin_site ))
150
157
151
158
def test_implicit_files_with_compiled_importlib (self ):
0 commit comments