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.36k stars 220 forks source link

cx_Freeze should be installable from git revision #2660

Open hbielenia opened 1 week ago

hbielenia commented 1 week ago

Describe the bug It appears that cx_Freeze cannot be correctly installed on Windows from git revision. The installation works correctly when using wheel from PyPI, but this cannot be guaranteed to be immutable. Also, it appears that all necessary files are already pre-built in the repository, so using a wheel doesn't have to be a hard requirement.

This issue is similar to #2392, but that's a bit convoluted thread with no clear answers. Eventually, it seems the OP there managed to resolve the issue, but also wasn't attempting an installation from git revision, so their issues were likely different.

To Reproduce On a Windows system, clone the repository or download and unpack the ZIP archive that GitHub automatically creates for every commit. Mine was https://codeload.github.com/marcelotduarte/cx_Freeze/zip/a2474eab285634ff59f3768a506e6b13ae77715b.zip Navigate to cloned/unpacked directory and execute python install -m . or python install -m .[dev]. Then, check the site-packages/cx_Freeze/bases (the exact location differs based on Python installation settings) - at most, it should contain __pycache__ and __init__.py, whereas some .exe files should also be present.

Expected behavior site-packages/cx_Freeze/bases should have at least the same set of .exe files as when installing from pre-built wheel package.

Desktop: Windows 10 x86_64, cx_Freeze version 7.2.4, Python 3.12

marcelotduarte commented 1 week ago

The pre-built files work if you do not have the MS VC C compiler and use pip install -e. for development, debugging, etc. To build your wheels, you should read this. For Windows, use of build or pip wheel also works.

hbielenia commented 1 week ago

Thanks for prompt response :)

The prebuild files work if you do not have the MS VC C compiler and use pip install—e. for development, debugging, etc.

Ok, so I gather that editable install is the only way to use these prebuild binaries.

To build your wheels, you should read this. For Windows, use of build or pip wheel also works.

Yes, I believe this is what pip install (without -e) uses under the hood. Though it's worth mentioning that without compiler in place, this will not error out and happily produce a wheel that is installable, but broken.

marcelotduarte commented 2 days ago

execute python install -m . or python install -m .[dev]. Then, check the

Do you mean pip install -e .?

I believe this is what pip install (without -e) uses under the hood.

pip install, buids and install the package, bypassing the creation of a wheel.

But, back to the issue, I made a patch, can you test it? You can test with cloning it and also, can use: pip install git+https://github.com/marcelotduarte/cx_Freeze.git@refs/pull/2681/head

hbielenia commented 2 days ago

execute python install -m . or python install -m .[dev]. Then, check the

Do you mean pip install -e .?

Oh gee, I was meant to write python -m pip install . but it looks like commands have coalesced in my mind... pip install -e . works, to be clear - it's the non-editable installation that doesn't.

pip install, buids and install the package, bypassing the creation of a wheel.

I'm not an expert on Python packaging (worked as a developer for several years but rarely had to package something) but my python -m pip install output has this:

Building wheels for collected packages: cx_Freeze
  Building wheel for cx_Freeze (pyproject.toml) ... done
  Created wheel for cx_Freeze: filename=cx_Freeze-7.3.0.dev0-cp312-cp312-win_amd64.whl size=2146017 sha256=e0cf855f11b6c30608963d637b5f355a1dbea5795fe2f9d507263c699bb52c93
  Stored in directory: C:\Users\Hubert\AppData\Local\Temp\pip-ephem-wheel-cache-4mzeresk\wheels\e7\30\21\ec28bdec843c7888ab855d3d7b043c7c598b7bc3a4f31957f8

Of course I admit the possibility that this is totally misleading.

But, back to the issue, I made a patch, can you test it? You can test with cloning it and also, can use: pip install git+https://github.com/marcelotduarte/cx_Freeze.git@refs/pull/2681/head

Tested it and it appears to solve the issue - python -m pip install . installs the package into site-packages complete with the prebuilt files, and -e flag doesn't seem required anymore :+1:

marcelotduarte commented 2 days ago

I'm not an expert on Python packaging (worked as a developer for several years but rarely had to package something) but my python -m pip install output has this:

I forgot the PEP517, so the wheel has been in the intermediate phase for about 2 or 3 years.