Skip to content

Commit

Permalink
Ensure editable builder generate valid scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
akeeman authored Oct 16, 2020
1 parent 42c8ccc commit 66d29f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion poetry/masonry/builders/editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _add_scripts(self):
for script in scripts:
name, script = script.split(" = ")
module, callable_ = script.split(":")
callable_holder = callable_.rsplit(".", 1)[0]
callable_holder = callable_.split(".", 1)[0]

script_file = scripts_path.joinpath(name)
self._debug(
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/simple_project/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ python = "~2.7 || ^3.4"
[tool.poetry.scripts]
foo = "foo:bar"
baz = "bar:baz.boom.bim"
fox = "fuz.foo:bar.baz"
16 changes: 14 additions & 2 deletions tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_

assert "poetry" == dist_info.joinpath("INSTALLER").read_text()
assert (
"[console_scripts]\nbaz=bar:baz.boom.bim\nfoo=foo:bar\n\n"
"[console_scripts]\nbaz=bar:baz.boom.bim\nfoo=foo:bar\nfox=fuz.foo:bar.baz\n\n"
== dist_info.joinpath("entry_points.txt").read_text()
)

Expand Down Expand Up @@ -140,7 +140,7 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_

baz_script = """\
#!{python}
from bar import baz.boom
from bar import baz
if __name__ == '__main__':
baz.boom.bim()
Expand All @@ -162,6 +162,18 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_

assert foo_script == tmp_venv._bin_dir.joinpath("foo").read_text()

fox_script = """\
#!{python}
from fuz.foo import bar
if __name__ == '__main__':
bar.baz()
""".format(
python=tmp_venv._bin("python")
)

assert fox_script == tmp_venv._bin_dir.joinpath("fox").read_text()


def test_builder_falls_back_on_setup_and_pip_for_packages_with_build_scripts(
extended_poetry,
Expand Down

0 comments on commit 66d29f6

Please sign in to comment.