1

I am creating the installer for python application by using below setup file

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)])

The setup file gets the dependencies by itself but catch here in my case is, the main.py calls another python program fun.py using the subprocess call. When I run setup.py, neither the fun.py is getting compiled nor is it going into the directory after installation.

Is there a way I can get fun.py compiled to bytecode and pack it along with installer?

Mel
  • 5,837
  • 10
  • 37
  • 42
Sagar
  • 1,115
  • 2
  • 13
  • 22

1 Answers1

1

Try to add import fun in your main.py and use fun.__file__ to get the correct location of the compiled fun in your subprocess call (assuming fun.py is in the same directory as main.py). This should do what you asked for.

But why don't you simply pack the content of fun.py into a function and call this function instead of the subprocess call?

jpeg
  • 2,372
  • 4
  • 18
  • 31
  • I agree with you on calling them as function instead of subprocess but the code is developed by someone else i am just creating installer for it. At this moment i have no permission to modify the existing code. – Sagar Dec 13 '18 at 04:52