marcelotduarte / cx_Freeze

cx_Freeze creates standalone executables from Python scripts, with the same performance, is cross-platform and should work on any platform that Python itself works on.
https://marcelotduarte.github.io/cx_Freeze/
Other
1.35k stars 218 forks source link

cx_Freeze v6.10 does not support pre-release segments in versioning. #1387

Closed noahblumADS closed 2 years ago

noahblumADS commented 2 years ago

Describe the bug When attempting to freeze an application with python setup.py build_exe a version number that has pre-release segments, i.e. "1.0.0b1", "0.10.0rc4", cx_Freeze v6.10 fails to build, as the pre-release segment fails to convert from a string to an int.

To Reproduce

  1. In setup.py set your version number to any number including pre-release segments, i.e., "1.0.0b1", "3.2a6", "0.10.0rc4"
  2. In the terminal, navigate to your setup.py file, and using cx_Freeze v6.10 run python setup.py build_exe.

Expected behavior In previous versions of cx_Freeze, including 6.9, there were no errors when including pre-release segments in the version number, as they would build without issue.

Desktop

Additional context

Console Log Attached is my console log, I've removed the name of my virtual environment, application, and username. They are irrelevant to the issue.

running build_exe
creating directory C:\Users\███████\Documents\GitHub\███████\Executable
copying C:\Users\███████\AppData\Local\Programs\Python\Python39\python3.dll -> C:\Users\███████\Documents\GitHub\███████\Executable\python3.dll
copying C:\Users\███████\AppData\Local\Programs\Python\Python39\python39.dll -> C:\Users\███████\Documents\GitHub\███████\Executable\python39.dll
copying C:\Users\███████\Documents\Virtual Environments\███████\Lib\site-packages\cx_Freeze\bases\Win32GUI-cp39-win-amd64.exe -> C:\Users\███████\Documents\GitHub\███████\Executable\███████.exe
Traceback (most recent call last):
  File "C:\Users\███████\Documents\GitHub\███████\script\setup.py", line 31, in <module>
    setup(options=options,
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\cx_Freeze\dist.py", line 447, in setup
    setuptools.setup(**attrs)
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\setuptools\__init__.py", line 155, in setup
    return distutils.core.setup(**attrs)
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
    return run_commands(dist)
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
    dist.run_commands()
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
    self.run_command(cmd)
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
    cmd_obj.run()
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\cx_Freeze\dist.py", line 317, in run
    freezer.Freeze()
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\cx_Freeze\freezer.py", line 618, in Freeze
    self._freeze_executable(executable)
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\cx_Freeze\freezer.py", line 255, in _freeze_executable
    self._add_resources(exe)
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\cx_Freeze\freezer.py", line 701, in _add_resources
    version.stamp(target_path)
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\cx_Freeze\winversioninfo.py", line 210, in stamp
    string_version_info = self.version_info(path)
  File "C:\Users\███████\Documents\Virtual Environments\███████\lib\site-packages\cx_Freeze\winversioninfo.py", line 223, in version_info
    vmaj, vmin, vsub, vbuild = map(int, self.version.split("."))
ValueError: invalid literal for int() with base 10: '0b1'

Attached is my setup.py again with identifying information removed. In this case, the __version__ imported is "v0.10.0b1"

import sys
import os
from cx_Freeze import Executable, setup
from [[APP NAME]] import __version__

# Determine the base
base = 'Win32GUI' if sys.platform == 'win32' else None

PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

executables = [Executable(script='[[APP NAME]].py',
                          base=base,
                          target_name="[[APP NAME]].exe",
                          icon="C://Users//0144416//Documents//GitHub//[[APP NAME]]//script//images//turtle_icon.ico")]

options = {'build_exe': {'build_exe': "../Executable",
                         'include_files': ["../script",
                                           "[DATA FILE].spec",
                                           "../[[APP NAME]] Easy User Guide.pdf",
                                           "config_default.yaml",
                                           "__init__.py",
                                           "../fonts/",
                                           "images/",
                                           "themes/",
                                           "../package-licenses/",
                                           "../LICENSE.txt",
                                           "../CHANGELOG.md"]}}

setup(options=options,
      name="[[APP NAME]]",
      version=f"{__version__}",
      author="Noah Blum",
      description="[[APP NAME]]",
      executables=executables)
marcelotduarte commented 2 years ago

In previous versions of cx_Freeze, including 6.9, there were no errors when including pre-release segments in the version number, as they would build without issue.

I believe that in 6.9 the version is ignored in the final executable. Can you check the properties of it?

I'll check if stamp can be non-number.

noahblumADS commented 2 years ago

Hi,

I believe that in 6.9 the version is ignored in the final executable. Can you check the properties of it?

I believe this is what you're looking for? In which case it is not applied. image

If not, please let me know. I'm not too familiar with executable properties, so I wasn't too certain where to look.

marcelotduarte commented 2 years ago

This is the correct screen.

marcelotduarte commented 2 years ago

You can test the development release:

pip uninstall -y cx_Freeze
pip install -i https://marcelotduarte.github.io/packages/ cx_Freeze --pre
noahblumADS commented 2 years ago

When I run that second command, I get the following error:

Requirement already satisfied: cx-logging>=3.0 in c:\users\███████\documents\virtual environments\███████ (3.9)\lib\site-packages (from cx_Freeze) (3.0)
Requirement already satisfied: lief>=0.11.5 in c:\users\███████\documents\virtual environments\███████ (3.9)\lib\site-packages (from cx_Freeze) (0.11.5)
Requirement already satisfied: importlib-metadata>=4.8.3 in c:\users\███████\documents\virtual environments\███████ (3.9)\lib\site-packages (from cx_Freeze) (4.11.2)
ERROR: Could not find a version that satisfies the requirement packaging (from cx-freeze) (from versions: none)
ERROR: No matching distribution found for packaging

Any suggestions?

marcelotduarte commented 2 years ago

The correct command is: pip install --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze --pre --no-cache

marcelotduarte commented 2 years ago

@noahblumADS Do you have success?

spaam commented 2 years ago

@marcelotduarte i got a similar issue as @noahblumADS and i tried the version you got at marcelotduarte.github.io and it seems to fixed the issue.

thanks for fixing it ❤️

marcelotduarte commented 2 years ago

cx_Freeze 6.11 has just been released. pip install --upgrade cx_Freeze