-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert changes to
pdm_build
script because it was broken or somethi…
…ng. no clue how it works but it seems to run too early before pdm actually does anything, and i dont have the patience to figure out why
- Loading branch information
1 parent
64640d4
commit 94ab71d
Showing
3 changed files
with
35 additions
and
83 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,37 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from json import loads | ||
from pathlib import Path | ||
from shutil import copyfile, copytree | ||
from typing import TYPE_CHECKING, TypedDict, cast | ||
|
||
from nodejs import node | ||
|
||
# https://github.com/samwillis/nodejs-pypi/pull/23 | ||
if TYPE_CHECKING: | ||
# https://github.com/samwillis/nodejs-pypi/pull/23 | ||
# https://github.com/astral-sh/ruff/issues/9528 | ||
from subprocess import run # noqa: S404 | ||
|
||
from pdm.backend.hooks import Context | ||
else: | ||
from nodejs.npm import run | ||
import os | ||
|
||
|
||
# these are hook functions where all args are required regardless of whether or not they are used | ||
# ruff: noqa: ARG001 | ||
from nodejs import node | ||
|
||
|
||
class PackageJson(TypedDict): | ||
bin: dict[str, str] | ||
|
||
|
||
def pdm_build_update_files(context: Context, files: dict[str, Path]): | ||
# ah yes, the classic "wrong path" moment! | ||
os.environ["PATH"] = os.pathsep.join([str(Path(node.__file__).parent), os.environ["PATH"]]) | ||
# ah yes, the classic "wrong path" moment! | ||
os.environ["PATH"] = os.pathsep.join([str(Path(node.__file__).parent), os.environ["PATH"]]) | ||
|
||
if not Path("node_modules").exists(): | ||
_ = run(["ci"], check=True) | ||
_ = run(["run", "build:cli:dev"], check=True) | ||
if not Path("node_modules").exists(): | ||
_ = run(["ci"], check=True) | ||
_ = run(["run", "build:cli:dev"], check=True) | ||
|
||
npm_package_dir = Path("packages/pyright") | ||
pypi_package_dir = Path("basedpyright") | ||
npm_package_dir = Path("packages/pyright") | ||
pypi_package_dir = Path("basedpyright") | ||
|
||
copytree(npm_package_dir / "dist", pypi_package_dir / "dist", dirs_exist_ok=True) | ||
for script_path in cast(PackageJson, loads((npm_package_dir / "package.json").read_text()))[ | ||
"bin" | ||
].values(): | ||
_ = copyfile(npm_package_dir / script_path, pypi_package_dir / script_path) | ||
copytree(npm_package_dir / "dist", pypi_package_dir / "dist", dirs_exist_ok=True) | ||
for script_path in cast(PackageJson, loads((npm_package_dir / "package.json").read_text()))[ | ||
"bin" | ||
].values(): | ||
_ = copyfile(npm_package_dir / script_path, pypi_package_dir / script_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters