Skip to content

Commit

Permalink
respect develop when installing from git
Browse files Browse the repository at this point in the history
* fixes python-poetry#1080, again
  • Loading branch information
fantix committed Feb 6, 2020
1 parent ed44342 commit 9a485dc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions poetry/json/schemas/poetry-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@
"items": {
"type": "string"
}
},
"develop": {
"type": "boolean",
"description": "Whether to install the dependency in development mode."
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +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":
if package.source_type in {"directory", "vcs"}:
data["develop"] = package.develop

return data
1 change: 1 addition & 0 deletions poetry/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ def add_dependency(
branch=constraint.get("branch", None),
tag=constraint.get("tag", None),
rev=constraint.get("rev", None),
develop=constraint.get("develop", True),
category=category,
optional=optional,
)
Expand Down
6 changes: 6 additions & 0 deletions poetry/packages/vcs_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(
rev=None,
category="main",
optional=False,
develop=True,
):
self._vcs = vcs
self._source = source
Expand All @@ -29,6 +30,7 @@ def __init__(
self._branch = branch
self._tag = tag
self._rev = rev
self._develop = develop

super(VCSDependency, self).__init__(
name, "*", category=category, optional=optional, allows_prereleases=True
Expand Down Expand Up @@ -58,6 +60,10 @@ def rev(self):
def reference(self): # type: () -> str
return self._branch or self._tag or self._rev

@property
def develop(self):
return self._develop

@property
def pretty_constraint(self): # type: () -> str
if self._branch:
Expand Down
4 changes: 3 additions & 1 deletion poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def search_for_vcs(self, dependency): # type: (VCSDependency) -> List[Package]
dependency.source,
dependency.reference,
name=dependency.name,
develop=dependency.develop,
)

for extra in dependency.extras:
Expand All @@ -182,7 +183,7 @@ def search_for_vcs(self, dependency): # type: (VCSDependency) -> List[Package]

@classmethod
def get_package_from_vcs(
cls, vcs, url, reference=None, name=None
cls, vcs, url, reference=None, name=None, develop=True,
): # type: (str, str, Optional[str], Optional[str]) -> Package
if vcs != "git":
raise ValueError("Unsupported VCS dependency {}".format(vcs))
Expand All @@ -206,6 +207,7 @@ def get_package_from_vcs(
package.source_type = "git"
package.source_url = url
package.source_reference = revision
package.develop = develop
except Exception:
raise
finally:
Expand Down
4 changes: 3 additions & 1 deletion poetry/utils/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ def _export_requirements_txt(
package.source_reference,
)
dependency.marker = package.marker
line = "-e git+{}@{}#egg={}".format(
line = "git+{}@{}#egg={}".format(
package.source_url, package.source_reference, package.name
)
if package.develop:
line = "-e " + line
elif package.source_type in ["directory", "file", "url"]:
if package.source_type == "file":
dependency = FileDependency(package.name, Path(package.source_url))
Expand Down

0 comments on commit 9a485dc

Please sign in to comment.