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
This commit is contained in:
rdb 2022-03-02 10:45:57 +01:00
parent 2334f48e89
commit 76fb49252c
2 changed files with 18 additions and 8 deletions

View File

@ -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',

View File

@ -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