aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author苏向夜 <fu050409@163.com>2024-02-28 22:53:02 +0800
committer苏向夜 <fu050409@163.com>2024-02-28 22:53:02 +0800
commit5ecf879bc72e73883d5a1f7bb1c748118fa5d9ce (patch)
tree7f5e30b85b2e5412922a5bd733c151ded352cd94 /src
parent457cb63e36e2696063d8dbd281fd5eacd1954f1a (diff)
downloadipm-5ecf879bc72e73883d5a1f7bb1c748118fa5d9ce.tar.gz
ipm-5ecf879bc72e73883d5a1f7bb1c748118fa5d9ce.zip
fix(freeze): fix deprecated warning
Diffstat (limited to 'src')
-rw-r--r--src/ipm/api.py9
-rw-r--r--src/ipm/typing.py3
-rw-r--r--src/ipm/utils/_freeze.py2
-rw-r--r--src/ipm/utils/freeze.py2
4 files changed, 13 insertions, 3 deletions
diff --git a/src/ipm/api.py b/src/ipm/api.py
index 6745b04..60dc05b 100644
--- a/src/ipm/api.py
+++ b/src/ipm/api.py
@@ -80,6 +80,15 @@ def init(source_path: StrPath, force: bool = False, echo: bool = False) -> bool:
toml_file.close()
(source_path / "src").mkdir(parents=True, exist_ok=True)
+ (source_path / ".gitignores").write_text(
+ "# Initialized `.gitignores` generated by ipm.\n\n"
+ "# python\n"
+ "__pycache__/\n"
+ "*.pyc\n"
+ "# build\n"
+ "build/"
+ "dist/"
+ )
if entry_file == "0":
(source_path / "src" / "__init__.py").write_text(
"# Initialized `__init__.py` generated by ipm.\n"
diff --git a/src/ipm/typing.py b/src/ipm/typing.py
index 45591ed..0346381 100644
--- a/src/ipm/typing.py
+++ b/src/ipm/typing.py
@@ -1,5 +1,6 @@
from pathlib import Path
from typing import (
+ Union,
Literal as Literal,
List as List,
Dict as Dict,
@@ -7,7 +8,7 @@ from typing import (
AnyStr as AnyStr,
)
-StrPath = str | Path
+StrPath = Union[str, Path]
Index = Dict[Literal["index", "host", "uuid"], str]
Package = Dict[
Literal["name", "version", "description", "requirements", "dependencies"], str
diff --git a/src/ipm/utils/_freeze.py b/src/ipm/utils/_freeze.py
index 1df0f86..e1d19db 100644
--- a/src/ipm/utils/_freeze.py
+++ b/src/ipm/utils/_freeze.py
@@ -12,4 +12,4 @@ def create_tar_gz(source_folder: str, output_filepath: str) -> None:
def extract_tar_gz(input_filename: str, output_folder: str) -> None:
with tarfile.open(input_filename, "r:gz") as tar:
- tar.extractall(output_folder)
+ tar.extractall(output_folder, filter=tarfile.fully_trusted_filter)
diff --git a/src/ipm/utils/freeze.py b/src/ipm/utils/freeze.py
index 277a068..de66f57 100644
--- a/src/ipm/utils/freeze.py
+++ b/src/ipm/utils/freeze.py
@@ -31,7 +31,7 @@ def build_ipk(ipk: InfiniProject, echo: bool = False) -> InfiniFrozenPackage:
update("复制工程文件...", echo)
shutil.copytree(src_path, build_dir / "src")
shutil.copy2(ipk.source_path / "infini.toml", build_dir / "infini.toml")
- success("工程文件复制完毕.")
+ success("工程文件复制完毕.", echo)
update("打包 [bold green]ipk[/bold green]文件...", echo)
_freeze.create_tar_gz(