From db4516b796a4fcff65e5a17e747fc3a75170ec32 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 9 Jan 2017 20:14:25 -0800 Subject: [PATCH] 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. --- direct/src/showutil/FreezeTool.py | 24 +++++++++++++++++++++++- direct/src/showutil/dist.py | 7 +++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/direct/src/showutil/FreezeTool.py b/direct/src/showutil/FreezeTool.py index 1c07fdbda4..0b212afba0 100644 --- a/direct/src/showutil/FreezeTool.py +++ b/direct/src/showutil/FreezeTool.py @@ -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. diff --git a/direct/src/showutil/dist.py b/direct/src/showutil/dist.py index 2f57e32a2f..b511b77f5f 100644 --- a/direct/src/showutil/dist.py +++ b/direct/src/showutil/dist.py @@ -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")