python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
30.47k stars 2.23k forks source link

Cannot install package with shell script in `[tool.poetry.scripts]` #4289

Open ethanabrooks opened 3 years ago

ethanabrooks commented 3 years ago

Issue

I am trying to create a package that includes a shell script that I would like to make available to any projects that install this package. https://github.com/ethanabrooks/poetry-issue is the package that I want to install. To set up the project that I want to install the package into, I run:

poetry new poetry-issue2
cd poetry-issue2
poetry shell

Then both

poetry add git+https://github.com/ethanabrooks/poetry-issue.git@main

and

poetry add ../poetry-issue

yield the same error:

poetry-issue2-fWI-Kq6B-py3.6 ❯ poetry add ../poetry-issue

Updating dependencies
Resolving dependencies... (0.1s)

Package operations: 1 install, 0 updates, 0 removals

  • Installing poetry-issue (0.1.0 /home/ethanbro/poetry-issue): Failed

  CalledProcessError

  Command '['/home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6/bin/python', '/home/ethanbro/.local/share/pypoetry/venv/lib/python3.6/site-packages/virtualenv/seed/wheels/embed/pip-21.0.1-py3-none-any.whl/pip', 'install', '--use-pep517', '--disable-pip-version-check', '--prefix', '/home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6', '--upgrade', '--no-deps', '/home/ethanbro/poetry-issue']' returned non-zero exit status 1.

  at /usr/lib/python3.6/subprocess.py:438 in run
       434│             raise
       435│         retcode = process.poll()
       436│         if check and retcode:
       437│             raise CalledProcessError(retcode, process.args,
    →  438│                                      output=stdout, stderr=stderr)
       439│     return CompletedProcess(process.args, retcode, stdout, stderr)
       440│
       441│
       442│ def list2cmdline(seq):

The following error occurred when trying to handle this error:

  EnvCommandError

  Command ['/home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6/bin/python', '/home/ethanbro/.local/share/pypoetry/venv/lib/python3.6/site-packages/virtualenv/seed/wheels/embed/pip-21.0.1-py3-none-any.whl/pip', 'install', '--use-pep517', '--disable-pip-version-check', '--prefix', '/home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6', '--upgrade', '--no-deps', '/home/ethanbro/poetry-issue'] errored with the following return code 1, and output:
  Processing /home/ethanbro/poetry-issue
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6/bin/python /home/ethanbro/.local/share/pypoetry/venv/lib/python3.6/site-packages/virtualenv/seed/wheels/embed/pip-21.0.1-py3-none-any.whl/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpxlxn6z_q
         cwd: /tmp/pip-req-build-zmy6kyn0
    Complete output (1 lines):
    /home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6/bin/python: can't find '__main__' module in '/home/ethanbro/.local/share/pypoetry/venv/lib/python3.6/site-packages/virtualenv/seed/wheels/embed/pip-21.0.1-py3-none-any.whl/pip/_vendor/pep517/_in_process.py'
    ----------------------------------------
  WARNING: Discarding file:///home/ethanbro/poetry-issue. Command errored out with exit status 1: /home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6/bin/python /home/ethanbro/.local/share/p
ypoetry/venv/lib/python3.6/site-packages/virtualenv/seed/wheels/embed/pip-21.0.1-py3-none-any.whl/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpxlxn6z_q Check the logs for full command
output.  ERROR: Command errored out with exit status 1: /home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6/bin/python /home/ethanbro/.local/share/pypoetry/venv/lib/python3.6/site-packages/virtualenv/seed/wheels/embed/pip-21.0.1-py3-none-any.whl/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpxlxn6z_q Check the logs for full command output.

  at ~/.local/share/pypoetry/venv/lib/python3.6/site-packages/poetry/utils/env.py:1300 in _run
      1296│                 output = subprocess.check_output(
      1297│                     cmd, stderr=subprocess.STDOUT, env=env, **kwargs
      1298│                 )
      1299│         except CalledProcessError as e:
    → 1300│             raise EnvCommandError(e, input=input_)
      1301│
      1302│         return decode(output)
      1303│
      1304│     def execute(self, bin: str, *args: str, **kwargs: Any) -> Optional[int]:

