diff --git a/poetry/masonry/builders/editable.py b/poetry/masonry/builders/editable.py
index 21a5d049f08..5c32fcb57e1 100644
--- a/poetry/masonry/builders/editable.py
+++ b/poetry/masonry/builders/editable.py
@@ -43,16 +43,24 @@ def build(self):
)
if self._package.build_script:
- self._debug(
- " - Falling back on using a setup.py"
- )
- return self._setup_build()
+ if self._package.build_should_generate_setup():
+ self._debug(
+ " - Falling back on using a setup.py"
+ )
+
+ return self._setup_build()
+
+ self._run_build_script(self._package.build_script)
added_files = []
added_files += self._add_pth()
added_files += self._add_scripts()
self._add_dist_info(added_files)
+ def _run_build_script(self, build_script):
+ self._debug(" - Executing build script: {}".format(build_script))
+ self._env.run("python", str(self._path.joinpath(build_script)), call=True)
+
def _setup_build(self):
builder = SdistBuilder(self._poetry)
setup = self._path / "setup.py"
diff --git a/tests/fixtures/extended_project_without_setup/README.rst b/tests/fixtures/extended_project_without_setup/README.rst
new file mode 100644
index 00000000000..f7fe15470f9
--- /dev/null
+++ b/tests/fixtures/extended_project_without_setup/README.rst
@@ -0,0 +1,2 @@
+My Package
+==========
diff --git a/tests/fixtures/extended_project_without_setup/build.py b/tests/fixtures/extended_project_without_setup/build.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/fixtures/extended_project_without_setup/extended_project/__init__.py b/tests/fixtures/extended_project_without_setup/extended_project/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/fixtures/extended_project_without_setup/pyproject.toml b/tests/fixtures/extended_project_without_setup/pyproject.toml
new file mode 100644
index 00000000000..42375c03c25
--- /dev/null
+++ b/tests/fixtures/extended_project_without_setup/pyproject.toml
@@ -0,0 +1,32 @@
+[tool.poetry]
+name = "extended-project"
+version = "1.2.3"
+description = "Some description."
+authors = [
+ "Sébastien Eustace "
+]
+license = "MIT"
+
+readme = "README.rst"
+
+homepage = "https://python-poetry.org"
+repository = "https://github.com/python-poetry/poetry"
+documentation = "https://python-poetry.org/docs"
+
+keywords = ["packaging", "dependency", "poetry"]
+
+classifiers = [
+ "Topic :: Software Development :: Build Tools",
+ "Topic :: Software Development :: Libraries :: Python Modules"
+]
+
+[tool.poetry.build]
+script = "build.py"
+generate-setup-file = false
+
+# Requirements
+[tool.poetry.dependencies]
+python = "~2.7 || ^3.4"
+
+[tool.poetry.scripts]
+foo = "foo:bar"
diff --git a/tests/masonry/builders/test_editable_builder.py b/tests/masonry/builders/test_editable_builder.py
index 05688f5a6bb..e2aac5beb41 100644
--- a/tests/masonry/builders/test_editable_builder.py
+++ b/tests/masonry/builders/test_editable_builder.py
@@ -42,6 +42,17 @@ def extended_poetry():
return poetry
+@pytest.fixture()
+def extended_without_setup_poetry():
+ poetry = Factory().create_poetry(
+ Path(__file__).parent.parent.parent
+ / "fixtures"
+ / "extended_project_without_setup"
+ )
+
+ return poetry
+
+
@pytest.fixture()
def env_manager(simple_poetry):
return EnvManager(simple_poetry)
@@ -194,3 +205,14 @@ def test_builder_installs_proper_files_when_packages_configured(
assert paths.issubset(expected)
assert len(paths) == len(expected)
+
+
+def test_builder_should_execute_build_scripts(extended_without_setup_poetry):
+ env = MockEnv(path=Path("/foo"))
+ builder = EditableBuilder(extended_without_setup_poetry, env, NullIO())
+
+ builder.build()
+
+ assert [
+ ["python", str(extended_without_setup_poetry.file.parent / "build.py")]
+ ] == env.executed