MCPcopy Index your code
hub / github.com/dashingsoft/pyarmor-webui / _build_target

Method _build_target

handler8.py:234–368  ·  view source on GitHub ↗
(self, path, args, debug=False)

Source from the content-addressed store, hash-verified

232
233 @enter_temp_path
234 def _build_target(self, path, args, debug=False):
235 homepath = self._config['homepath']
236
237 target = args.get('buildTarget')
238 self._check_arg('target', target, valids=[0, 1, 2, 3])
239
240 src = self._format_path(args.get('src'))
241 name = args.get('bundleName')
242 output = self._format_path(args.get('output'))
243 if not output:
244 output = os.path.join(src, 'dist')
245 entries = args.get('entry', [])
246 cmd_args = ['gen']
247
248 if target:
249 pack = args.get('pack', [])
250 self._check_arg('pack', pack, types=list)
251 pyi_options = self._handle_pack_options(src, pack)
252 binext = '.exe' if sys.platform.startswith('win') else ''
253 entryname = name if name else os.path.splitext(entries[0])[0]
254 bundle = entryname + binext
255 distpath = os.path.basename(output)
256 if target in (2, 3):
257 pyi_options.append('--onefile')
258 distfile = os.path.join(distpath, bundle)
259 else:
260 distfile = os.path.join(distpath, entryname, bundle)
261 pyi_options.extend(['--distpath', distpath])
262 cmd_args.extend(['--pack', distfile])
263
264 if name:
265 pyi_options.extend(['--name', name])
266
267 pyi_options.append(os.path.join(src, entries[0]))
268 call_pyinstaller(pyi_options)
269
270 else:
271 if args.get('noRuntime'):
272 cmd_args.append('--no-runtime')
273
274 if name:
275 cmd_args.append('-i')
276
277 if args.get('platforms'):
278 pnames = args.get('platforms')
279 if any([x.startswith('themida.') for x in pnames]):
280 cmd_args.append('--enable-themida')
281 pnames = [x.replace('themida', 'windows') for x in pnames]
282 cmd_args.extend(['--platform', ','.join(pnames)])
283
284 cmd_args.extend(['--output', output])
285
286 restrict_mode = args.get('restrictMode', DEFAULT_RESTRICT_FLAG)
287 if restrict_mode & NO_RESTRICT_FLAG:
288 call_pyarmor(['cfg', 'restrict_module', '0'], homepath=homepath)
289 if restrict_mode & RESTRICT_PACKAGE_FLAG:
290 cmd_args.append('--restrict')
291 elif restrict_mode & PRIVATE_MODULE_FLAG:

Callers 2

_build_tempMethod · 0.95
do_buildMethod · 0.95

Calls 5

_handle_pack_optionsMethod · 0.95
call_pyinstallerFunction · 0.85
_check_argMethod · 0.80
_format_pathMethod · 0.80
call_pyarmorFunction · 0.70

Tested by

no test coverage detected