|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 | import os
|
| 16 | +import tempfile |
16 | 17 | from datetime import datetime
|
17 | 18 |
|
18 | 19 | import click
|
19 | 20 |
|
| 21 | +from platformio import fs |
20 | 22 | from platformio.clients.registry import RegistryClient
|
| 23 | +from platformio.compat import ensure_python3 |
21 | 24 | from platformio.package.meta import PackageSpec, PackageType
|
22 | 25 | from platformio.package.pack import PackagePacker
|
23 | 26 |
|
@@ -77,13 +80,16 @@ def package_pack(package, output):
|
77 | 80 | help="Notify by email when package is processed",
|
78 | 81 | )
|
79 | 82 | def package_publish(package, owner, released_at, private, notify):
|
80 |
| - p = PackagePacker(package) |
81 |
| - archive_path = p.pack() |
82 |
| - response = RegistryClient().publish_package( |
83 |
| - archive_path, owner, released_at, private, notify |
84 |
| - ) |
85 |
| - os.remove(archive_path) |
86 |
| - click.secho(response.get("message"), fg="green") |
| 83 | + assert ensure_python3() |
| 84 | + with tempfile.TemporaryDirectory() as tmp_dir: # pylint: disable=no-member |
| 85 | + with fs.cd(tmp_dir): |
| 86 | + p = PackagePacker(package) |
| 87 | + archive_path = p.pack() |
| 88 | + response = RegistryClient().publish_package( |
| 89 | + archive_path, owner, released_at, private, notify |
| 90 | + ) |
| 91 | + os.remove(archive_path) |
| 92 | + click.secho(response.get("message"), fg="green") |
87 | 93 |
|
88 | 94 |
|
89 | 95 | @cli.command("unpublish", short_help="Remove a pushed package from the registry")
|
|
0 commit comments