|
34 | 34 |
|
35 | 35 |
|
36 | 36 | import functools
|
| 37 | +from io import open # needed for python 2 |
37 | 38 | import os
|
38 | 39 | import shutil
|
39 | 40 | import subprocess
|
40 | 41 | import sys
|
41 | 42 | import tarfile
|
42 | 43 | import tempfile
|
43 | 44 | import time
|
44 |
| -import zipfile |
45 |
| -from io import open # needed for python 2 |
46 | 45 | from urllib.parse import unquote as urlunquote
|
47 | 46 | from urllib.parse import urlparse
|
| 47 | +import zipfile |
48 | 48 |
|
49 | 49 | import toml
|
50 | 50 | import build.util
|
51 | 51 |
|
| 52 | +from pythonforandroid.util import rmdir, ensure_dir |
| 53 | + |
52 | 54 |
|
53 | 55 | def transform_dep_for_pip(dependency):
|
54 | 56 | if dependency.find("@") > 0 and (
|
@@ -113,7 +115,7 @@ def extract_metainfo_files_from_package(
|
113 | 115 |
|
114 | 116 | _extract_metainfo_files_from_package_unsafe(package, output_folder)
|
115 | 117 | finally:
|
116 |
| - shutil.rmtree(temp_folder) |
| 118 | + rmdir(temp_folder) |
117 | 119 |
|
118 | 120 |
|
119 | 121 | def _get_system_python_executable():
|
@@ -314,7 +316,7 @@ def get_package_as_folder(dependency):
|
314 | 316 | )
|
315 | 317 |
|
316 | 318 | # Create download subfolder:
|
317 |
| - os.mkdir(os.path.join(venv_path, "download")) |
| 319 | + ensure_dir(os.path.join(venv_path, "download")) |
318 | 320 |
|
319 | 321 | # Write a requirements.txt with our package and download:
|
320 | 322 | with open(os.path.join(venv_path, "requirements.txt"),
|
@@ -394,11 +396,11 @@ def to_unicode(s): # Needed for Python 2.
|
394 | 396 | # Copy result to new dedicated folder so we can throw away
|
395 | 397 | # our entire virtualenv nonsense after returning:
|
396 | 398 | result_path = tempfile.mkdtemp()
|
397 |
| - shutil.rmtree(result_path) |
| 399 | + rmdir(result_path) |
398 | 400 | shutil.copytree(result_folder_or_file, result_path)
|
399 | 401 | return (dl_type, result_path)
|
400 | 402 | finally:
|
401 |
| - shutil.rmtree(venv_parent) |
| 403 | + rmdir(venv_parent) |
402 | 404 |
|
403 | 405 |
|
404 | 406 | def _extract_metainfo_files_from_package_unsafe(
|
@@ -458,7 +460,7 @@ def _extract_metainfo_files_from_package_unsafe(
|
458 | 460 | shutil.copyfile(metadata_path, os.path.join(output_path, "METADATA"))
|
459 | 461 | finally:
|
460 | 462 | if clean_up_path:
|
461 |
| - shutil.rmtree(path) |
| 463 | + rmdir(path) |
462 | 464 |
|
463 | 465 |
|
464 | 466 | def is_filesystem_path(dep):
|
@@ -576,7 +578,7 @@ def _extract_info_from_package(dependency,
|
576 | 578 |
|
577 | 579 | return list(set(requirements)) # remove duplicates
|
578 | 580 | finally:
|
579 |
| - shutil.rmtree(output_folder) |
| 581 | + rmdir(output_folder) |
580 | 582 |
|
581 | 583 |
|
582 | 584 | package_name_cache = dict()
|
|
0 commit comments