Skip to content

Commit

Permalink
Merge pull request #95 from facundobatista/store-entrypoint-as-list
Browse files Browse the repository at this point in the history
Store the entrypoint information as a list.
  • Loading branch information
facundobatista authored Sep 9, 2023
2 parents 9032fae + b759d86 commit d60e84c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyempaq/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
}

Expand Down

0 comments on commit d60e84c

Please sign in to comment.