diff --git a/src/poetry_plugin_bundle/bundlers/venv_bundler.py b/src/poetry_plugin_bundle/bundlers/venv_bundler.py
index e3672ef..7a948d2 100644
--- a/src/poetry_plugin_bundle/bundlers/venv_bundler.py
+++ b/src/poetry_plugin_bundle/bundlers/venv_bundler.py
@@ -165,30 +165,37 @@ def locked_repository(self) -> LockfileRepository:
)
return False
- self._write(
- io,
- f"{message}: Installing {poetry.package.pretty_name}"
- f" ({poetry.package.pretty_version})",
- )
+ # Skip building the wheel if is_package_mode exists and is set to false
+ if hasattr(poetry, "is_package_mode") and not poetry.is_package_mode:
+ self._write(
+ io,
+ f"{message}: Skipping installation for non package project {poetry.package.pretty_name}",
+ )
+ else:
+ self._write(
+ io,
+ f"{message}: Installing {poetry.package.pretty_name}"
+ f" ({poetry.package.pretty_version})",
+ )
- # Build a wheel of the project in a temporary directory
- # and install it in the newly create virtual environment
- with TemporaryDirectory() as directory:
- try:
- wheel_name = WheelBuilder.make_in(poetry, directory=Path(directory))
- wheel = Path(directory).joinpath(wheel_name)
- package = Package(
- poetry.package.name,
- poetry.package.version,
- source_type="file",
- source_url=str(wheel),
- )
- installer.executor.execute([Install(package)])
- except ModuleOrPackageNotFound:
- warnings.append(
- "The root package was not installed because no matching module or"
- " package was found."
- )
+ # Build a wheel of the project in a temporary directory
+ # and install it in the newly create virtual environment
+ with TemporaryDirectory() as directory:
+ try:
+ wheel_name = WheelBuilder.make_in(poetry, directory=Path(directory))
+ wheel = Path(directory).joinpath(wheel_name)
+ package = Package(
+ poetry.package.name,
+ poetry.package.version,
+ source_type="file",
+ source_url=str(wheel),
+ )
+ installer.executor.execute([Install(package)])
+ except ModuleOrPackageNotFound:
+ warnings.append(
+ "The root package was not installed because no matching module or"
+ " package was found."
+ )
self._write(io, self._get_message(poetry, self._path, done=True))
diff --git a/tests/bundlers/test_venv_bundler.py b/tests/bundlers/test_venv_bundler.py
index 4cd2b27..3ddaf8f 100644
--- a/tests/bundlers/test_venv_bundler.py
+++ b/tests/bundlers/test_venv_bundler.py
@@ -395,3 +395,30 @@ def test_bundler_should_build_a_venv_at_specified_path_if_centralized_venv_exist
• Bundled simple-project (1.2.3) into {path}
"""
assert expected == io.fetch_output()
+
+
+def test_bundler_non_package_mode(
+ io: BufferedIO, tmp_venv: VirtualEnv, mocker: MockerFixture, config: Config
+) -> None:
+ poetry = Factory().create_poetry(
+ Path(__file__).parent.parent / "fixtures" / "non_package_mode"
+ )
+ poetry.set_config(config)
+
+ mocker.patch("poetry.installation.executor.Executor._execute_operation")
+
+ bundler = VenvBundler()
+ bundler.set_path(tmp_venv.path)
+ bundler.set_remove(True)
+
+ assert bundler.bundle(poetry, io)
+
+ path = str(tmp_venv.path)
+ expected = f"""\
+ • Bundling simple-project-non-package-mode (1.2.3) into {path}
+ • Bundling simple-project-non-package-mode (1.2.3) into {path}: Creating a virtual environment using Poetry-determined Python
+ • Bundling simple-project-non-package-mode (1.2.3) into {path}: Installing dependencies
+ • Bundling simple-project-non-package-mode (1.2.3) into {path}: Skipping installation for non package project simple-project-non-package-mode
+ • Bundled simple-project-non-package-mode (1.2.3) into {path}
+"""
+ assert expected == io.fetch_output()
diff --git a/tests/fixtures/non_package_mode/poetry.lock b/tests/fixtures/non_package_mode/poetry.lock
new file mode 100644
index 0000000..fb78887
--- /dev/null
+++ b/tests/fixtures/non_package_mode/poetry.lock
@@ -0,0 +1,11 @@
+# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
+package = []
+
+[metadata]
+lock-version = "2.0"
+python-versions = "~2.7 || ^3.4"
+content-hash = "ea8246031ba3d40ce95b77e8f186836ce4a26fbba7b2be93f6a2f70047c04b66"
+
+
+[metadata.files]
+foo = []
diff --git a/tests/fixtures/non_package_mode/pyproject.toml b/tests/fixtures/non_package_mode/pyproject.toml
new file mode 100644
index 0000000..0e811aa
--- /dev/null
+++ b/tests/fixtures/non_package_mode/pyproject.toml
@@ -0,0 +1,17 @@
+[tool.poetry]
+name = "simple-project-non-package-mode"
+version = "1.2.3"
+package-mode = false
+
+# Requirements
+[tool.poetry.dependencies]
+python = "~2.7 || ^3.4"
+
+
+[tool.poetry.group.dev]
+optional = true
+dependencies = {}
+
+[tool.poetry.scripts]
+foo = "foo:bar"
+baz = "bar:baz.boom.bim"