The following error occurred when trying to handle this error:

  CalledProcessError

  Command '['/tmp/tmpzu5vptq1/.venv/bin/python', '/tmp/tmpzu5vptq1/.venv/bin/pip', 'install', '--use-pep517', '--disable-pip-version-check', '--prefix', '/home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6', '--upgrade', '--no-deps', '/home/ethanbro/poetry-issue']' returned non-zero exit status 1.

  at /usr/lib/python3.6/subprocess.py:438 in run
       434│             raise
       435│         retcode = process.poll()
       436│         if check and retcode:
       437│             raise CalledProcessError(retcode, process.args,
    →  438│                                      output=stdout, stderr=stderr)
       439│     return CompletedProcess(process.args, retcode, stdout, stderr)
       440│
       441│
       442│ def list2cmdline(seq):

The following error occurred when trying to handle this error:

  EnvCommandError

  Command ['/tmp/tmpzu5vptq1/.venv/bin/python', '/tmp/tmpzu5vptq1/.venv/bin/pip', 'install', '--use-pep517', '--disable-pip-version-check', '--prefix', '/home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue2-fWI-Kq6B-py3.6', '--upgrade', '--no-deps', '/home/ethanbro/poetry-issue'] errored with the following return code 1, and output:
  Processing /home/ethanbro/poetry-issue
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
      Preparing wheel metadata: started
      Preparing wheel metadata: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /tmp/tmpzu5vptq1/.venv/bin/python /tmp/tmpzu5vptq1/.venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpn5b58em1
           cwd: /tmp/pip-req-build-ufprx1xr
      Complete output (14 lines):
      Traceback (most recent call last):
        File "/tmp/tmpzu5vptq1/.venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
          main()
        File "/tmp/tmpzu5vptq1/.venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/tmp/tmpzu5vptq1/.venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/tmp/pip-build-env-9zyzmw6o/overlay/lib/python3.6/site-packages/poetry/core/masonry/api.py", line 51, in prepare_metadata_for_build_wheel
          builder._write_entry_points(f)
        File "/tmp/pip-build-env-9zyzmw6o/overlay/lib/python3.6/site-packages/poetry/core/masonry/builders/wheel.py", line 330, in _write_entry_points
          entry_points = self.convert_entry_points()
        File "/tmp/pip-build-env-9zyzmw6o/overlay/lib/python3.6/site-packages/poetry/core/masonry/builders/builder.py", line 285, in convert_entry_points
          extras = "[{}]".format(", ".join(ep["extras"]))
      KeyError: 'extras'
      ----------------------------------------
  WARNING: Discarding file:///home/ethanbro/poetry-issue. Command errored out with exit status 1: /tmp/tmpzu5vptq1/.venv/bin/python /tmp/tmpzu5vptq1/.venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_proc
ess.py prepare_metadata_for_build_wheel /tmp/tmpn5b58em1 Check the logs for full command output.  ERROR: Command errored out with exit status 1: /tmp/tmpzu5vptq1/.venv/bin/python /tmp/tmpzu5vptq1/.venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpn5b58em1 Check the logs for full command output.

  at ~/.local/share/pypoetry/venv/lib/python3.6/site-packages/poetry/utils/env.py:1300 in _run
      1296│                 output = subprocess.check_output(
      1297│                     cmd, stderr=subprocess.STDOUT, env=env, **kwargs
      1298│                 )
      1299│         except CalledProcessError as e:
    → 1300│             raise EnvCommandError(e, input=input_)
      1301│
      1302│         return decode(output)
      1303│
      1304│     def execute(self, bin: str, *args: str, **kwargs: Any) -> Optional[int]:

Failed to add packages, reverting the pyproject.toml file to its original content.

If I remove the last two lines (the [tool.poetry.scripts] section), the package installs fine.

kojiromike commented 6 months ago

Is this a duplicate of #2310?