From b759d86fdad954899b406e73547dff5281d4f978 Mon Sep 17 00:00:00 2001 From: Facundo Batista Date: Sat, 9 Sep 2023 13:30:11 -0300 Subject: [PATCH] Store the entrypoint information as a list. --- pyempaq/main.py | 2 +- tests/test_integration.py | 24 ++++++++++++++++++++++++ tests/test_main.py | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pyempaq/main.py b/pyempaq/main.py index c09de3c..a748c10 100644 --- a/pyempaq/main.py +++ b/pyempaq/main.py @@ -172,7 +172,7 @@ def prepare_metadata(origdir: pathlib.Path, config: Config): metadata["exec_value"] = str(config.exec.module) elif config.exec.entrypoint is not None: metadata["exec_style"] = "entrypoint" - metadata["exec_value"] = str(config.exec.entrypoint) + metadata["exec_value"] = config.exec.entrypoint # if dependencies, store them just as another requirement file (save it inside the project, # but using an unique name to not overwrite anything) diff --git a/tests/test_integration.py b/tests/test_integration.py index 56137bd..295be7a 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -252,3 +252,27 @@ def test_ephemeral_install_run_ok(tmp_path, monkeypatch): _unpack(packed_filepath, tmp_path, extra_env={"PYEMPAQ_EPHEMERAL": "1"}, expected_rc=0) project_install_dir = [d for d in tmp_path.iterdir() if d.name.startswith("testproject")] assert not project_install_dir + + +def test_using_entrypoint(tmp_path, monkeypatch): + """Test full cycle using entrypoint as exec method.""" + projectpath = tmp_path / "fakeproject" + projectpath.mkdir() + (projectpath / "main.py").write_text(textwrap.dedent(""" + import sys + print(sys.argv[1]) + """)) + conf = { + "name": "testproject", + "basedir": str(projectpath), + "include": ["main.py"], + "exec": { + "entrypoint": ["main.py", "crazyarg"] + }, + } + + packed_filepath = _pack(projectpath, monkeypatch, yaml.safe_dump(conf)) + proc, _ = _unpack(packed_filepath, tmp_path) + + assert proc.returncode == 0 + assert proc.stdout.strip() == "crazyarg" diff --git a/tests/test_main.py b/tests/test_main.py index c3a6f1e..f8831bb 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -523,7 +523,7 @@ def test_metadata_base_exec_entrypoint(tmp_path): "project_name": "testproject", "exec_default_args": [], "exec_style": "entrypoint", - "exec_value": "['foo', 'bar']", + "exec_value": ['foo', 'bar'], "unpack_restrictions": {}, }