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

add nodejs-wheel #28400

Merged
merged 4 commits into from
Nov 29, 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
48 changes: 48 additions & 0 deletions recipes/nodejs-wheel/0001-hack-ROOT_DIR.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
From 3c744fcf21d755f393a533df49afdb0c52ce9be3 Mon Sep 17 00:00:00 2001
From: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Date: Thu, 28 Nov 2024 18:44:21 -0500
Subject: [PATCH] hack ROOT_DIR

---
nodejs_wheel/executable.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/nodejs_wheel/executable.py b/nodejs_wheel/executable.py
index 42f216e..e435399 100644
--- a/nodejs_wheel/executable.py
+++ b/nodejs_wheel/executable.py
@@ -10,7 +10,12 @@ try:
except ImportError:
from typing_extensions import Literal # type: ignore

-ROOT_DIR = os.path.dirname(__file__)
+if os.name == "nt":
+ ROOT_DIR = os.path.join(os.path.dirname(__file__), "..", "..", "..")
+ NODE_MODULES_DIR = os.path.join(ROOT_DIR, "node_modules")
+else:
+ ROOT_DIR = os.path.join(os.path.dirname(__file__), "..", "..", "..", "..")
+ NODE_MODULES_DIR = os.path.join(ROOT_DIR, "lib", "node_modules")


@overload
@@ -179,7 +184,7 @@ def npm(
if args is None:
args = sys.argv[1:]
return call_node(
- os.path.join(ROOT_DIR, "lib", "node_modules", "npm", "bin", "npm-cli.js"),
+ os.path.join(NODE_MODULES_DIR, "npm", "bin", "npm-cli.js"),
*args,
return_completed_process=return_completed_process,
**kwargs,
@@ -233,7 +238,7 @@ def npx(
if args is None:
args = sys.argv[1:]
return call_node(
- os.path.join(ROOT_DIR, "lib", "node_modules", "npm", "bin", "npx-cli.js"),
+ os.path.join(NODE_MODULES_DIR, "npm", "bin", "npx-cli.js"),
*args,
return_completed_process=return_completed_process,
**kwargs,
--
2.34.1

57 changes: 57 additions & 0 deletions recipes/nodejs-wheel/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{% set name = "nodejs-wheel" %}
{% set version = "22.11.0" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://github.com/njzjz/nodejs-wheel/archive/v{{ version }}.tar.gz
sha256: 66a58de579f1d2fb64aa021ef324877375beb0b86596d4ddb4edfadcbb714f81
patches:
- 0001-hack-ROOT_DIR.patch

build:
noarch: python
number: 0
script_env:
- SETUPTOOLS_SCM_PRETEND_VERSION={{ version }}
- SKBUILD_WHEEL_CMAKE=0
script: "{{ PYTHON }} -m pip install . -vv"

requirements:
host:
- python {{ python_min }}
- pip
- scikit-build-core
- setuptools_scm
run:
- python >={{ python_min }}
# unpin nodejs, so downstream packages can control the version
- nodejs

test:
imports:
- nodejs_wheel
requires:
- python {{ python_min }}
- pip
commands:
- python -m nodejs_wheel --version
- pip check

about:
home: https://github.com/njzjz/nodejs-wheel
summary: 'Python wrapper for Node.js wheels'
description: |
On PyPI, nodejs-wheel is unoffical Node.js wheels;
on conda-forge, only the Python wrapper is provided.
license: MIT
license_family: MIT
license_file: LICENSE
doc_url: https://github.com/njzjz/nodejs-wheel
dev_url: https://github.com/njzjz/nodejs-wheel

extra:
recipe-maintainers:
- njzjz
15 changes: 15 additions & 0 deletions recipes/nodejs-wheel/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from nodejs_wheel import (
node,
npm,
npx,
)


return_code0 = node(["--version"])
assert return_code0 == 0

return_code1 = npm(["--version"])
assert return_code1 == 0

return_code2 = npx(["--version"])
assert return_code2 == 0