Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into sync-branches/maste…
Browse files Browse the repository at this point in the history
…r-to-current
  • Loading branch information
github-actions[bot] committed Jan 19, 2025
2 parents c0cf0e1 + 51cc4ef commit e4d6715
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ jobs:
python: 311
platform_id: win_amd64
# linux-aarch64
- os: ARM64
- os: ubuntu-24.04-arm
python: 311
platform_id: manylinux_aarch64
- os: ubuntu-24.04-arm
python: 311
platform_id: musllinux_aarch64
# windows-arm64
- os: windows-latest
python: 311
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
git commit -m "Sync .gitattributes from ${{ github.ref_name }}"
fi
git merge origin/${{ github.ref_name }}
git push origin ${BRANCH_NAME} --force
git push -u origin ${BRANCH_NAME} --force
PR_URL="$(gh pr list --head "${BRANCH_NAME}" --state open --json url --jq .[].url)"
if [[ -n "${PR_URL}" ]]; then
echo "PR already exists -> ${PR_URL}"
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ elseif(WIN32 AND CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
WORLD_EXECUTE
)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nodejs_source/deps/npm
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nodejs_source/deps/npm ${CMAKE_CURRENT_BINARY_DIR}/nodejs_source/deps/corepack
DESTINATION ${SKBUILD_PLATLIB_DIR}/nodejs_wheel/lib/node_modules/
USE_SOURCE_PERMISSIONS
)
Expand Down Expand Up @@ -85,7 +85,7 @@ elseif(WIN32 AND CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
WORLD_EXECUTE
)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nodejs_source/deps/npm
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nodejs_source/deps/npm ${CMAKE_CURRENT_BINARY_DIR}/nodejs_source/deps/corepack
DESTINATION ${SKBUILD_PLATLIB_DIR}/nodejs_wheel/lib/node_modules/
USE_SOURCE_PERMISSIONS
)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The project is powered by [scikit-build-core](/~https://github.com/scikit-build/sc
| Linux | x86_64 | 64 | glibc >= 2.17 | v18.18.0 |
| Linux | x86_64 | 64 | musl >= 1.2 | v20.14.0 |
| Linux | aarch64 | 64 | glibc >= 2.17 | v20.13.0 |
| Linux | aarch64 | 64 | musl >= 1.2 | v22.14.0 |
| macOS | x86_64 | 64 | >= macOS-11 | v18.18.0 |
| macOS | arm64 | 64 | >= macOS-11 | v20.11.1 |
| Windows | amd64 | 64 | | v18.18.0 |
Expand All @@ -48,6 +49,8 @@ Only available in the `nodejs-wheel` package.
node -h
npm -h
npx -h
# New in v22.14.0
corepack -h
```

### Run library module as a script
Expand All @@ -69,11 +72,15 @@ from nodejs_wheel import (
node,
npm,
npx,
# corepack: New in v22.14.0
corepack,
)

return_code0 = node(["--version"])
return_code1 = npm(["--version"])
return_code2 = npx(["--version"])
# corepack: New in v22.14.0
return_code3 = corepack(]"--version"])
```

*New in v20.13.1*: pass `return_completed_process=True` to get `subprocess.CompletedProcess` instead of `int`.
Expand All @@ -82,6 +89,8 @@ return_code2 = npx(["--version"])
completed_process0 = node(["--version"], return_completed_process=True)
completed_process1 = npm(["--version"], return_completed_process=True)
completed_process2 = npx(["--version"], return_completed_process=True)
# corepack: New in v22.14.0
completed_process3 = corepack(["--version"], return_completed_process=True)
```

## License
Expand Down
9 changes: 9 additions & 0 deletions cmd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The project is powered by [scikit-build-core](/~https://github.com/scikit-build/sc
| Linux | x86_64 | 64 | glibc >= 2.17 | v18.18.0 |
| Linux | x86_64 | 64 | musl >= 1.2 | v20.14.0 |
| Linux | aarch64 | 64 | glibc >= 2.17 | v20.13.0 |
| Linux | aarch64 | 64 | musl >= 1.2 | v22.14.0 |
| macOS | x86_64 | 64 | >= macOS-11 | v18.18.0 |
| macOS | arm64 | 64 | >= macOS-11 | v20.11.1 |
| Windows | amd64 | 64 | | v18.18.0 |
Expand All @@ -48,6 +49,8 @@ Only available in the `nodejs-wheel` package.
node -h
npm -h
npx -h
# New in v22.14.0
corepack -h
```

### Run library module as a script
Expand All @@ -69,11 +72,15 @@ from nodejs_wheel import (
node,
npm,
npx,
# corepack: New in v22.14.0
corepack,
)

return_code0 = node(["--version"])
return_code1 = npm(["--version"])
return_code2 = npx(["--version"])
# corepack: New in v22.14.0
return_code3 = corepack(]"--version"])
```

*New in v20.13.1*: pass `return_completed_process=True` to get `subprocess.CompletedProcess` instead of `int`.
Expand All @@ -82,6 +89,8 @@ return_code2 = npx(["--version"])
completed_process0 = node(["--version"], return_completed_process=True)
completed_process1 = npm(["--version"], return_completed_process=True)
completed_process2 = npx(["--version"], return_completed_process=True)
# corepack: New in v22.14.0
completed_process3 = corepack(["--version"], return_completed_process=True)
```

