cx_Freeze icon indicating copy to clipboard operation
cx_Freeze copied to clipboard

Support PEP517

Open calendulish opened this issue 2 years ago • 5 comments

Describe the bug currently cx_Freeze seems not compatible with PEP517 build frontends. For example, when try to build a simple package using build the build will fail with ValueError: Egg metadata expected. Same occurs using pip. It's important that this operation works as the whole python packaging system is moving to this path

To Reproduce try to build a cx_Freeze project using python -m build or pip install .

Expected behavior successfully build the package

Desktop (please complete the following information):

  • Platform information (e.g. Ubuntu Linux 16.04): MINGW
  • OS architecture (e.g. amd64): x86_64
  • cx_Freeze version [e.g. 6.6]: 6.10-1
  • Python version [e.g. 3.9]: 3.9.12

Additional context error with python -m build:

Traceback (most recent call last):
  File "I:\msys64\mingw64\lib\python3.9\site-packages\pep517\in_process\_in_process.py", line 363, in <module>
    main()
  File "I:\msys64\mingw64\lib\python3.9\site-packages\pep517\in_process\_in_process.py", line 345, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "I:\msys64\mingw64\lib\python3.9\site-packages\pep517\in_process\_in_process.py", line 261, in build_wheel
    return _build_backend().build_wheel(wheel_directory, config_settings,
  File "I:\msys64\mingw64\lib\python3.9\site-packages\setuptools\build_meta.py", line 230, in build_wheel
    return self._build_with_temp_dir(['bdist_wheel'], '.whl',
  File "I:\msys64\mingw64\lib\python3.9\site-packages\setuptools\build_meta.py", line 215, in _build_with_temp_dir
    self.run_setup()
  File "I:\msys64\mingw64\lib\python3.9\site-packages\setuptools\build_meta.py", line 158, in run_setup

    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 213, in <module>
    setup(
  File "I:\msys64\mingw64\lib\python3.9\site-packages\cx_Freeze\dist.py", line 447, in setup
    setuptools.setup(**attrs)
  File "I:\msys64\mingw64\lib\python3.9\site-packages\setuptools\__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "I:\msys64\mingw64\lib\python3.9\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "I:\msys64\mingw64\lib\python3.9\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "I:\msys64\mingw64\lib\python3.9\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "I:\msys64\mingw64\lib\python3.9\site-packages\wheel\bdist_wheel.py", line 351, in run
    self.egg2dist(self.egginfo_dir, distinfo_dir)
  File "I:\msys64\mingw64\lib\python3.9\site-packages\wheel\bdist_wheel.py", line 461, in egg2dist
    raise ValueError(err)
ValueError: Egg metadata expected at build\bdist.mingw_x86_64\wheel\.\test-1.0-py3.9.egg-info but not found

ERROR Backend subproccess exited when trying to invoke build_wheel

error with pip install .:

  Traceback (most recent call last):
    File "I:\msys64\mingw64\lib\python3.9\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
      main()
    File "I:\msys64\mingw64\lib\python3.9\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "I:\msys64\mingw64\lib\python3.9\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 261, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "I:\msys64\mingw64\lib\python3.9\site-packages\setuptools\build_meta.py", line 230, in build_wheel
      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
    File "I:\msys64\mingw64\lib\python3.9\site-packages\setuptools\build_meta.py", line 215, in _build_with_temp_dir
      self.run_setup()
    File "I:\msys64\mingw64\lib\python3.9\site-packages\setuptools\build_meta.py", line 158, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 213, in <module>
      setup(
    File "I:\msys64\mingw64\lib\python3.9\site-packages\cx_Freeze\dist.py", line 447, in setup
      setuptools.setup(**attrs)
    File "I:\msys64\mingw64\lib\python3.9\site-packages\setuptools\__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "I:\msys64\mingw64\lib\python3.9\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "I:\msys64\mingw64\lib\python3.9\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "I:\msys64\mingw64\lib\python3.9\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "I:\msys64\mingw64\lib\python3.9\site-packages\wheel\bdist_wheel.py", line 351, in run
      self.egg2dist(self.egginfo_dir, distinfo_dir)
    File "I:\msys64\mingw64\lib\python3.9\site-packages\wheel\bdist_wheel.py", line 461, in egg2dist
      raise ValueError(err)
  ValueError: Egg metadata expected at build\bdist.mingw_x86_64\wheel\.\test-1.0-py3.9.egg-info but not found
  error: subprocess-exited-with-error

  × Building wheel for test (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: 'I:\msys64\mingw64\bin\python.exe' 'I:\msys64\mingw64\lib\python3.9\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\micro\AppData\Local\Temp\tmphpfq77gu'
  cwd: I:\Develop\test
error
  ERROR: Failed building wheel for test
Failed to build test
ERROR: Could not build wheels for test, which is required to install pyproject.toml-based projects
```

calendulish avatar Apr 30 '22 21:04 calendulish

Are you trying to build cx_Freeze or a test project? For cx_Freeze, you must use --no-build-isolation in MinGW. And, for MSYS2 you can get binary package using mingw-w64-python-cx-freeze. Also, development version is in packages

marcelotduarte avatar May 01 '22 00:05 marcelotduarte

I'm trying to build a test project using cx_Freeze not cx_Freeze itself. Actually I'm already using --no-build-isolation for this build in specific, but the problem seems to be the same in other scenarios I'm using the binary package for msys2. It's working fine using the old way (./setup.py build). error only occurs when trying to build using PEP517 Development packages for MSYS2 is returning 404 on page you suggest

calendulish avatar May 01 '22 01:05 calendulish

Development packages for MSYS2 is returning 404 on page you suggest

Fixed.

currently cx_Freeze seems not compatible with PEP517 build frontends

Building cx_Freeze is compatible with PEP517/518.

The objective of cx_Freeze is to "Create standalone executables..." and PEP517 define how to create sdist and wheels, and PEP518 defines file-formats overwriting PEP508. So, this is not a bug. Obviously, we can use the same ideas to create executables instead of wheels.

To Reproduce try to build a cx_Freeze project using python -m build or pip install .

There is nothing in the documentation that suggests this is the command to build cx_Freeze. The correct in any environment, including MSYS2, is: python setup.py build

If you check the error of the first command you tried: ERROR Backend subproccess exited when trying to invoke build_wheel

This error is correct because cx_Freeze does not build wheels.

I understand that you are suggesting the support for a PEP517-like feature, maybe supporting pyproject.toml.

marcelotduarte avatar May 02 '22 07:05 marcelotduarte

I understand that you are suggesting the support for a PEP517-like feature, maybe supporting pyproject.toml.

Exactly, as nowadays the use of setup.py is discouraged in favour of pyproject.toml together with setup.cfg.

Maybe a console script as custom build frontend? so we can run something like python -m cx_Freeze build to build executables

calendulish avatar May 05 '22 03:05 calendulish

PEP 517 means having setup.py is no longer required (perhaps even discouraged?). cx_Freeze can't work without a setup.py though, right?

brenthuisman avatar Jul 31 '22 13:07 brenthuisman

pyproject.toml already can be used in conjunction to setup.py (only basic metadata and commands). Subscribe to #1569 for news.

marcelotduarte avatar Dec 28 '22 17:12 marcelotduarte