Skip to content

Commit

Permalink
feat: switch from nodejs-bin to nodejs-wheel
Browse files Browse the repository at this point in the history
Wider support for older glibc

Fixes DetachHead#167
  • Loading branch information
lewis6991 authored and DetachHead committed May 8, 2024
1 parent 02577dc commit e061b1b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 92 deletions.
4 changes: 2 additions & 2 deletions basedpyright/run_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import sys
from pathlib import Path

from nodejs import node
from nodejs_wheel import executable


def run(script_name: str):
sys.exit(node.call([Path(__file__).parent / f"{script_name}.js", *sys.argv[1:]]))
sys.exit(executable.call_node(Path(__file__).parent / f"{script_name}.js", *sys.argv[1:]))
118 changes: 42 additions & 76 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions pdm_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@
from json import loads
from pathlib import Path
from shutil import copyfile, copytree
from typing import TYPE_CHECKING, TypedDict, cast
from typing import List, TypedDict, cast

# https://github.com/samwillis/nodejs-pypi/pull/23
if TYPE_CHECKING:
# https://github.com/astral-sh/ruff/issues/9528
from subprocess import run # noqa: S404
else:
from nodejs.npm import run
from nodejs_wheel import executable

# Remove when https://github.com/njzjz/nodejs-wheel/pull/24 is merged
def run(cmd: List[str]):
old_sys_argv = sys.argv
sys.argv = [old_sys_argv[0]] + cmd
try:
executable.npm()
finally:
sys.argv = old_sys_argv


class PackageJson(TypedDict):
bin: dict[str, str]


_ = run(["ci"], check=True)
_ = run(["run", "build:cli:dev"], check=True)
run(["ci"])
run(["run", "build:cli:dev"])

npm_package_dir = Path("packages/pyright")
pypi_package_dir = Path("basedpyright")
Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dev = [
"pylint>=3.0.0a7",
"ruff>=0.2.2",
# required for running node/npm commands for local development if node is not installed globally:
"nodejs-bin[cmd]>=18.4.0a4",
"nodejs-wheel>=20.12.2",
]

[tool.pdm.version]
Expand All @@ -32,8 +32,8 @@ authors = [
{ name = "detachhead", email = "[email protected]" },
]
dependencies = [
# required by the basedpyright cli & langserver wrapper scripts, the cmd extra is not needed downstream tho
"nodejs-bin>=18.4.0a4",
# required by the basedpyright cli & langserver wrapper scripts
"nodejs-wheel>=20.12.2",
]
requires-python = ">=3.8"
readme = "README.md"
Expand All @@ -49,8 +49,6 @@ basedpyright-langserver = 'basedpyright.langserver:main'
[build-system]
requires = [
"pdm-backend",
# required when building because some transient dependencies call node/npm scripts relying on it being in the PATH
"nodejs-bin[cmd]>=18.4.0a4",
]
build-backend = "pdm.backend"

Expand Down

0 comments on commit e061b1b

Please sign in to comment.