Skip to content

Commit

Permalink
Print -e option and path for editable package when using `pipenv re…
Browse files Browse the repository at this point in the history
…quirements` (#5071)

* Print `-e` option and path for editable package

* Reduce depth for logical complexity

* Add news fragment
  • Loading branch information
change-park committed Apr 23, 2022
1 parent 5ed5419 commit 9a6cf5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions news/5070.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes issue of ``requirements`` command problem by modifying to print ``-e`` and path of the editable package.
18 changes: 11 additions & 7 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,21 +759,25 @@ def requirements(state, dev=False, dev_only=False, hash=False):
lockfile = state.project.lockfile_content
for i, package_index in enumerate(lockfile["_meta"]["sources"]):
prefix = "-i" if i == 0 else "--extra-index-url"
echo(crayons.normal(" ".join([prefix, package_index["url"]])))
echo(" ".join([prefix, package_index["url"]]))
if not dev_only:
for req_name, value in lockfile["default"].items():
if hash:
if value.get("editable", False):
echo("-e " + value["path"])
elif hash:
hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])]
echo("".join([req_name, value["version"], *hashes]))
else:
hashes = []
echo(crayons.normal("".join([req_name, value["version"], *hashes])))
echo("".join([req_name, value["version"]]))
if dev or dev_only:
for req_name, value in lockfile["develop"].items():
if hash:
if value.get("editable", False):
echo("-e " + value["path"])
elif hash:
hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])]
echo("".join([req_name, value["version"], *hashes]))
else:
hashes = []
echo(crayons.normal("".join([req_name, value["version"], *hashes])))
echo("".join([req_name, value["version"]]))
sys.exit(0)


Expand Down

0 comments on commit 9a6cf5d

Please sign in to comment.