Is it possible to package python scripts and DSO to a APP

Thanks @driazati for your more tips for package python scripts to a single app.

I have successfully package a simple test_py.py + tvm + libtvm_runtime.so into an single app using pyinstaller, and it runs ok. The only problem is the destination app’s size, more than 440MB (in a new created conda env).

I just want a minimum package with TVM’s RPC.

#! /usr/bin/python3.6
# -*- coding:utf-8 -*-

# test_py.py

import tvm
import sys
import tvm.rpc

print('test_py.py will run...')
ip_addr, ip_port = sys.argv[1].split(':')
remote = tvm.rpc.connect(ip_addr, int(ip_port))
add_func = remote.get_function('rpc.test_add')
print(add_func(10, 20))

List of files under package directory:

  • libtvm_runtime.so
  • test_py.py # → test_py.spec
  • tvm: init.py _ffi contrib parser rpc runtime support.py error.py

Content of the test_py.spec:

# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(['test_py.py'],
             pathex=['/data/huangxiaofeng/work/vsext_example/py_package'],
             binaries=[('libtvm_runtime.so', '.')],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='test_py',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=False,
          disable_windowed_traceback=False,
          target_arch=None,
          codesign_identity=None,
          entitlements_file=None )