From 76fb49252c158b534943eac5e5be69d643fce4e7 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 2 Mar 2022 10:45:57 +0100 Subject: [PATCH] dist: Fix regression with data_dir NameError in build_apps Fixes #1276 Also let's consistently use the term "assets" for all the application data (and not the gaming-specific term "game files") and use the term "data" for package data only --- direct/src/dist/commands.py | 19 ++++++++++++------- makepanda/makepandacore.py | 7 ++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index cd31b3073e..5af82606a3 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -513,7 +513,9 @@ class build_apps(setuptools.Command): else: # e.g. x86, x86_64, mips, mips64 suffix = '_' + abi.replace('-', '_') - self.build_binaries(lib_dir, platform + suffix) + # We end up copying the data multiple times to the same + # directory, but that's probably fine for now. + self.build_binaries(platform + suffix, lib_dir, data_dir) # Write out the icons to the res directory. for appname, icon in self.icon_objects.items(): @@ -532,13 +534,13 @@ class build_apps(setuptools.Command): if icon.getLargestSize() >= 192: icon.writeSize(192, os.path.join(res_dir, 'mipmap-xxxhdpi-v4', basename)) - self.build_data(data_dir, platform) + self.build_assets(platform, data_dir) # Generate an AndroidManifest.xml self.generate_android_manifest(os.path.join(build_dir, 'AndroidManifest.xml')) else: - self.build_binaries(build_dir, platform) - self.build_data(build_dir, platform) + self.build_binaries(platform, build_dir, build_dir) + self.build_assets(platform, build_dir) # Bundle into an .app on macOS if self.macos_main_app and 'macosx' in platform: @@ -750,7 +752,7 @@ class build_apps(setuptools.Command): with open(path, 'wb') as fh: tree.write(fh, encoding='utf-8', xml_declaration=True) - def build_binaries(self, binary_dir, platform): + def build_binaries(self, platform, binary_dir, data_dir=None): """ Builds the binary data for the given platform. """ use_wheels = True @@ -1121,6 +1123,9 @@ class build_apps(setuptools.Command): os.path.join(binary_dir, '..', '..', 'classes.dex')) # Extract any other data files from dependency packages. + if data_dir is None: + return + for module, datadesc in self.package_data_dirs.items(): if module not in freezer_modules: continue @@ -1161,11 +1166,11 @@ class build_apps(setuptools.Command): else: self.copy(source_path, target_path) - def build_data(self, data_dir, platform): + def build_assets(self, platform, data_dir): """ Builds the data files for the given platform. """ # Copy Game Files - self.announce('Copying game files for platform: {}'.format(platform), distutils.log.INFO) + self.announce('Copying assets for platform: {}'.format(platform), distutils.log.INFO) ignore_copy_list = [ '**/__pycache__/**', '**/*.pyc', diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index f0e2708401..25565db8f1 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -3366,7 +3366,12 @@ def SetOrigExt(x, v): ORIG_EXT[x] = v def GetExtensionSuffix(): - if CrossCompiling(): + if GetTarget() == 'windows': + if GetTargetArch() == 'x64': + return '.cp%d%d-win_amd64.pyd' % (sys.version_info[:2]) + else: + return '.cp%d%d-win32.pyd' % (sys.version_info[:2]) + elif CrossCompiling(): return '.{0}.so'.format(GetPythonABI()) else: import _imp