-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bundle shaders into a shader.py when building wheels
simplepbr will automatically handle bundled vs non-bundled. The main benefit of this is that users no longer need to take special action to copy shader files when making applications using Panda's build_apps.
- Loading branch information
Showing
3 changed files
with
43 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import shutil | ||
|
||
from distutils.command.install import install | ||
from distutils import log | ||
import setuptools | ||
|
||
|
||
class BundleShaders(setuptools.Command): | ||
def initialize_options(self): | ||
pass | ||
|
||
def finalize_options(self): | ||
pass | ||
|
||
def run(self): | ||
log.info('Bundling shaders') | ||
installcmd = self.distribution.get_command_obj('install') | ||
builddir = os.path.join(installcmd.root, 'simplepbr') | ||
shaderdir = os.path.join(builddir, 'shaders') | ||
shaders = {} | ||
for shaderpath in os.listdir(shaderdir): | ||
with open(os.path.join(shaderdir, shaderpath)) as shaderfile: | ||
shaders[shaderpath] = shaderfile.read() | ||
with open(os.path.join(builddir, 'shaders.py'), 'w') as shaderfile: | ||
shaderfile.write(f'shaders={repr(shaders)}') | ||
shutil.rmtree(shaderdir) | ||
|
||
install.sub_commands.append(('bundle_shaders', None)) | ||
|
||
setuptools.setup( | ||
cmdclass={'bundle_shaders': BundleShaders} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters