diff --git a/poetry.lock b/poetry.lock index a2ba928..a0fd24c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1535,4 +1535,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "4f4da37bfd58c8cdb1eba38239f44a0ebe60e032801f629b5cfbc797b68a6718" +content-hash = "edfe1f3976af8ff764e114676539a4cca2b4058f080e8d4b52fc26abaa759484" diff --git a/pyproject.toml b/pyproject.toml index 0d7d0a8..3e4fffe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ include = [ [tool.poetry.dependencies] python = "^3.9" -poetry = "^1.5.0" +poetry = ">=1.5.0,<3.0.0" [tool.poetry.group.dev.dependencies] pre-commit = ">=2.6" diff --git a/src/poetry_plugin_bundle/bundlers/venv_bundler.py b/src/poetry_plugin_bundle/bundlers/venv_bundler.py index ab6ddf8..d4df8e3 100644 --- a/src/poetry_plugin_bundle/bundlers/venv_bundler.py +++ b/src/poetry_plugin_bundle/bundlers/venv_bundler.py @@ -55,7 +55,16 @@ def bundle(self, poetry: Poetry, io: IO) -> bool: from cleo.io.null_io import NullIO from poetry.core.masonry.builders.wheel import WheelBuilder - from poetry.core.masonry.utils.module import ModuleOrPackageNotFound + + try: + from poetry.core.masonry.utils.module import ( # type: ignore[attr-defined] + ModuleOrPackageNotFoundError, + ) + except ImportError: + # poetry-core < 2.0 + from poetry.core.masonry.utils.module import ( + ModuleOrPackageNotFound as ModuleOrPackageNotFoundError, + ) from poetry.core.packages.package import Package from poetry.installation.installer import Installer from poetry.installation.operations.install import Install @@ -140,7 +149,12 @@ def locked_repository(self) -> LockfileRepository: package.develop = False return repo - custom_locker = CustomLocker(poetry.locker.lock, poetry.local_config) + try: + locker_data = poetry.locker._pyproject_data # type: ignore[attr-defined] + except AttributeError: + # poetry < 2.0 + locker_data = poetry.locker._local_config + custom_locker = CustomLocker(poetry.locker.lock, locker_data) installer = Installer( NullIO() if not io.is_debug() else io, @@ -192,7 +206,7 @@ def locked_repository(self) -> LockfileRepository: source_url=str(wheel), ) installer.executor.execute([Install(package)]) - except ModuleOrPackageNotFound: + except ModuleOrPackageNotFoundError: warnings.append( "The root package was not installed because no matching module or" " package was found." diff --git a/tests/console/conftest.py b/tests/console/conftest.py index 06ee3df..941039a 100644 --- a/tests/console/conftest.py +++ b/tests/console/conftest.py @@ -27,7 +27,12 @@ def poetry(project_directory: str, config: Config) -> Poetry: p = Factory().create_poetry( Path(__file__).parent.parent / "fixtures" / project_directory ) - p.set_locker(TestLocker(p.locker.lock, p.locker._local_config)) + try: + locker_data = p.locker._pyproject_data # type: ignore[attr-defined] + except AttributeError: + # poetry < 2.0 + locker_data = p.locker._local_config + p.set_locker(TestLocker(p.locker.lock, locker_data)) return p diff --git a/tests/fixtures/simple_project/poetry.lock b/tests/fixtures/simple_project/poetry.lock index 7e414db..7ce319e 100644 --- a/tests/fixtures/simple_project/poetry.lock +++ b/tests/fixtures/simple_project/poetry.lock @@ -7,6 +7,7 @@ python-versions = "*" version = "1.0.0" [metadata] +lock-version = "1.0" content-hash = "940146b262cc643ca9ab2e882e530cc737484f7a10fa7623439fa401c1b3af72" python-versions = "~2.7 || ^3.4" diff --git a/tests/fixtures/simple_project_with_dev_dep/poetry.lock b/tests/fixtures/simple_project_with_dev_dep/poetry.lock index 8c69716..31ea28d 100644 --- a/tests/fixtures/simple_project_with_dev_dep/poetry.lock +++ b/tests/fixtures/simple_project_with_dev_dep/poetry.lock @@ -7,6 +7,7 @@ python-versions = "*" version = "1.0.0" [metadata] +lock-version = "1.0" content-hash = "84d6d2a62597932428c63eb32553bbd5b803651a1878365bd33d0df15f741c44" python-versions = "~2.7 || ^3.4" diff --git a/tests/fixtures/simple_project_with_editable_dep/poetry.lock b/tests/fixtures/simple_project_with_editable_dep/poetry.lock index 5bb223b..d3ac38d 100644 --- a/tests/fixtures/simple_project_with_editable_dep/poetry.lock +++ b/tests/fixtures/simple_project_with_editable_dep/poetry.lock @@ -1,4 +1,5 @@ [metadata] +lock-version = "1.0" content-hash = "4bf28231e477206338f6afc67df322e7b3601fdbf1d704521e1676a33603768b" python-versions = "~2.7 || ^3.4" diff --git a/tests/fixtures/simple_project_with_no_module/poetry.lock b/tests/fixtures/simple_project_with_no_module/poetry.lock index 3b8c78d..039340e 100644 --- a/tests/fixtures/simple_project_with_no_module/poetry.lock +++ b/tests/fixtures/simple_project_with_no_module/poetry.lock @@ -7,6 +7,7 @@ python-versions = "*" version = "1.0.0" [metadata] +lock-version = "1.0" content-hash = "e97e6b0e10d38d2bbc2549ae152a31c81e1d2ed5e65a2cdf395d4ade26e9bf41" python-versions = "~2.7 || ^3.4"