Skip to content

Commit cf2874f

Browse files
committed
Add support for "import nodejs; nodejs.node" pattern. samwillis#7
1 parent 2ff8933 commit cf2874f

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

make_wheels.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010

1111
# Versions to build if run as a script:
12-
BUILD_VERSIONS = ('14.19.3', '16.15.1', '18.4.0')
12+
BUILD_VERSIONS = ('14.19.3',)# '16.15.1', '18.4.0')
1313

1414
# Suffix to append to the Wheel
1515
# For pre release versions this should be 'aN', e.g. 'a1'
1616
# For release versions this should be ''
1717
# See https://peps.python.org/pep-0427/#file-name-convention for details.
18-
BUILD_SUFFIX = 'a2'
18+
BUILD_SUFFIX = 'a3'
1919

2020
# Main binary for node
2121
# Path of binary inn downloaded distribution to match
@@ -38,13 +38,13 @@
3838

3939
# Mapping of node platforms to Python platforms
4040
PLATFORMS = {
41-
'win-x86': 'win32',
42-
'win-x64': 'win_amd64',
41+
# 'win-x86': 'win32',
42+
# 'win-x64': 'win_amd64',
4343
'darwin-x64': 'macosx_10_9_x86_64',
44-
'darwin-arm64': 'macosx_11_0_arm64',
45-
'linux-x64': 'manylinux_2_12_x86_64.manylinux2010_x86_64',
46-
'linux-armv7l': 'manylinux_2_17_armv7l.manylinux2014_armv7l',
47-
'linux-arm64': 'manylinux_2_17_aarch64.manylinux2014_aarch64',
44+
# 'darwin-arm64': 'macosx_11_0_arm64',
45+
# 'linux-x64': 'manylinux_2_12_x86_64.manylinux2010_x86_64',
46+
# 'linux-armv7l': 'manylinux_2_17_armv7l.manylinux2014_armv7l',
47+
# 'linux-arm64': 'manylinux_2_17_aarch64.manylinux2014_aarch64',
4848
}
4949

5050

@@ -111,12 +111,7 @@ def write_wheel(out_dir, *, name, version, tag, metadata, description, contents,
111111
def write_nodejs_wheel(out_dir, *, node_version, version, platform, archive):
112112
contents = {}
113113
entry_points = {}
114-
contents['nodejs/__init__.py'] = cleandoc(f"""
115-
from .node import path, main, call, run, Popen
116-
117-
__version__ = "{version}"
118-
node_version = "{node_version}"
119-
""").encode('ascii')
114+
init_imports = []
120115

121116
with libarchive.memory_reader(archive) as archive:
122117
for entry in archive:
@@ -130,6 +125,7 @@ def write_nodejs_wheel(out_dir, *, node_version, version, platform, archive):
130125

131126
if entry_name in NODE_BINS:
132127
# entry_points['node'] = 'nodejs.node:main'
128+
init_imports.append('from . import node')
133129
contents['nodejs/node.py'] = cleandoc(f"""
134130
import os, sys, subprocess
135131
@@ -167,6 +163,7 @@ def main():
167163
""").encode('ascii')
168164
elif entry_name in NODE_OTHER_BINS and NODE_OTHER_BINS[entry_name][1]:
169165
# entry_points[NODE_OTHER_BINS[entry_name][0]] = f'nodejs.{NODE_OTHER_BINS[entry_name][0]}:main'
166+
init_imports.append(f'from . import {NODE_OTHER_BINS[entry_name][0]}')
170167
script_name = '/'.join(os.path.normpath(os.path.join(os.path.dirname(entry.name), entry.linkpath)).split('/')[1:])
171168
contents[f'nodejs/{NODE_OTHER_BINS[entry_name][0]}.py'] = cleandoc(f"""
172169
import os, sys
@@ -198,6 +195,7 @@ def main():
198195
""").encode('ascii')
199196
elif entry_name in NODE_OTHER_BINS:
200197
# entry_points[NODE_OTHER_BINS[entry_name][0]] = f'nodejs.{NODE_OTHER_BINS[entry_name][0]}:main'
198+
init_imports.append(f'from . import {NODE_OTHER_BINS[entry_name][0]}')
201199
contents[f'nodejs/{NODE_OTHER_BINS[entry_name][0]}.py'] = cleandoc(f"""
202200
import os, sys, subprocess
203201
@@ -225,6 +223,18 @@ def main():
225223
if __name__ == '__main__':
226224
main()
227225
""").encode('ascii')
226+
227+
contents['nodejs/__init__.py'] = (cleandoc("""
228+
from .node import path, main, call, run, Popen
229+
{init_imports}
230+
231+
__version__ = "{version}"
232+
node_version = "{node_version}"
233+
""")).format(
234+
init_imports='\n'.join(init_imports),
235+
version=version,
236+
node_version=node_version,
237+
).encode('ascii')
228238

229239
with open('README.md') as f:
230240
description = f.read()

0 commit comments

Comments
 (0)