-2

I am trying to figure out what is causing this file called builder.py to not run on mac even though it runs on windows. Code:

import cffi
import glob
import platform

# relative to build dir
LIB_BASE = '../libs/'
# compiling libraries statically to get a single binary
EXTRA_SRC = [LIB_BASE + 'subhook/subhook.c']

pltsysname = {'Windows': 'win32', 'Darwin': 'osx', 'Linux': 'elf'}
pltsrc = pltsysname[platform.system()]
pltsrc = LIB_BASE + 'plthook/plthook_{}.c'.format(pltsrc)
# EXTRA_SRC.append(pltsrc)  # disabled until it is actually useful

LIBDIRS = []
if platform.system() == 'Windows':
LIBDIRS.append('../libs/SDL/lib/x86/')

CDEFS = 'generated internals SDL XDL subhook xternPython'.split()


def readfile(name):
with open(name, 'r') as f:
    content = f.read()
return content


def build():
ffibuilder = cffi.FFI()

for fname in CDEFS:
    ffibuilder.cdef(readfile('cdefs/{}.h'.format(fname)))

ffibuilder.embedding_api('uint32_t kickstart();')
ffibuilder.embedding_init_code(readfile('remote.py'))

ffibuilder.set_source(
    '_remote', readfile('cdefs/remote.c'), sources=EXTRA_SRC,
    libraries=['SDL2'], library_dirs=LIBDIRS,
    define_macros=[('SUBHOOK_STATIC', None)])

ffibuilder.compile(tmpdir='build', target='remote.bin')


if __name__ == '__main__':
build()

When ever I run it I expect it to run but instead it comes up with the following error:

Traceback (most recent call last):
File "/Users/alexanderlee/Desktop/sbpe-1.6.1/builder.py", line 1, in <module>
import cffi
ModuleNotFoundError: No module named 'cffi'
>>> 

How do I fix it?

Alex Lee
  • 1
  • 3

2 Answers2

0

It's probably because you only installed cffi on your Windows, so you probably need to install it on your Mac also.

You can follow rules on the docs:

pip install cffi

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
0

cffi is a third-party module. It's installed on your Windows computer but not on your Mac.

John Gordon
  • 29,573
  • 7
  • 33
  • 58