Skip to content

Commit

Permalink
fix (#1654): exporting to requirements.txt always prepends -e to depe…
Browse files Browse the repository at this point in the history
…ndencies (#1656)

* fix (locker): add `develop = false` in `poetry.lock` if set in `pyproject.toml`
fix (locker): read `develop` value from `poetry.lock` so it is respect when exporting to `requirements.txt`

* fix (test_installer): adopt expected result

* change (test_installer): move develop key from source to package in lock file

* fix (test_installer): make black happy
  • Loading branch information
finswimmer authored and sdispater committed Dec 11, 2019
1 parent e943a4e commit 06cdc77
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
5 changes: 5 additions & 0 deletions poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ def locked_repository(

package.add_dependency(dep_name, constraint)

if "develop" in info:
package.develop = info["develop"]

if "source" in info:
package.source_type = info["source"].get("type", "")
package.source_url = info["source"]["url"]
Expand Down Expand Up @@ -301,5 +304,7 @@ def _dump_package(self, package): # type: (poetry.packages.Package) -> dict
}
if package.source_type:
data["source"]["type"] = package.source_type
if package.source_type == "directory":
data["develop"] = package.develop

return data
1 change: 1 addition & 0 deletions poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def search_for_directory(
)

package.source_url = dependency.path.as_posix()
package.develop = dependency.develop

if dependency.base is not None:
package.root_dir = dependency.base.as_posix()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[[package]]
category = "main"
description = ""
develop = true
name = "project-with-extras"
optional = false
python-versions = "*"
Expand All @@ -18,6 +19,7 @@ url = "tests/fixtures/directory/project_with_transitive_directory_dependencies/.
[[package]]
category = "main"
description = ""
develop = true
name = "project-with-transitive-directory-dependencies"
optional = false
python-versions = "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ version = "1.4.4"
[[package]]
category = "main"
description = ""
develop = true
name = "project-with-extras"
optional = false
python-versions = "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ python-versions = "*"
[[package]]
name = "my-package"
version = "0.1.2"
develop = true
description = "Demo project."
category = "main"
optional = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ version = "1.4.4"
[[package]]
category = "main"
description = ""
develop = true
name = "project-with-transitive-file-dependencies"
optional = false
python-versions = "*"
Expand Down
21 changes: 11 additions & 10 deletions tests/installation/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
from tests.repositories.test_pypi_repository import MockRepository


fixtures_dir = Path("tests/fixtures")


class Installer(BaseInstaller):
def _get_installer(self):
return NoopInstaller()
Expand Down Expand Up @@ -662,7 +665,7 @@ def test_installer_with_pypi_repository(package, locker, installed):


def test_run_installs_with_local_file(installer, locker, repo, package):
file_path = Path("tests/fixtures/distributions/demo-0.1.0-py2.py3-none-any.whl")
file_path = fixtures_dir / "distributions/demo-0.1.0-py2.py3-none-any.whl"
package.add_dependency("demo", {"file": str(file_path)})

repo.add_package(get_package("pendulum", "1.4.4"))
Expand All @@ -677,8 +680,8 @@ def test_run_installs_with_local_file(installer, locker, repo, package):


def test_run_installs_wheel_with_no_requires_dist(installer, locker, repo, package):
file_path = Path(
"tests/fixtures/wheel_with_no_requires_dist/demo-0.1.0-py2.py3-none-any.whl"
file_path = (
fixtures_dir / "wheel_with_no_requires_dist/demo-0.1.0-py2.py3-none-any.whl"
)
package.add_dependency("demo", {"file": str(file_path)})

Expand All @@ -694,7 +697,7 @@ def test_run_installs_wheel_with_no_requires_dist(installer, locker, repo, packa
def test_run_installs_with_local_poetry_directory_and_extras(
installer, locker, repo, package, tmpdir
):
file_path = Path("tests/fixtures/project_with_extras")
file_path = fixtures_dir / "project_with_extras"
package.add_dependency(
"project-with-extras", {"path": str(file_path), "extras": ["extras_a"]}
)
Expand All @@ -713,8 +716,8 @@ def test_run_installs_with_local_poetry_directory_and_extras(
def test_run_installs_with_local_poetry_directory_transitive(
installer, locker, repo, package, tmpdir
):
file_path = Path(
"tests/fixtures/directory/project_with_transitive_directory_dependencies/"
file_path = (
fixtures_dir / "directory/project_with_transitive_directory_dependencies/"
)
package.add_dependency(
"project-with-transitive-directory-dependencies", {"path": str(file_path)}
Expand All @@ -735,9 +738,7 @@ def test_run_installs_with_local_poetry_directory_transitive(
def test_run_installs_with_local_poetry_file_transitive(
installer, locker, repo, package, tmpdir
):
file_path = Path(
"tests/fixtures/directory/project_with_transitive_file_dependencies/"
)
file_path = fixtures_dir / "directory/project_with_transitive_file_dependencies/"
package.add_dependency(
"project-with-transitive-file-dependencies", {"path": str(file_path)}
)
Expand All @@ -757,7 +758,7 @@ def test_run_installs_with_local_poetry_file_transitive(
def test_run_installs_with_local_setuptools_directory(
installer, locker, repo, package, tmpdir
):
file_path = Path("tests/fixtures/project_with_setup/")
file_path = fixtures_dir / "project_with_setup/"
package.add_dependency("my-package", {"path": str(file_path)})

repo.add_package(get_package("pendulum", "1.4.4"))
Expand Down

0 comments on commit 06cdc77

Please sign in to comment.