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

feat: switch from nodejs-bin to nodejs-wheel #323

Merged
merged 7 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions basedpyright/run_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import sys
from pathlib import Path

from nodejs import node
from nodejs_wheel.executable import ( # pyright:ignore[reportMissingTypeStubs]
node, # pyright:ignore[reportUnknownVariableType]
)


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

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

21 changes: 12 additions & 9 deletions pdm_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@
from json import loads
from pathlib import Path
from shutil import copyfile, copytree
from typing import TYPE_CHECKING, TypedDict, cast
from typing import 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.executable import ( # pyright:ignore[reportMissingTypeStubs]
npm, # pyright:ignore[reportUnknownVariableType]
)


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


_ = run(["ci"], check=True)
_ = run(["run", "build:cli:dev"], check=True)
def run_npm(*args: str):
exit_code = npm(args)
if exit_code != 0:
raise Exception(f"the following npm command exited with {exit_code=}: {args}")


run_npm("ci")
run_npm("run", "build:cli:dev")

npm_package_dir = Path("packages/pyright")
pypi_package_dir = Path("basedpyright")
Expand Down
24 changes: 9 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.pyprojectx]
main = ["pdm==2.13.2"]
main = ["pdm==2.15.1"]

[tool.pdm]
distribution = true
Expand All @@ -8,8 +8,8 @@ distribution = true
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",
# cli is needed for development if node is not installed globally
"nodejs-wheel>=20.13.0",
]

[tool.pdm.version]
Expand All @@ -32,8 +32,9 @@ 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. only binaries are required (no cli)
# since the user shouldn't have a node/npm binary unknowingly added to their PATH
"nodejs-wheel-binaries>=20.13.0",
]
requires-python = ">=3.8"
readme = "README.md"
Expand All @@ -49,8 +50,9 @@ 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",
# required for building the pyright npm package to be bundled in the pypi package.
# cli is required due to dependencies with install scripts that assume node/npm is in the path
"nodejs-wheel>=20.13.0",
]
build-backend = "pdm.backend"

Expand Down Expand Up @@ -97,12 +99,9 @@ enable = [
"assignment-from-none",
"dict-iter-missing-items",
"invalid-bool-returned",
"invalid-bytes-returned",
"invalid-getnewargs-ex-returned",
"invalid-getnewargs-returned",
"invalid-index-returned",
"invalid-length-hint-returned",
"invalid-length-returned",
"invalid-slice-index",
"invalid-slice-step",
"invalid-slots",
Expand All @@ -112,10 +111,8 @@ enable = [
"logging-unsupported-format",
"method-hidden",
"modified-iterating-dict",
"modified-iterating-set",
"potential-index-error",
"relative-beyond-top-level",
"singledispatchmethod-function",
"abstract-method",
"arguments-out-of-order",
"attribute-defined-outside-init",
Expand All @@ -127,17 +124,14 @@ enable = [
"missing-param-doc",
"modified-iterating-list",
"multiple-constructor-doc",
"nan-comparison",
"non-parent-init-called",
"overlapping-except",
"preferred-module",
"raising-format-tuple",
"redeclared-assigned-name",
"redefined-outer-name",
"redefined-slots-in-subclass",
"redundant-returns-doc",
"redundant-yields-doc",
"self-cls-assignment",
"shallow-copy-environ",
"useless-param-doc",
"useless-parent-delegation",
Expand Down
Loading