diff --git a/platformio/package/manager/_download.py b/platformio/package/manager/_download.py index 2ab8c143..01be36aa 100644 --- a/platformio/package/manager/_download.py +++ b/platformio/package/manager/_download.py @@ -61,7 +61,7 @@ class PackageManagerDownloadMixin(object): return dl_path with_progress = not silent and not app.is_disabled_progressbar() - tmp_path = tempfile.mkstemp(dir=self.get_download_dir())[1] + tmp_fd, tmp_path = tempfile.mkstemp(dir=self.get_download_dir()) try: with LockFile(dl_path): try: @@ -86,9 +86,11 @@ class PackageManagerDownloadMixin(object): raise e if checksum: fd.verify(checksum) - shutil.copyfile(tmp_path, dl_path) + os.close(tmp_fd) + os.rename(tmp_path, dl_path) finally: if os.path.isfile(tmp_path): + os.close(tmp_fd) os.remove(tmp_path) assert os.path.isfile(dl_path) diff --git a/platformio/package/manager/_registry.py b/platformio/package/manager/_registry.py index cdd46cd0..a14bde98 100644 --- a/platformio/package/manager/_registry.py +++ b/platformio/package/manager/_registry.py @@ -64,6 +64,10 @@ class RegistryFileMirrorsIterator(object): response.headers.get("X-PIO-Content-SHA256"), ) + def next(self): + """ For Python 2 compatibility """ + return self.__next__() + def get_http_client(self): if self._base_url not in RegistryFileMirrorsIterator.HTTP_CLIENT_INSTANCES: RegistryFileMirrorsIterator.HTTP_CLIENT_INSTANCES[ diff --git a/tests/package/test_manager.py b/tests/package/test_manager.py index 7d3cb070..2d8a7b14 100644 --- a/tests/package/test_manager.py +++ b/tests/package/test_manager.py @@ -71,7 +71,7 @@ def test_find_pkg_root(isolated_pio_core, tmpdir_factory): # library manager should create "library.json" lm = LibraryPackageManager() spec = PackageSpec("custom-name@1.0.0") - pkg_root = lm.find_pkg_root(pkg_dir, spec) + pkg_root = lm.find_pkg_root(str(pkg_dir), spec) manifest_path = os.path.join(pkg_root, "library.json") assert os.path.realpath(str(root_dir)) == os.path.realpath(pkg_root) assert os.path.isfile(manifest_path)