|
4 | 4 | check_all, is_api_lt, is_ndk) |
5 | 5 | from pythonforandroid.logger import logger, info |
6 | 6 | from pythonforandroid.util import ensure_dir, walk_valid_filens |
7 | | -from os.path import exists, join, realpath, basename |
| 7 | +from os.path import exists, join, realpath, dirname |
8 | 8 | from os import environ, listdir, walk |
9 | 9 | import glob |
10 | 10 | import sh |
|
18 | 18 | 'ensurepip', |
19 | 19 | 'idlelib', |
20 | 20 | 'tkinter', |
21 | | - } |
| 21 | +} |
22 | 22 |
|
23 | 23 | STDLIB_FILEN_BLACKLIST = [ |
24 | 24 | '*.pyc', |
25 | 25 | '*.exe', |
26 | 26 | '*.whl', |
27 | | - ] |
| 27 | +] |
28 | 28 |
|
| 29 | +# TODO: Move to a generic location so all recipes use the same blacklist |
| 30 | +SITE_PACKAGES_DIR_BLACKLIST = { |
| 31 | + '__pycache__', |
| 32 | + 'tests' |
| 33 | +} |
| 34 | + |
| 35 | +SITE_PACKAGES_FILEN_BLACKLIST = [] |
29 | 36 |
|
30 | 37 |
|
31 | 38 | class Python3Recipe(TargetPythonRecipe): |
@@ -151,12 +158,19 @@ def create_python_bundle(self, dirn, arch): |
151 | 158 | # zip up the standard library |
152 | 159 | stdlib_zip = join(dirn, 'stdlib.zip') |
153 | 160 | with current_directory(join(self.get_build_dir(arch.arch), 'Lib')): |
154 | | - stdlib_filens = walk_valid_filens('.', STDLIB_DIR_BLACKLIST, STDLIB_FILEN_BLACKLIST) |
| 161 | + stdlib_filens = walk_valid_filens( |
| 162 | + '.', STDLIB_DIR_BLACKLIST, STDLIB_FILEN_BLACKLIST) |
155 | 163 | shprint(sh.zip, stdlib_zip, *stdlib_filens) |
156 | 164 |
|
157 | 165 | # copy the site-packages into place |
158 | | - shprint(sh.cp, '-r', self.ctx.get_python_install_dir(), |
159 | | - join(dirn, 'site-packages')) |
| 166 | + ensure_dir(join(dirn, 'site-packages')) |
| 167 | + # TODO: Improve the API around walking and copying the files |
| 168 | + with current_directory(self.ctx.get_python_install_dir()): |
| 169 | + filens = list(walk_valid_filens( |
| 170 | + '.', SITE_PACKAGES_DIR_BLACKLIST, SITE_PACKAGES_FILEN_BLACKLIST)) |
| 171 | + for filen in filens: |
| 172 | + ensure_dir(join(dirn, 'site-packages', dirname(filen))) |
| 173 | + sh.cp(filen, join(dirn, 'site-packages', filen)) |
160 | 174 |
|
161 | 175 | # copy the python .so files into place |
162 | 176 | python_build_dir = join(self.get_build_dir(arch.arch), |
|
0 commit comments