python-poetry / python-poetry/poetry-plugin-bundle

Bundle breaks when using relative path

Open
#97 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
151
Forks
30
Avg merge
48m
Merged PRs (30d)
5

Description

The following command succeeds, but then calling an entrypoint from this bundle fails because the shebangs stores the python exectuable path as a relative with respect to the directory we launched the first command from.

In the example, we install black in order to have an executable entrypoint, but any other entrypoint would work

poetry new -n issute_test
cd issue_test
poetry add black
poetry bundle venv ../issue_test_bundle
../issue_test_bundle/bin/black -h   # this works
cd .. && ./issue_test_bundle/bin/black -h  # this fails

The error message :

zsh: ./issue_test_bundle/bin/black: bad interpreter: ../issue_test_bundle/bin/python: aucun fichier ou dossier de ce nom

The created black file in issue_test_bundle/black :

#!../issue_test_bundle/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from black import patched_main
if __name__ == "__main__":
    sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
    sys.exit(patched_main())

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

First reproduce the issue with the commands in the report, especially invoking issue_test_bundle/bin/black from both the project directory and its parent. Inspect the generated issue_test_bundle/bin/black entrypoint and its shebang. Done means the bundled entrypoint works when launched from outside the directory used to create the bundle, with a valid interpreter path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.