pyarmor 8.5.2__zip → 8.5.4__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. {pyarmor-8.5.2 → pyarmor-8.5.4}/PKG-INFO +1 -1
  2. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/__init__.py +1 -1
  3. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/__main__.py +14 -3
  4. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/context.py +35 -0
  5. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/default.cfg +19 -2
  6. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/generate.py +14 -2
  7. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/repack.py +156 -0
  8. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/config.py +1 -1
  9. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor.egg-info/PKG-INFO +1 -1
  10. pyarmor-8.5.4/pyarmor.egg-info/requires.txt +1 -0
  11. {pyarmor-8.5.2 → pyarmor-8.5.4}/setup.py +1 -1
  12. pyarmor-8.5.2/pyarmor.egg-info/requires.txt +0 -1
  13. {pyarmor-8.5.2 → pyarmor-8.5.4}/MANIFEST.in +0 -0
  14. {pyarmor-8.5.2 → pyarmor-8.5.4}/README.md +0 -0
  15. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/README.rst +0 -0
  16. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/__init__.py +0 -0
  17. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/benchmark.py +0 -0
  18. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/build_meta.py +0 -0
  19. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/bootstrap.py +0 -0
  20. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/bug.py +0 -0
  21. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/config.py +0 -0
  22. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/core.data.1 +0 -0
  23. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/core.data.2 +0 -0
  24. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/core.data.3 +0 -0
  25. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/docker.py +0 -0
  26. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/hdinfo.py +0 -0
  27. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/merge.py +0 -0
  28. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/mixer.py +0 -0
  29. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/plugin.py +0 -0
  30. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/public_capsule.zip +0 -0
  31. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/register.py +0 -0
  32. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/resource.py +0 -0
  33. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cli/shell.py +0 -0
  34. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/cobuilder.py +0 -0
  35. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/README-ZH.md +0 -0
  36. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/README.md +0 -0
  37. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/build-for-exe.bat +0 -0
  38. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/build-for-freeze.bat +0 -0
  39. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/build-with-project.bat +0 -0
  40. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/build-with-project.sh +0 -0
  41. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/cx_Freeze/hello.py +0 -0
  42. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/cx_Freeze/queens.py +0 -0
  43. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/cx_Freeze/setup.py +0 -0
  44. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/helloworld/foo.py +0 -0
  45. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/obfuscate-app.bat +0 -0
  46. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/obfuscate-app.sh +0 -0
  47. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/obfuscate-pkg.bat +0 -0
  48. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/obfuscate-pkg.sh +0 -0
  49. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pack-obfuscated-scripts.bat +0 -0
  50. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pack-obfuscated-scripts.sh +0 -0
  51. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/py2exe/hello.py +0 -0
  52. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/py2exe/queens.py +0 -0
  53. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/py2exe/setup.py +0 -0
  54. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Arithmetic.py +0 -0
  55. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Calls.py +0 -0
  56. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/CommandLine.py +0 -0
  57. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Constructs.py +0 -0
  58. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Dict.py +0 -0
  59. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Exceptions.py +0 -0
  60. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Imports.py +0 -0
  61. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Instances.py +0 -0
  62. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Lists.py +0 -0
  63. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Lookups.py +0 -0
  64. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/NewInstances.py +0 -0
  65. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Numbers.py +0 -0
  66. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Setup.py +0 -0
  67. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Strings.py +0 -0
  68. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/Tuples.py +0 -0
  69. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/With.py +0 -0
  70. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/clockres.py +0 -0
  71. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/package/__init__.py +0 -0
  72. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/package/submodule.py +0 -0
  73. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/pybench.py +0 -0
  74. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/pybench/systimes.py +0 -0
  75. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/simple/queens.py +0 -0
  76. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/testmod/hello.py +0 -0
  77. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/testmod/queens.py +0 -0
  78. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/testpkg/main.py +0 -0
  79. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/testpkg/mypkg/__init__.py +0 -0
  80. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/examples/testpkg/mypkg/foo.py +0 -0
  81. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/helper/__init__.py +0 -0
  82. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/helper/build_data_module.py +0 -0
  83. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/helper/buildext.py +0 -0
  84. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/helper/get_bind_key.py +0 -0
  85. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/helper/get_license_info.py +0 -0
  86. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/helper/get_platform_name.py +0 -0
  87. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/helper/merge.py +0 -0
  88. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/helper/repack.py +0 -0
  89. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/helper/superuntime.py +0 -0
  90. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/license.tri +0 -0
  91. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/packer.py +0 -0
  92. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/platforms/darwin/x86_64/_pytransform.dylib +0 -0
  93. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/platforms/linux/x86/_pytransform.so +0 -0
  94. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/platforms/linux/x86_64/_pytransform.so +0 -0
  95. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/platforms/windows/x86/_pytransform.dll +0 -0
  96. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/platforms/windows/x86_64/_pytransform.dll +0 -0
  97. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/plugins/README.md +0 -0
  98. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/plugins/check_ntp_time.py +0 -0
  99. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/polyfills/__init__.py +0 -0
  100. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/polyfills/argparse.py +0 -0
  101. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/product.key +0 -0
  102. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/project.py +0 -0
  103. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/protect_code.pt +0 -0
  104. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/protect_code2.pt +0 -0
  105. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/public.key +0 -0
  106. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/public_capsule.zip +0 -0
  107. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/pyarmor-deprecated.py +0 -0
  108. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/pyarmor-webui.py +0 -0
  109. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/pyarmor.py +0 -0
  110. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/pyimcore.py +0 -0
  111. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/pyshield.key +0 -0
  112. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/pyshield.lic +0 -0
  113. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/pytransform.py +0 -0
  114. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/reform.py +0 -0
  115. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/register.py +0 -0
  116. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/sppmode.py +0 -0
  117. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor/utils.py +0 -0
  118. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor.egg-info/SOURCES.txt +0 -0
  119. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor.egg-info/dependency_links.txt +0 -0
  120. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor.egg-info/entry_points.txt +0 -0
  121. {pyarmor-8.5.2 → pyarmor-8.5.4}/pyarmor.egg-info/top_level.txt +0 -0
  122. {pyarmor-8.5.2 → pyarmor-8.5.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: pyarmor
3
- Version: 8.5.2
3
+ Version: 8.5.4
4
4
  Summary: A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.
5
5
  Home-page: https://github.com/dashingsoft/pyarmor
6
6
  Author: Jondy Zhao
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
 
3
- __VERSION__ = '8.5.2'
3
+ __VERSION__ = '8.5.4'
4
4
 
5
5
  logger = logging.getLogger('cli')
6
6
 
@@ -107,6 +107,10 @@ def format_gen_args(ctx, args):
107
107
  options['no_runtime'] = True
108
108
  options['use_runtime'] = args.use_runtime
109
109
 
110
+ if (options.get('restrict_module', 0) == 2
111
+ and ctx.cfg['builder'].get('private_module_as_restrict', 0)):
112
+ options['restrict_module'] = 3
113
+
110
114
  if options.get('assert_call') or options.get('assert_import'):
111
115
  if options.get('restrict_module', 0) < 2:
112
116
  logger.debug('implicitly set restrict_module = 2')
@@ -132,7 +136,7 @@ def format_gen_args(ctx, args):
132
136
 
133
137
  if args.pack:
134
138
  dist_path = os.path.join(ctx.repack_path, 'dist')
135
- logger.info('implicitly set output to "%s"', dist_path)
139
+ logger.info('implicitly save obfuscated scripts to "%s"', dist_path)
136
140
  options['output'] = dist_path
137
141
 
138
142
  return options
@@ -205,8 +209,10 @@ def check_gen_context(ctx, args):
205
209
  raise CliError('--outer conflicts with any -e, --period, -b')
206
210
 
207
211
  if args.pack:
208
- if not os.path.isfile(args.pack):
209
- raise CliError('--pack must be an executable file')
212
+ choices = 'auto', 'onefile', 'onedir'
213
+ if args.pack not in choices and not os.path.isfile(args.pack):
214
+ raise CliError('--pack must be an executable file, '
215
+ '"auto", "onefile" or "onedir"')
210
216
  if args.no_runtime:
211
217
  raise CliError('--pack conficts with --no-runtime, --use-runtime')
212
218
  if ctx.import_prefix:
@@ -226,6 +232,11 @@ def cmd_gen(ctx, args):
226
232
  return _cmd_gen_key(builder, options)
227
233
  elif args.inputs[0].lower() in ('runtime', 'run', 'r'):
228
234
  _cmd_gen_runtime(builder, options)
235
+ elif args.pack in ('auto', 'onefile', 'onedir'):
236
+ from .repack import Repacker6
237
+ packer = Repacker6(ctx, args.pack, options['inputs'], args.output)
238
+ builder.process(options, packer)
239
+ Plugin.post_build(ctx, pack=args.pack)
229
240
  elif args.pack:
230
241
  from .repack import Repacker
231
242
  codesign = ctx.cfg['pack'].get('codesign_identify', None)
@@ -701,3 +701,38 @@ class Context(object):
701
701
  port = http_proxy[j+1:]
702
702
  url = b'http://pyarmor.dashingsoft.com'
703
703
  return b'\x00'.join([host, port, url, header, b'\x00'])
704
+
705
+ def request_token(self, url, timeout=6.0):
706
+ from urllib.request import urlopen
707
+
708
+ def get_response(host):
709
+ try:
710
+ from ssl import _create_unverified_context
711
+ context = _create_unverified_context()
712
+ req = 'https://%s%s' % (host, url)
713
+ except Exception:
714
+ context = None
715
+ req = 'http://%s%s' % (host, url)
716
+ return urlopen(req, None, timeout, context=context)
717
+
718
+ with get_response('pyarmor.dashingsoft.com') as res:
719
+ return res.read()
720
+
721
+ #
722
+ # Pack options for auto/onefile/onefolder mode
723
+ #
724
+ @property
725
+ def pyi_options(self):
726
+ from json import loads as json_loads
727
+ from shlex import split as split_opt
728
+ pyi_opts = []
729
+ jsmarker = 'json::'
730
+ for line in self.cfg['pack'].get('pyi_options', '').splitlines():
731
+ line = line.strip()
732
+ if line.startswith(jsmarker):
733
+ pyi_opts.extend(json_loads(line[len(jsmarker):]))
734
+ elif line.startswith('-'):
735
+ pyi_opts.extend(split_opt(line))
736
+ elif line:
737
+ pyi_opts.append(line)
738
+ return pyi_opts
@@ -3,10 +3,10 @@
3
3
  ;; Pyarmor version
4
4
  major = 8
5
5
  minor = 5
6
- patch = 2
6
+ patch = 4
7
7
 
8
8
  ;; Compatible core version
9
- cli.core = 6.5.0
9
+ cli.core = 6.5.1
10
10
 
11
11
  ;; Deprecated since Pyarmor 8.2.5
12
12
  ; cli.runtime = 3.2.5
@@ -192,6 +192,23 @@ clear_frame_locals = 0
192
192
  ;; Whether encrypt name in statement import
193
193
  rft_mix_import_name = 0
194
194
 
195
+ ;;
196
+ ;; Compatiable options
197
+ ;;
198
+
199
+ ;; Since pyarmor 8.5.3, pyarmor.core 6.5.1
200
+ ;;
201
+ ;; If private_module_same_as_restrict is set to 1, --private is same as --restrict, it's default behaviours in previous version. Both --private and --restrict don't allow plain scripts to import the obfsucated modules
202
+ ;;
203
+ ;; But the right way should be
204
+ ;;
205
+ ;; --private allow
206
+ ;; --restrict not allow
207
+ ;;
208
+ ;; When need this behaviours, set private_module_same_as_restrict is to 0
209
+ ;;
210
+ private_module_same_as_restrict = 0
211
+
195
212
  [runtime]
196
213
 
197
214
  ;; Generate extension for all Python3.7+
@@ -62,6 +62,13 @@ class Finder(object):
62
62
  self.ctx.obfuscated_modules.add(res.pkgname)
63
63
  self.ctx.extra_resources.append(res)
64
64
 
65
+ def append(self, resources):
66
+ resnames = [x.pkgname for x in self.ctx.resources]
67
+ for res in self._build_resource(resources):
68
+ if res.pkgname not in resnames:
69
+ self.ctx.obfuscated_modules.add(res.pkgname)
70
+ self.ctx.extra_resources.append(res)
71
+
65
72
  def process(self):
66
73
  logger.info('search inputs ...')
67
74
  self.prepare(self.ctx.input_paths)
@@ -149,8 +156,13 @@ class Builder(object):
149
156
  finder = Finder(self.ctx)
150
157
  finder.process()
151
158
 
152
- if packer and options.get('self_contained'):
153
- finder.process_extra(packer.contents)
159
+ if packer:
160
+ if options.get('self_contained'):
161
+ finder.process_extra(packer.contents)
162
+ if hasattr(packer, 'analysis'):
163
+ auto_resources = packer.analysis()
164
+ logger.info('find extra resources: %s', auto_resources)
165
+ finder.append(auto_resources)
154
166
 
155
167
  Pytransform3.pre_build(self.ctx)
156
168
 
@@ -3,6 +3,7 @@ import marshal
3
3
  import os
4
4
  import shutil
5
5
  import struct
6
+ import sys
6
7
  import tempfile
7
8
 
8
9
  from importlib._bootstrap_external import _code_to_timestamp_pyc
@@ -435,3 +436,158 @@ class Repacker:
435
436
  check_call(cmdlist, stdout=DEVNULL, stderr=DEVNULL)
436
437
  except Exception as e:
437
438
  logger.warning('%s', e)
439
+
440
+
441
+ # This patch is used to modify the specfile generate by PyInstaller
442
+ #
443
+ # It has 2 goals:
444
+ #
445
+ # 1. Find all the imported modules and packages
446
+ #
447
+ # Save them to hook script
448
+ #
449
+ # 2. Search scripts and packages in the path of entry script
450
+ #
451
+ # All of them will be obfuscated automatically
452
+ #
453
+ spec_patch_code = '''
454
+ from PyInstaller.compat import base_prefix
455
+ import marshal
456
+ import os
457
+
458
+ hiddenimports = set([])
459
+ plist = set([])
460
+ mlist = []
461
+ src = {src}
462
+ sn = len(src) + 1
463
+ prefix = os.path.relpath(src)
464
+ prefix = '' if prefix == '.' else prefix
465
+
466
+ for name, path, kind in a.pure:
467
+ if name.startswith('pyi_rth'):
468
+ continue
469
+ if path.startswith(src) and not path.startswith(base_prefix):
470
+ hiddenimports.add(name)
471
+ if name.find('.') == -1 and os.path.basename(path) != '__init__.py':
472
+ mlist.append(os.path.join(prefix, path[sn:]))
473
+ else:
474
+ pkgname = os.path.dirname(path[sn:]).split(os.sep)[0]
475
+ plist.add(os.path.join(prefix, pkgname))
476
+ else:
477
+ hiddenimports.add(name.split('.')[0])
478
+
479
+ with open({resfile}, 'wb') as f:
480
+ marshal.dump(mlist + list(plist), f)
481
+ with open({hookscript}, 'w') as f:
482
+ f.write("hiddenimports=[%s]" % ", ".join([repr(x) for x in hiddenimports]))
483
+ '''
484
+
485
+
486
+ class Repacker6:
487
+ """New repacker to support PyInstaller 6.0+
488
+
489
+ Args:
490
+ ctx: build context
491
+ mode: onefile or onefolder
492
+ inputs: main script to pack
493
+ """
494
+
495
+ def __init__(self, ctx, mode, inputs, output):
496
+ self.ctx = ctx
497
+ self.inputs = inputs
498
+ self.output = 'dist' if output is None else os.path.normpath(output)
499
+
500
+ self.script = self.inputs[0]
501
+ self.packpath = os.path.normpath(self.ctx.repack_path)
502
+ self.workpath = os.path.join(self.packpath, 'build')
503
+ self.obfpath = os.path.join(self.packpath, 'dist')
504
+ self.pyicmd = [sys.executable, '-m', 'PyInstaller']
505
+ self.pyiopts = self.init_opts(mode)
506
+
507
+ def init_opts(self, mode):
508
+ opts = []
509
+ exopts = '--noconfirm', '-y'
510
+ if mode == 'auto':
511
+ exopts += ('--onefile', '-F', '--onefolder', '-D')
512
+ else:
513
+ opts.append('-F' if mode == 'onefile' else '-D')
514
+ opts.extend(self.ctx.pyi_options)
515
+
516
+ exvalues = '--distpath', '--specpath', '--workpath'
517
+ return self.filter_opts(opts, exvalues, exopts)
518
+
519
+ def filter_opts(self, opts, exvalues, exopts=None):
520
+ result = []
521
+ isvalue = False
522
+ for x in opts:
523
+ if isvalue:
524
+ isvalue = False
525
+ elif x in exvalues:
526
+ isvalue = True
527
+ elif exopts is None or x not in exopts:
528
+ result.append(x)
529
+ return result
530
+
531
+ def analysis(self):
532
+ """Got imported modules and packages by PyInstaller
533
+
534
+ Generate hook script
535
+ Return file/dir list need to be obfuscated
536
+ """
537
+ cmdspec = [
538
+ sys.executable, '-m', 'PyInstaller.utils.cliutils.makespec',
539
+ '--specpath', self.packpath
540
+ ]
541
+ cmdspec.extend(self.filter_opts(self.pyiopts, ('--name', '-N')))
542
+ cmdspec.append(self.script)
543
+ check_call(cmdspec)
544
+
545
+ name = os.path.splitext(os.path.basename(self.script))[0]
546
+ rtname = self.ctx.runtime_package_name
547
+ specfile = os.path.join(self.packpath, name + '.spec')
548
+ resfile = os.path.join(self.packpath, 'resources.list')
549
+ hookscript = os.path.join(self.packpath, 'hook-%s.py' % rtname)
550
+ self.patch_specfile(specfile, hookscript, resfile)
551
+
552
+ cmdlist = self.pyicmd + ['--clean', '--workpath', self.workpath]
553
+ cmdlist.extend(self.pyiopts)
554
+ cmdlist.append(specfile)
555
+ check_call(cmdlist)
556
+
557
+ with open(resfile, 'rb') as f:
558
+ return marshal.load(f)
559
+
560
+ def build(self):
561
+ """Generate final bundle to output"""
562
+ script = os.path.join(self.obfpath, os.path.basename(self.inputs[0]))
563
+ cmdlist = self.pyicmd + [
564
+ '--clean',
565
+ '--distpath', self.output,
566
+ '--workpath', self.workpath,
567
+ '--specpath', self.packpath,
568
+ '--additional-hooks-dir', self.packpath,
569
+ ]
570
+ cmdlist.extend(self.pyiopts)
571
+ cmdlist.append(script)
572
+ check_call(cmdlist)
573
+
574
+ def repack(self, *unused):
575
+ """Only for compatible with Repacker"""
576
+ self.build()
577
+
578
+ def patch_specfile(self, specfile, hookscript, resfile):
579
+ # TODO: non-ascii need specify encoding to open file
580
+ lines = []
581
+ with open(specfile, 'r') as f:
582
+ for line in f:
583
+ if line.startswith('pyz = PYZ'):
584
+ break
585
+ lines.append(line)
586
+
587
+ lines.append(spec_patch_code.format(
588
+ src=repr(os.path.abspath(os.path.dirname(self.script))),
589
+ hookscript=repr(os.path.abspath(hookscript)),
590
+ resfile=repr(os.path.abspath(resfile))))
591
+
592
+ with open(specfile, 'w') as f:
593
+ f.write(''.join(lines))
@@ -1,6 +1,6 @@
1
1
  from sys import platform
2
2
 
3
- version = '8.5.2'
3
+ version = '8.5.4'
4
4
 
5
5
  # The corresponding version of pytransform.so
6
6
  core_version = 'r52.6'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: pyarmor
3
- Version: 8.5.2
3
+ Version: 8.5.4
4
4
  Summary: A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.
5
5
  Home-page: https://github.com/dashingsoft/pyarmor
6
6
  Author: Jondy Zhao
@@ -0,0 +1 @@
1
+ pyarmor.cli.core~=6.5.1
@@ -113,7 +113,7 @@ setup(
113
113
  },
114
114
 
115
115
  install_requires=[
116
- 'pyarmor.cli.core~=6.5.0'
116
+ 'pyarmor.cli.core~=6.5.1'
117
117
  ],
118
118
 
119
119
  entry_points={
@@ -1 +0,0 @@
1
- pyarmor.cli.core~=6.5.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes