Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while creating binary's icon #718

Closed
cflavio opened this issue Aug 27, 2019 · 4 comments
Closed

Issue while creating binary's icon #718

cflavio opened this issue Aug 27, 2019 · 4 comments
Assignees
Labels
Milestone

Comments

@cflavio
Copy link
Contributor

@cflavio cflavio commented Aug 27, 2019

Hi, I'm using the new 1.10.4's feature for creating the binary's icon. But, I get this:

running bdist_apps
running build_apps
Building platforms: win_amd64
Gathering wheels for platform: win_amd64
Looking in indexes: https://pypi.org/simple, https://archive.panda3d.org/simple/opt, https://archive.panda3d.org/thirdparty
Collecting panda3d==1.10.4.1 (from -r /home/flavio/sync/yorg/requirements.txt (line 2))
  Using cached https://buildbot.panda3d.org/downloads/1318fd80d7fd48a84394ee86bad6a57c245206e1/opt/panda3d-1.10.4.1%2Bopt-cp35-cp35m-win_amd64.whl
  Saved ./build/__whl_cache__/panda3d-1.10.4.1+opt-cp35-cp35m-win_amd64.whl
Successfully downloaded panda3d
WARNING: You are using pip version 19.1.1, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Building runtime for platform: win_amd64
There are some missing modules: ['StringIO', '__builtin__', '_codecs_cn', '_codecs_hk', '_codecs_iso2022', '_codecs_jp', '_codecs_kr', '_codecs_tw', '_json', '_lsprof', '_multibytecodec', '_opcode', '_psutil_linux', '_psutil_windows', '_scproxy', '_winapi', '_yaml', 'cStringIO', 'contextmanager', 'ctypes.macholib.dyld', 'dateutil.tz.tzfile', 'dateutil.tz.tzutc', 'dummy.Process', 'iconv_codec', 'mmap', 'multiprocessing.AuthenticationError', 'multiprocessing.BufferTooShort', 'multiprocessing.TimeoutError', 'multiprocessing.cpu_count', 'multiprocessing.get_context', 'multiprocessing.get_start_method', 'multiprocessing.set_start_method', 'netbios', 'psutil._psutil_aix', 'psutil._psutil_bsd', 'psutil._psutil_osx', 'psutil._psutil_posix', 'psutil._psutil_sunos', 'psutil._psutil_windows', 'rfc822', 'sgmllib', 'thread', 'tz.tzlocal', 'tz.tzutc', 'win32wnet']
Traceback (most recent call last):
  File "bsetup.py", line 3, in <module>
    setup(name="yorg", options={'bdist_apps': {'installers': {'manylinux1_x86_64': ['xztar'], 'macosx_10_6_x86_64': ['xztar'], 'win_amd64': ['xztar']}}, 'build_apps': {'platforms': ['win_amd64'], 'gui_apps': {'yorg': 'main.py'}, 'include_modules': {'*': ['encodings.hex_codec']}, 'plugins': ['pandagl', 'p3openal_audio'], 'log_filename': '$USER_APPDATA/Yorg/p3d_log.log', 'icons': {'yorg': ['assets/images/icon/icon256_png.png', 'assets/images/icon/icon128_png.png', 'assets/images/icon/icon48_png.png', 'assets/images/icon/icon32_png.png', 'assets/images/icon/icon16_png.png']}, 'exclude_patterns': ['build/*', 'built/*', 'setup.py', 'requirements.txt', '*.swp', 'SConstruct', 'venv/*', '.git*', '*.pyc', 'options.yml'], 'include_patterns': ['**/yyagl/licenses/*', '**/licenses/*', '**/license.txt', '**/*.bam', '**/*.txo']}})
  File "/home/flavio/venv/lib/python3.5/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 1414, in run
    self.run_command('build_apps')
  File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 380, in run
    self.build_runtimes(platform, True)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 709, in build_runtimes
    create_runtime(appname, scriptname, False)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 669, in create_runtime
    self.update_pe_resources(appname, temp_file.name)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 463, in update_pe_resources
    pef.add_icon(icon)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/pefile.py", line 669, in add_icon
    icon._write_bitmap(buf, image, size, 8)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/p3d/DeploymentTools.py", line 413, in _write_bitmap
    assert closest_diff < 100
AssertionError

Anyway, if I remove that assertion, then I get this:

running bdist_apps
running build_apps
Building platforms: win_amd64
Gathering wheels for platform: win_amd64
Looking in indexes: https://pypi.org/simple, https://archive.panda3d.org/simple/opt, https://archive.panda3d.org/thirdparty
Collecting panda3d==1.10.4.1 (from -r /home/flavio/sync/yorg/requirements.txt (line 2))
  Using cached https://buildbot.panda3d.org/downloads/1318fd80d7fd48a84394ee86bad6a57c245206e1/opt/panda3d-1.10.4.1%2Bopt-cp35-cp35m-win_amd64.whl
  Saved ./build/__whl_cache__/panda3d-1.10.4.1+opt-cp35-cp35m-win_amd64.whl
Successfully downloaded panda3d
WARNING: You are using pip version 19.1.1, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Building runtime for platform: win_amd64
There are some missing modules: ['StringIO', '__builtin__', '_codecs_cn', '_codecs_hk', '_codecs_iso2022', '_codecs_jp', '_codecs_kr', '_codecs_tw', '_json', '_lsprof', '_multibytecodec', '_opcode', '_psutil_linux', '_psutil_windows', '_scproxy', '_winapi', '_yaml', 'cStringIO', 'contextmanager', 'ctypes.macholib.dyld', 'dateutil.tz.tzfile', 'dateutil.tz.tzutc', 'dummy.Process', 'iconv_codec', 'mmap', 'multiprocessing.AuthenticationError', 'multiprocessing.BufferTooShort', 'multiprocessing.TimeoutError', 'multiprocessing.cpu_count', 'multiprocessing.get_context', 'multiprocessing.get_start_method', 'multiprocessing.set_start_method', 'netbios', 'psutil._psutil_aix', 'psutil._psutil_bsd', 'psutil._psutil_osx', 'psutil._psutil_posix', 'psutil._psutil_sunos', 'psutil._psutil_windows', 'rfc822', 'sgmllib', 'thread', 'tz.tzlocal', 'tz.tzutc', 'win32wnet']
Traceback (most recent call last):
  File "bsetup.py", line 3, in <module>
    setup(name="yorg", options={'bdist_apps': {'installers': {'manylinux1_x86_64': ['xztar'], 'macosx_10_6_x86_64': ['xztar'], 'win_amd64': ['xztar']}}, 'build_apps': {'platforms': ['win_amd64'], 'gui_apps': {'yorg': 'main.py'}, 'include_modules': {'*': ['encodings.hex_codec']}, 'plugins': ['pandagl', 'p3openal_audio'], 'log_filename': '$USER_APPDATA/Yorg/p3d_log.log', 'icons': {'yorg': ['assets/images/icon/icon256_png.png', 'assets/images/icon/icon128_png.png', 'assets/images/icon/icon48_png.png', 'assets/images/icon/icon32_png.png', 'assets/images/icon/icon16_png.png']}, 'exclude_patterns': ['build/*', 'built/*', 'setup.py', 'requirements.txt', '*.swp', 'SConstruct', 'venv/*', '.git*', '*.pyc', 'options.yml'], 'include_patterns': ['**/yyagl/licenses/*', '**/licenses/*', '**/license.txt', '**/*.bam', '**/*.txo']}})
  File "/home/flavio/venv/lib/python3.5/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 1414, in run
    self.run_command('build_apps')
  File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 380, in run
    self.build_runtimes(platform, True)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 709, in build_runtimes
    create_runtime(appname, scriptname, False)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 669, in create_runtime
    self.update_pe_resources(appname, temp_file.name)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/commands.py", line 463, in update_pe_resources
    pef.add_icon(icon)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/dist/pefile.py", line 694, in add_icon
    icon._write_bitmap(buf, image, size, bpp)
  File "/home/flavio/venv/lib/python3.5/site-packages/direct/p3d/DeploymentTools.py", line 375, in _write_bitmap
    fp.write(rowalign)
TypeError: a bytes-like object is required, not 'str'
@Moguri Moguri added the deployment label Aug 27, 2019
@rdb

This comment has been minimized.

Copy link
Member

@rdb rdb commented Aug 28, 2019

Thanks for filing this. Could you share the icon files you are using and the setup.py syntax?

@rdb rdb added the bug label Aug 28, 2019
@rdb

This comment has been minimized.

Copy link
Member

@rdb rdb commented Aug 28, 2019

It looks like this line:

rowalign = '\0' * (-(size * 3) & 3)

Should actually be:

            rowalign = b'\0' * (-(size * 3) & 3)
@cflavio

This comment has been minimized.

Copy link
Contributor Author

@cflavio cflavio commented Aug 28, 2019

Could you share the icon files you are using and the setup.py syntax?

Icon files.

setup.py:

setup(
    name="yorg",
    options={
        'bdist_apps': {
            'installers': {
                'manylinux1_x86_64': ['xztar'],
                'macosx_10_6_x86_64': ['xztar'],
                'win_amd64': ['xztar', 'nsis']}},
        'build_apps': {
            'platforms': ['win_amd64'],
            'gui_apps': {'yorg': 'main.py'},
            'include_modules': {'*': ['encodings.hex_codec']},
            'plugins': ['pandagl', 'p3openal_audio'],
            'log_filename': '$USER_APPDATA/Yorg/p3d_log.log',
            'icons': {
                'yorg': [
                    'assets/images/icon/icon256_png.png',
                    'assets/images/icon/icon128_png.png',
                    'assets/images/icon/icon48_png.png',
                    'assets/images/icon/icon32_png.png',
                    'assets/images/icon/icon16_png.png']},
            'exclude_patterns': [
                'build/*', 'built/*', 'setup.py', 'requirements.txt',
                '*.swp', 'SConstruct', 'venv/*', '.git*', '*.pyc',
                'options.yml'],
            'include_patterns': [
                '**/yyagl/licenses/*', '**/licenses/*', '**/*.bam', '**/*.txo',
                '**/*.yml', '**/*.txt']}})

rowalign = b'\0' * (-(size * 3) & 3)

I've tested it and it fixes the issue.

rdb added a commit that referenced this issue Aug 28, 2019
This prevents infrequently occurring colors from being washed out.

See #718
@rdb rdb added this to the 1.10.5 milestone Aug 28, 2019
@rdb

This comment has been minimized.

Copy link
Member

@rdb rdb commented Aug 28, 2019

Thanks! I've checked in several fixes: for the Python 3 incompatibility issue, and for the first assert you reported, which was caused by an awful palettize algorithm I had used to produce the 8-bpp icon sizes that will wash out rarer colors on some icons. I've now properly implemented the median cut algorithm in PNMImage which should give higher-quality results to begin with.

As a workaround for the second issue, you can make sure that your images have an alpha channel.

These fixes will be in 1.10.5.

@rdb rdb closed this Aug 28, 2019
@rdb rdb self-assigned this Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.