## License
Expand Down
1 change: 1 addition & 0 deletions cmd/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ repository = "/~https://github.com/njzjz/nodejs-wheel"
node = "nodejs_wheel.executable:_node_entry_point"
npm = "nodejs_wheel.executable:_npm_entry_point"
npx = "nodejs_wheel.executable:_npx_entry_point"
corepack = "nodejs_wheel.executable:_corepack_entry_point"

[tool.hatch.version]
source = "vcs"
Expand Down
2 changes: 2 additions & 0 deletions nodejs_wheel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from __future__ import annotations

from .executable import (
corepack,
node,
npm,
npx,
)

__all__ = [
"corepack",
"node",
"npm",
"npx",
Expand Down
60 changes: 60 additions & 0 deletions nodejs_wheel/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,62 @@ def npx(
)


@overload
def corepack(
args: Iterable[str] | None, return_completed_process: Literal[True], **kwargs: Any
) -> subprocess.CompletedProcess[str | bytes]: ...


@overload
def corepack(
args: Iterable[str] | None,
return_completed_process: Literal[False] = ...,
**kwargs: Any,
) -> int: ...


@overload
def corepack(
args: Iterable[str] | None = None,
return_completed_process: bool = False,
**kwargs: Any,
) -> int | subprocess.CompletedProcess[str | bytes]: ...


def corepack(
args: Iterable[str] | None = None,
return_completed_process: bool = False,
**kwargs: Any,
) -> int | subprocess.CompletedProcess[str | bytes]:
"""Call the corepack executable with the given arguments.
Parameters
----------
args : Optional[list[str]], default=None
List of arguments to pass to the corepack executable.
If None, the arguments are taken from sys.argv[1:].
return_completed_process : bool, default=False
If True, return the CompletedProcess[str | bytes] object instead of the return code.
**kwargs : dict[str, Any]
Other arguments passed to subprocess.call
Returns
-------
int | subprocess.CompletedProcess[str | bytes]
Return code of the corepack executable, or the CompletedProcess[str | bytes] object.
"""
if args is None:
args = sys.argv[1:]
return call_node(
os.path.join(
ROOT_DIR, "lib", "node_modules", "corepack", "dist", "corepack.js"
),
*args,
return_completed_process=return_completed_process,
**kwargs,
)


def _node_entry_point() -> None:
raise SystemExit(node(close_fds=False))

Expand All @@ -250,3 +306,7 @@ def _npm_entry_point() -> None:

def _npx_entry_point() -> None:
raise SystemExit(npx(close_fds=False))


def _corepack_entry_point() -> None:
raise SystemExit(corepack(close_fds=False))
5 changes: 5 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from nodejs_wheel import (
corepack,
node,
npm,
npx,
Expand All @@ -9,14 +10,18 @@
return_code0 = node(["--version"])
return_code1 = npm(["--version"])
return_code2 = npx(["--version"])
return_code3 = corepack(["--version"])
assert return_code0 == 0
assert return_code1 == 0
assert return_code2 == 0
assert return_code3 == 0

completed_process0 = node(["--version"], return_completed_process=True)
completed_process1 = npm(["--version"], return_completed_process=True)
completed_process2 = npx(["--version"], return_completed_process=True)
completed_process3 = corepack(["--version"], return_completed_process=True)

assert completed_process0.returncode == 0
assert completed_process1.returncode == 0
assert completed_process2.returncode == 0
assert completed_process3.returncode == 0

0 comments on commit e4d6715

Please sign in to comment.