Sagar
Sagar

Reputation: 1175

cx_Freeze how to avoid packages getting installed in lib folder?

When I build the installer and install the application, it installs all the packages in the lib folder whereas my code is picking the imports from current directory not lib.

How can I make the packages to be in the same directory as the executable?

Below is my script:

from cx_Freeze import setup, Executable 

buildOptions = dict(excludes = ["tkinter"], includes =["idna.idnadata"], optimize=1)

setup(name = "SoftwareGateway" , 
      version = "0.1" , 
      description = "" , 
      options =dict(build_exe = buildOptions),
      executables = [Executable("main.py", base = base)])

Upvotes: 1

Views: 1334

Answers (1)

jpeg
jpeg

Reputation: 2461

As far as I understand, what you are asking for can't be done with cx_Freeze 5.1.1 (the current version) or 5.1.0.

You can use the previous stable version cx_Freeze 5.0.2 which does not freeze the packages into a subdirectory lib. To downgrade to this cx_Freeze version, run

python -m pip install cx_Freeze==5.0.2

in a cmd terminal.

But I actually don't understand why it should be an insurmountable problem to have the packages frozen into a subdirectory lib, except for very particular cases. I would advise you to let your code pick the imports from the lib sudirectory by using the __file__ property of packages instead of changing the cx_Freeze version.

Upvotes: 1

Related Questions