Remove .dist-info directories except for specified packages. Generally these are not needed in the final CLI executable, unless specified via keep_packages.
(dirname, keep_packages)
| 102 | |
| 103 | |
| 104 | def remove_dist_info_directories(dirname, keep_packages): |
| 105 | """Remove .dist-info directories except for specified packages. |
| 106 | Generally these are not needed in the final CLI executable, |
| 107 | unless specified via keep_packages. |
| 108 | """ |
| 109 | for item in os.listdir(dirname): |
| 110 | if item.endswith('.dist-info') and not any( |
| 111 | package in item for package in keep_packages |
| 112 | ): |
| 113 | shutil.rmtree(os.path.join(dirname, item)) |