Skip to content

Conversation

wiwichips
Copy link
Collaborator

This change prints an error message during pip install when npm is not installed on the system:

The error should show up like this:

Building wheels for collected packages: pminit
  Building wheel for pminit (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pminit (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [38 lines of output]
      
      
      PythonMonkey Build Error:
      
      
        *    It appears npm is not installed on this system.
        *    npm is required for PythonMonkey to build.
        *    Please install NPM and Node.js before installing PythonMonkey.
        *    Refer to the documentation for installing NPM and Node.js here: https://nodejs.org/en/download
      
      
      
      Traceback (most recent call last):
        File "/tmp/pip-req-build-ryy_b0um/post-install-hook.py", line 38, in <module>
          main()
        File "/tmp/pip-req-build-ryy_b0um/post-install-hook.py", line 33, in main
          raise Exception("PythonMonkey build error: Unable to find npm on the system.")
      Exception: PythonMonkey build error: Unable to find npm on the system.
      Traceback (most recent call last):
        File "/home/will/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/will/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/will/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/tmp/pip-build-env-m9x30o3s/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/api.py", line 57, in build_wheel
          return WheelBuilder.make_in(
        File "/tmp/pip-build-env-m9x30o3s/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/wheel.py", line 88, in make_in
          wb.build(target_dir=directory)
        File "/tmp/pip-build-env-m9x30o3s/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/wheel.py", line 123, in build
          self._build(zip_file)
        File "/tmp/pip-build-env-m9x30o3s/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/wheel.py", line 172, in _build
          self._run_build_script(self._package.build_script)
        File "/tmp/pip-build-env-m9x30o3s/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/wheel.py", line 232, in _run_build_script
          subprocess.check_call([self.executable.as_posix(), build_script])
        File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/usr/bin/python3', 'post-install-hook.py']' returned non-zero exit status 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pminit
Failed to build pminit
ERROR: Could not build wheels for pminit, which is required to install pyproject.toml-based projects

If there is a cleaner way to do this which results in less output, please let me know

…lled

The error now displays like this:

Building wheels for collected packages: pminit
  Building wheel for pminit (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pminit (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [38 lines of output]

      PythonMonkey Build Error:

        *    It appears npm is not installed on this system.
        *    npm is required for PythonMonkey to build.
        *    Please install NPM and Node.js before installing PythonMonkey.
        *    Refer to the documentation for installing NPM and Node.js here: https://nodejs.org/en/download

      Traceback (most recent call last):
        File "/tmp/pip-req-build-75mp6ch1/post-install-hook.py", line 38, in <module>
          main()
        File "/tmp/pip-req-build-75mp6ch1/post-install-hook.py", line 33, in main
          raise Exception("PythonMonkey build error: Unable to find npm on the system.")
      Exception: PythonMonkey build error: Unable to find npm on the system.
      Traceback (most recent call last):
        File "/home/will/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/will/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/will/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/tmp/pip-build-env-emge0d96/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/api.py", line 57, in build_wheel
          return WheelBuilder.make_in(
        File "/tmp/pip-build-env-emge0d96/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/wheel.py", line 88, in make_in
          wb.build(target_dir=directory)
        File "/tmp/pip-build-env-emge0d96/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/wheel.py", line 123, in build
          self._build(zip_file)
        File "/tmp/pip-build-env-emge0d96/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/wheel.py", line 172, in _build
          self._run_build_script(self._package.build_script)
        File "/tmp/pip-build-env-emge0d96/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/wheel.py", line 232, in _run_build_script
          subprocess.check_call([self.executable.as_posix(), build_script])
        File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/usr/bin/python3', 'post-install-hook.py']' returned non-zero exit status 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pminit
Failed to build pminit
ERROR: Could not build wheels for pminit, which is required to install pyproject.toml-based projects
@bryan-hoang
Copy link
Contributor

question: Is it worth telling folks to use npm >= 7 to avoid people using versions of npm that will no longer receive security updates?

It looks like we aren't concerned with lock file versions, so any version of npm that comes with node >= 16 should suffice.

@wiwichips
Copy link
Collaborator Author

question: Is it worth telling folks to use npm >= 7 to avoid people using versions of npm that will no longer receive security updates?

It looks like we aren't concerned with lock file versions, so any version of npm that comes with node >= 16 should suffice.

I like this - However, I'm not sure which version we should specify - also keeping in mind older versions of NPM have security vulnerabilities

@Xmader Xmader merged commit 25b8ea6 into main Jul 28, 2023
@wiwichips
Copy link
Collaborator Author

Thanks @Xmader !

@Xmader Xmader deleted the will/install-error-when-npm-not-on-system branch July 28, 2023 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants