Skip to content

Commit

Permalink
update sys_paths default insert index; update download_python
Browse files Browse the repository at this point in the history
  • Loading branch information
lidong committed Aug 7, 2024
1 parent daf5e90 commit 1ad381e
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 88 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [zipapps](https://github.com/ClericPy/zipapps)

[![PyPI](https://img.shields.io/pypi/v/zipapps?style=plastic)](https://pypi.org/project/zipapps/)[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/clericpy/zipapps/pythonpackage.yml)](https://github.com/ClericPy/zipapps/actions)![PyPI - Wheel](https://img.shields.io/pypi/wheel/zipapps?style=plastic)![PyPI - Downloads](https://img.shields.io/pypi/dm/zipapps?style=plastic)![PyPI - License](https://img.shields.io/pypi/l/zipapps?style=plastic)
[![PyPI](https://img.shields.io/pypi/v/zipapps?style=plastic)](https://pypi.org/project/zipapps/)[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/clericpy/zipapps/pythonpackage.yml)](https://github.com/ClericPy/zipapps/actions)![PyPI - Wheel](https://img.shields.io/pypi/wheel/zipapps?style=plastic)![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=zipapps)![PyPI - Downloads](https://img.shields.io/pypi/dm/zipapps?style=plastic)![PyPI - License](https://img.shields.io/pypi/l/zipapps?style=plastic)

[Changelogs](https://github.com/ClericPy/zipapps/blob/master/changelog.md)

Expand Down
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@

# Changelogs

- 2024.08.07
- [**Compatible WARNING**]: update `sys_paths` insert index from `-1` to `0`
- disable `--download-python`, use `python -m zipapps.download_python` instead
- add `-a/--auto`
- auto download the latest version matched the current platform: x86_64+install_only
- `python -m zipapps.download_python -a`
- add `-k/--keywords`, filt with keywords split by `,`
- `python -m zipapps.download_python -a -k 3.11`
- add `-u/--unzip`, unzip the `.tar.gz`
- `python -m zipapps.download_python -a -k 3.11 -u`
- download and unzip the `.tar.gz`
- 2024.06.04
- add arg `--download-python`: interactive download standalone python interpreter (https://www.github.com/indygreg/python-build-standalone)
- custom `--rm-patterns` to remove useless files . fixed #28 #29
Expand Down
16 changes: 6 additions & 10 deletions test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,19 @@ def test_includes():
def test_pip_args():
# test pip_args
_clean_paths()
_, stderr_output = subprocess.Popen(
[sys.executable, "-c", "import bottle"],
stdout, _ = subprocess.Popen(
[sys.executable, "-c", "import bottle;print(bottle.__file__)"],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
).communicate()
assert (
b"No module named" in stderr_output
), "check init failed, bottle should not be installed"
assert b'app.pyz' not in stdout, "test pip_args failed %s" % stdout
app_path = create_app(pip_args=["bottle"])
_, stderr_output = subprocess.Popen(
[sys.executable, str(app_path), "-c", "import bottle"],
stdout, _ = subprocess.Popen(
[sys.executable, str(app_path), "-c", "import bottle;print(bottle.__file__)"],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
).communicate()
assert stderr_output == b"", "test pip_args failed"
assert b'app.pyz' in stdout, "test pip_args failed %s" % stdout


def test_cache_path():
Expand Down Expand Up @@ -626,8 +624,6 @@ def test_sys_paths():
# pip install by given --target
args = [sys.executable, "-m", "pip", "install", "bottle", "-t", "./bottle_env"]
subprocess.Popen(args=args).wait()
mock_requirement = Path("_requirements.txt")
mock_requirement.write_text("bottle")
create_app(sys_paths="$SELF/bottle_env")
output = subprocess.check_output(
[sys.executable, "app.pyz", "-c", "import bottle;print(bottle.__file__)"]
Expand Down
8 changes: 3 additions & 5 deletions zipapps/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def main():
"--python-path",
default="",
dest="sys_paths",
help="Paths be insert to sys.path[-1] while running."
help="Paths be insert to sys.path[0] while running."
" Support $TEMP/$HOME/$SELF/$PID/$CWD prefix, separated by commas.",
)
parser.add_argument(
Expand Down Expand Up @@ -395,7 +395,7 @@ def main():
"--download-python",
action="store_true",
dest="download_python",
help=f'Download standalone python from "{DOWNLOAD_PYTHON_URL}"',
help=f'(please use `python -m zipapps.download_python` instead). Download standalone python from "{DOWNLOAD_PYTHON_URL}"',
)
parser.add_argument(
"--rm-patterns",
Expand All @@ -409,9 +409,7 @@ def main():
return
args, pip_args = parser.parse_known_args()
if args.download_python:
from .download_python import download_python

return download_python()
raise ValueError("please use `python -m zipapps.download_python` instead")
elif args.download_pip_pyz:
return download_pip_pyz(args.download_pip_pyz)
if args.quite_mode:
Expand Down
Loading

0 comments on commit 1ad381e

Please sign in to comment.