LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 10-01-2008, 11:36 PM   #1
ankit_mcgill
Member
 
Registered: Aug 2005
Location: Montreal
Distribution: OpenSuse 10.3
Posts: 65

Rep: Reputation: 15
Convert python script to windows executable


Hi all,

I made a python script using Qt for a nice gui that reads the dvd in the drive, catalogues all the movies/files on the disk and stores them in a db so that when i want to watch a movie from my collection i can simply put in the name and it will tell me what disk the movie is in.

now the problem is i want to port this python script to a windows executable so that i can run this on my windows desktop as well.

had some questions/concerns regarding this .. hoping someone can help :

1. since the script uses qt first of all can it be ported to windows ?

2. in the script itself i use some native linux commands like 'du' .. would i need to change them to something else if i port ?

3. what about all the packages like pydb that i have importted in the script ? so they get compiled in the final .exe automatically ?

this little script has been a much needed time saver for me and i would really love to be able to run it on windows ... even thought about coding it in C on windows .. but why waste time if i can manage to port the same python code to an .exe.

thanks for the help
-ankit
 
Old 10-01-2008, 11:51 PM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,029

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
Quote:
Originally Posted by ankit_mcgill View Post
1. since the script uses qt first of all can it be ported to windows ?
It depends. It should be easily portable, as long as the python bindings and all the other extensions you use (if any) are also working in windows.

About qt: I think that qt3 has no free license for windows. If you used qt4 you are not going to have problems. You should be able to compile it in windows with very little work. But it all depends on the application. Some apps use OS specific code, others do not...

Quote:
2. in the script itself i use some native linux commands like 'du' .. would i need to change them to something else if i port ?
Sure.

That's why it's a good thing to stick to standard ANSI libs (or qt, or whatever libs you are using). If you use libraries that are available in many architectures and OSes, and stick to the standard libraries of your chosen language, then you are going to have a much easier life. If you use external tools and libraries that are OS dependant, then you are going to have to reprogram that part of the program each time to want to use a new OS.

Quote:
3. what about all the packages like pydb that i have importted in the script ? so they get compiled in the final .exe automatically ?
I know very little about python and I know nothing about python object code compilers. I guess that depends entirely on the compiler you use, and whether you link all the stuff statically or whatever... I am a complete profane when it comes to compiling languages languages that are meant to be interpreted.

Quote:
this little script has been a much needed time saver for me and i would really love to be able to run it on windows ... even thought about coding it in C on windows .. but why waste time if i can manage to port the same python code to an .exe.

thanks for the help
-ankit
Now, a silly question: python does run in windows as well as a whole of of other OSes. Why compile an exe? Why not just run it as you run it in linux? Just install python and let it do its job.

If you are wanting to do so to override the dependencies, forget about it. You will still need everything you need on linux to run it. So, if you are using functionalities that are linux-only you are going to have to re-make some bits.
 
Old 10-02-2008, 12:54 AM   #3
ankit_mcgill
Member
 
Registered: Aug 2005
Location: Montreal
Distribution: OpenSuse 10.3
Posts: 65

Original Poster
Rep: Reputation: 15
Quote:
Now, a silly question: python does run in windows as well as a whole of of other OSes. Why compile an exe? Why not just run it as you run it in linux? Just install python and let it do its job.

If you are wanting to do so to override the dependencies, forget about it. You will still need everything you need on linux to run it. So, if you are using functionalities that are linux-only you are going to have to re-make some bits.
i am just trying to avoid having to install python on my desktop as i know i wouldnt use it for anything else/

hmm ... is that the whole point of compiling it into a nice little exe file so that i do not need python on the windows computer to interpret my script ? also if i did manage to compile it into an exe why would i need the dependencies ? shouldnt they be compiled in as well ??

thanks
-ankit
 
Old 10-03-2008, 11:11 AM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,029

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
There might be tools that can embed the python modules on a single exe file so your program can import them from there. I am not sure if there's anything to embed the rest of libraries like qt, however, even if there is, you need to make sure that everything needed is available for windows.

Supposing that statically linking libs into a python compiled object code, you can't expect to embed a linux qt .so file into such a file and hope that it will work in windows. You need the windows libs. And you definitely need to make sure that all the tools you use (for example, "du" as you said) are also available. There's no way to magically port your code if it's not designed to be portable.
 
Old 10-05-2008, 01:21 AM   #5
ankit_mcgill
Member
 
Registered: Aug 2005
Location: Montreal
Distribution: OpenSuse 10.3
Posts: 65

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by i92guboj View Post
There might be tools that can embed the python modules on a single exe file so your program can import them from there. I am not sure if there's anything to embed the rest of libraries like qt, however, even if there is, you need to make sure that everything needed is available for windows.

Supposing that statically linking libs into a python compiled object code, you can't expect to embed a linux qt .so file into such a file and hope that it will work in windows. You need the windows libs. And you definitely need to make sure that all the tools you use (for example, "du" as you said) are also available. There's no way to magically port your code if it's not designed to be portable.
well put ! ... another lesson learned . always keep the future in mind !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert shell script to a binary executable madhi Programming 13 07-24-2012 09:36 AM
python: how to tell if an executable exists? BrianK Programming 5 06-19-2008 12:02 AM
python executable deep_jyotsingh Programming 3 06-02-2006 04:09 AM
how to convert C executable into Assembly Code indian Programming 4 10-04-2004 04:56 PM
How do I convert a Windows Dial-up Script to use in Mandrake 8.1 wjsulliv Linux - Networking 1 02-22-2002 01:17 AM


All times are GMT -5. The time now is 03:45 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration