File tree 1 file changed +7
-8
lines changed
Lib/test/test_importlib/resources
1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -150,18 +150,17 @@ def create_zip_from_directory(source_dir, zip_filename):
150
150
def _compile_importlib (self ):
151
151
"""
152
152
Make a compiled-only copy of the importlib resources package.
153
+
154
+ Currently only code is copied, as importlib resources doesn't itself
155
+ have any resources.
153
156
"""
154
157
bin_site = self .fixtures .enter_context (os_helper .temp_dir ())
155
158
c_resources = pathlib .Path (bin_site , 'c_resources' )
156
159
sources = pathlib .Path (resources .__file__ ).parent
157
- shutil .copytree (sources , c_resources , ignore = lambda * _ : ['__pycache__' ])
158
-
159
- for dirpath , _ , filenames in os .walk (c_resources ):
160
- for filename in filenames :
161
- source_path = pathlib .Path (dirpath ) / filename
162
- cfile = source_path .with_suffix ('.pyc' )
163
- py_compile .compile (source_path , cfile )
164
- pathlib .Path .unlink (source_path )
160
+
161
+ for source_path in sources .glob ('**/*.py' ):
162
+ c_path = c_resources .joinpath (source_path .relative_to (sources )).with_suffix ('.pyc' )
163
+ py_compile .compile (source_path , c_path )
165
164
self .fixtures .enter_context (import_helper .DirsOnSysPath (bin_site ))
166
165
167
166
def test_implicit_files_with_compiled_importlib (self ):
You can’t perform that action at this time.
0 commit comments