Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundle node and pyright with the pypi package #231

Open
DetachHead opened this issue Nov 15, 2023 · 7 comments · Fixed by #299 · May be fixed by #300
Open

bundle node and pyright with the pypi package #231

DetachHead opened this issue Nov 15, 2023 · 7 comments · Fixed by #299 · May be fixed by #300

Comments

@DetachHead
Copy link

DetachHead commented Nov 15, 2023

having the pypi package download both node and the npm package when you first run the pyright command causes some issues:

  • we have a docker image where all the dependencies are installed, but when the pyright job runs in our CI, it can fail because the runner cannot access npm (due to corporate proxy nonsense). to work around this, we had to put this command in our dockerfile:
    # installs node & pyright
    RUN pyright --version
  • Pre-commit install hook doesn't actually install Pyright #225
  • npm is incredibly slow and unreliable on PCs at my work

i think bundling the npm package and node in the pypi package would be a much more reliable solution. that's how the playwright pypi package works for example

@DetachHead
Copy link
Author

I've solved this problem in basedpyright

@Avasam
Copy link

Avasam commented Mar 15, 2024

Here's another example of issues caused by trying to install a node environment on first run: python/typeshed#11575 (review)

According to @jakebailey, python/typeshed#11575 (comment)

[...] It also could skip npm, but I can understand wanting to leverage npm to do version resolution (though doing it just with the registry is not super hard and IMO would be worth it to avoid the dep).

Also relates to #209

@RobertCraigie
Copy link
Owner

Didn't intent to close this yet, the next release will add support for

pip install pyright[nodejs]

which will download the Node.js binaries at install time using nodejs-wheel instead of using nodeenv at runtime.

@bersbersbers
Copy link
Contributor

#299 works great for me - thanks!

@codeofandrin
Copy link

For me, this doesn't fix it and sitll has the same behavior as described in #296, even when I installed it via

pip install pyright[nodejs]

@RobertCraigie
Copy link
Owner

@Puncher1 that's expected currently as your issue is happening at the npm install step, not when downloading Node.js.

If you want to test out my WIP PR for bundling pyright, you can checkout this branch, setup a venv then run these commands to produce a .whl file you can install in other projects.

pip install -r dev-requiremnts.txt
python scripts/download_pyright.py
python setup.py sdist bdist_wheel

then to install it

pip install /path/to/pyright-python/dist/pyright-1.1.382.post0-py3-none-any.whl

@vctorhuang
Copy link

Hi @RobertCraigie, thanks for adding these great features and maintaining this repo!

Our usage of pyright would optimally require that everything is bundled inside the pypi package (node + pyright). I built the wheel off of the branch (#300) according to the instructions above and it seems to work correctly. Is there a timeline on when this will be available on main?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants