deploy-ng: Look for correct platform suffixes for Python extension modules when cross-building

Note: We still need to supply suffixes for macOS. Also, Linux suffixes
are based on suffixes on my system (Arch, Python3) and will likely need
to be tweaked.
This commit is contained in:
Mitchell Stokes 2017-01-09 20:14:25 -08:00
parent 25b167c080
commit db4516b796
2 changed files with 28 additions and 3 deletions

View File

@ -717,6 +717,28 @@ class Freezer:
if path:
modulefinder.AddPackagePath(moduleName, path[0])
# Suffix/extension for Python C extension modules
if self.platform == PandaSystem.getPlatform():
self.moduleSuffixes = imp.get_suffixes()
else:
self.moduleSuffixes = [('.py', 'r', 1), ('.pyc', 'rb', 2)]
if 'linux' in self.platform:
self.moduleSuffixes += [
('.cpython-{0}{1}m-x86_64-linux-gnu.so'.format(*sys.version_info), 'rb', 3),
('.cpython-{0}{1}m-i686-linux-gnu.so'.format(*sys.version_info), 'rb', 3),
('.abi{}.so'.format(sys.version_info[0]), 'rb', 3),
('.so', 'rb', 3),
]
elif 'win' in self.platform:
self.moduleSuffixes += [
('.cp{0}{1}-win_amd64.pyd'.format(*sys.version_info), 'rb', 3),
('.cp{0}{1}-win32.pyd'.format(*sys.version_info), 'rb', 3),
('.dll', 'rb', 3),
]
else:
print("Unknown platform %s" % (self.platform))
self.moduleSuffixes = imp.get_suffixes()
def excludeFrom(self, freezer):
""" Excludes all modules that have already been processed by
the indicated FreezeTool. This is equivalent to passing the
@ -966,7 +988,7 @@ class Freezer:
else:
includes.append(mdef)
self.mf = PandaModuleFinder(excludes = list(excludeDict.keys()))
self.mf = PandaModuleFinder(excludes = list(excludeDict.keys()), suffixes=self.moduleSuffixes)
# Attempt to import the explicit modules into the modulefinder.

View File

@ -100,7 +100,7 @@ class build(distutils.command.build.build):
freezer_extras = set()
freezer_modules = set()
for app in self.distribution.applications:
freezer = FreezeTool.Freezer()
freezer = FreezeTool.Freezer(platform=platform)
freezer.addModule('__main__', filename=app.scriptname)
for exmod in self.distribution.exclude_modules:
freezer.excludeModule(exmod)
@ -226,7 +226,10 @@ class bdist_panda3d(distutils.core.Command):
pass
def run(self):
platforms = [p3d.PandaSystem.get_platform()]
if not self.distribution.deploy_platforms:
platforms = [p3d.PandaSystem.get_platform()]
else:
platforms = self.distribution.deploy_platforms
build_base = os.path.join(os.getcwd(), 'build')
self.run_command("build")