Skip to content

Commit

Permalink
parse_specifier_for_install: using abs path for constraint and requir…
Browse files Browse the repository at this point in the history
…ements
  • Loading branch information
guysalt committed May 4, 2024
1 parent bd69963 commit 6bd33c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/1389.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix passing constraints file path into `pipx install` operation via `pip` args
22 changes: 21 additions & 1 deletion src/pipx/package_specifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,27 @@ def parse_specifier_for_install(package_spec: str, pip_args: List[str]) -> Tuple
)
pip_args.remove("--editable")

return (package_or_url, pip_args)
for index, option in enumerate(pip_args):
if not option.startswith(("-c", "--constraint")):
continue

if option == "-c":
next_option_index = index + 1
if next_option_index < len(pip_args):
next_option = pip_args[next_option_index]
pip_args[next_option_index] = str(Path(next_option).expanduser().resolve())

else: # option == "--constraint"
option_list = option.split("=")

if len(option_list) == 2:
key, value = option_list
value_path = Path(value).expanduser().resolve()
pip_args[index] = f"{key}={value_path}"

break

return package_or_url, pip_args


def parse_specifier_for_metadata(package_spec: str) -> str:
Expand Down

0 comments on commit 6bd33c5

Please sign in to comment.