Skip to content

Commit c9c6951

Browse files
committed
chore(python): use nodejs-wheel in place of nodejs-bin dependency
1 parent 08f639c commit c9c6951

File tree

8 files changed

+42
-36
lines changed

8 files changed

+42
-36
lines changed

python/neuroglancer/server.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,11 @@ def set_static_content_source(*args, **kwargs):
519519

520520

521521
def set_dev_server_content_source():
522-
import nodejs
523-
524522
static_content_url = None
525523
root_dir = os.path.join(os.path.dirname(__file__), "..", "..")
526-
build_process = nodejs.npm.Popen(
524+
build_process = subprocess.Popen(
527525
[
526+
"npm",
528527
"run",
529528
"dev-server-python",
530529
"--",

python/requirements-mypy.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ pytest-html
1111
requests
1212
filelock
1313
argcomplete
14-
nodejs-bin

python/requirements-nodejs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs-wheel>=20.11

python/requirements-test-browser.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
selenium>=4
2-
nodejs-bin[cmd]
1+
-r requirements-webdriver.txt
2+
-r requirements-nodejs.txt

python/requirements-webdriver.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
selenium>=4

python/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Pillow>=3.2.0
2+
numpy>=1.11.0
3+
requests
4+
tornado
5+
google-apitools
6+
google-auth
7+
atomicwrites

python/tests/client_test.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
def capture_screenshot_from_dev_server(
3333
webdriver, example_dir, test_fragment, extra_args=None
3434
):
35-
import nodejs
36-
3735
if sys.platform == "win32":
3836
process_group_args = dict(creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
3937
else:
@@ -43,8 +41,8 @@ def capture_screenshot_from_dev_server(
4341
# causes this test to hang when using a new process group rather than a
4442
# new session.
4543
process_group_args = dict(start_new_session=True)
46-
p = nodejs.npm.Popen(
47-
["run", "dev-server"] + (extra_args or []),
44+
p = subprocess.Popen(
45+
["npm", "run", "dev-server"] + (extra_args or []),
4846
stdin=subprocess.PIPE,
4947
stdout=subprocess.PIPE,
5048
stderr=subprocess.STDOUT,
@@ -102,9 +100,9 @@ def capture_screenshot_from_build(
102100
output_dir=None,
103101
extra_args=None,
104102
):
105-
import nodejs
106-
107-
nodejs.npm.run(["run", "build"] + (extra_args or []), cwd=example_dir, check=True)
103+
subprocess.run(
104+
["npm", "run", "build"] + (extra_args or []), cwd=example_dir, check=True
105+
)
108106
if output_dir is None:
109107
output_dir = os.path.join(example_dir, "dist")
110108

@@ -195,10 +193,10 @@ def example_dir(request):
195193
@pytest.fixture(scope="session")
196194
def built_package(request):
197195
def do_build():
198-
import nodejs
199-
200-
nodejs.npm.run(["install", "--no-fund", "--no-audit"], cwd=root_dir, check=True)
201-
nodejs.npm.run(["run", "build-package"], cwd=root_dir, check=True)
196+
subprocess.run(
197+
["npm", "install", "--no-fund", "--no-audit"], cwd=root_dir, check=True
198+
)
199+
subprocess.run(["npm", "run", "build-package"], cwd=root_dir, check=True)
202200

203201
get_xdist_session_value(
204202
do_build,
@@ -209,10 +207,8 @@ def do_build():
209207
@pytest.fixture(scope="session")
210208
def installed_example_dir(request, example_dir):
211209
def do_install():
212-
import nodejs
213-
214-
nodejs.npm.run(
215-
["install", "--no-fund", "--no-audit"],
210+
subprocess.run(
211+
["npm", "install", "--no-fund", "--no-audit"],
216212
cwd=os.path.join(root_dir, example_dir),
217213
check=True,
218214
)

setup.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pathlib
99
import platform
1010
import shutil
11+
import subprocess
1112
import tempfile
1213

1314
import setuptools
@@ -26,6 +27,11 @@
2627
python_dir, "ext", "third_party", "openmesh", "OpenMesh", "src"
2728
)
2829

30+
31+
def _read_requirements(path: str) -> list[str]:
32+
return pathlib.Path(path).read_text(encoding="utf-8").splitlines()
33+
34+
2935
_SETUP_REQUIRES = [
3036
"setuptools_scm>=4.1.2",
3137
"numpy>=1.11.0",
@@ -35,7 +41,9 @@
3541
_PACKAGE_JSON_EXISTS = os.path.exists(os.path.join(root_dir, "package.json"))
3642

3743
if _PACKAGE_JSON_EXISTS:
38-
_SETUP_REQUIRES.append("nodejs-bin[cmd]")
44+
_SETUP_REQUIRES.extend(
45+
_read_requirements(os.path.join(python_dir, "requirements-nodejs.txt"))
46+
)
3947

4048

4149
with open(os.path.join(python_dir, "README.md"), encoding="utf-8") as f:
@@ -226,11 +234,9 @@ def run(self):
226234
if self.skip_npm_reinstall and os.path.exists(node_modules_path):
227235
print(f"Skipping `npm install` since {node_modules_path} already exists")
228236
else:
229-
import nodejs
230-
231-
nodejs.npm.run(["install"], cwd=root_dir, check=True)
232-
nodejs.npm.run(
233-
["run", t, "--", f"--output={output_dir}"], cwd=root_dir, check=True
237+
subprocess.run(["npm", "install"], cwd=root_dir, check=True)
238+
subprocess.run(
239+
["npm", "run", t, "--", f"--output={output_dir}"], cwd=root_dir, check=True
234240
)
235241

236242

@@ -295,15 +301,12 @@ def _no_guess_dev_version(version):
295301
"": "python",
296302
},
297303
setup_requires=_SETUP_REQUIRES,
298-
install_requires=[
299-
"Pillow>=3.2.0",
300-
"numpy>=1.11.0",
301-
"requests",
302-
"tornado",
303-
"google-apitools",
304-
"google-auth",
305-
"atomicwrites",
306-
],
304+
install_requires=_read_requirements(os.path.join(python_dir, "requirements.txt")),
305+
extras_require={
306+
"webdriver": _read_requirements(
307+
os.path.join(python_dir, "requirements-webdriver.txt")
308+
),
309+
},
307310
ext_modules=[
308311
setuptools.Extension(
309312
"neuroglancer._neuroglancer",

0 commit comments

Comments
 (0)