Creating a program

This is the place for queries that don't fit in any of the other categories.

Creating a program

Postby Anders » Wed Jun 04, 2014 1:14 pm

Hello,
I am stuck on how to create a program for users to use. I have done following.
1) Created a setup file
2) ran python setup.py build
3) in python folder \build following folder was created: exe.win-amd64-3.3 here I have an exe among other files.
Question is how to package all these files in order to make a functional program?
My .py file looks like this:

Code: Select all
import os
cmd = 'deleteFolders.cmd'
os.system(cmd)


So my next question is if how to include the file deleteFolders.cmd into the package and also the package "os" that I import in my .py file?
Many thanks in advance.
Br
Anders
Last edited by stranac on Wed Jun 04, 2014 2:06 pm, edited 1 time in total.
Reason: Added code tags. Locked.
Anders
 
Posts: 4
Joined: Wed Jun 04, 2014 12:59 pm

Re: Creating a program

Postby stranac » Wed Jun 04, 2014 2:10 pm

There are many programs that can do that for you, e.g. PyInstaller, cx_freeze, py2exe...
But if all your script is doing is executing a .cmd script, why not just give people that?
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1246
Joined: Thu Feb 07, 2013 3:42 pm

Re: Creating a program

Postby metulburr » Wed Jun 04, 2014 2:47 pm

I have to agree with stranac. This is quite a ridiculous program to go through the hassle of building an exe for. Unless your are just trying to understand the process of how to do it.

For one you did not mention which program you were using to create your exe file. cx_freeze or py2exe, because both require different modification of the setup file. Second of all, you did not inlcude your setup file. This is information you should always share when asking about building an exe with python.

Code: Select all
cmd = 'deleteFolders.cmd'
os.system(cmd)

I am not sure what you mean, as that is not a valid command to any operating system.

So my next question is if how to include the file deleteFolders.cmd into the package and also the package "os" that I import in my .py file?

assuming that deleteFolders.cmd is a file based on your statement here, and that it doesnt contain the full path, you would have to move this file within the location of the exe. If your source code is looking for it within the same directory then your exe is also looking for it within its same directory. That varies with your modification of your setup file.

Unless you explicitly exclude the os module in your setup file, all of python standard libraries should be packaged within the exe or within its directory in a zip depending on your setup file.

So then we go in circles because you did not supply us with enough information. Please read this
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1562
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Creating a program

Postby Anders » Thu Jun 05, 2014 8:23 am

Stranac and metulburr you did not understand purpose, I was just giving the users of this forum what I thought an easy example to explain how to create a "Final" product for the users that should use the program created by me in the environment of python....

I was just stating a simple example where I asked someone to help explaining me the process of having final end product from python. How to create a program that can be installed in a way of other standard programs that are by setup installed under c:\Programs.
Is there a way in python to create a setup file that installs my program (whole environment mentioned earlier) under lets say c:\Programs..
If yes what are the steps in order to be succesfull?
Anders
 
Posts: 4
Joined: Wed Jun 04, 2014 12:59 pm

Re: Creating a program

Postby Anders » Fri Jun 06, 2014 10:01 am

ANSWER IS TO FOLLOW THIS NICE HOW TO:
http://www.pythonschool.net/cxfreeze_win/

To metulburr and stranac I just would like to say: it would be a better world if we all try to understand people instead of picking on them! :)
Anders
 
Posts: 4
Joined: Wed Jun 04, 2014 12:59 pm

Re: Creating a program

Postby metulburr » Fri Jun 06, 2014 10:44 am

neither of us were picking on you. We were trying to help you. But we cannot help when you do not give us enough information.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1562
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Creating a program

Postby Mekire » Fri Jun 06, 2014 10:44 am

Yes, and now I'm sure you probably have about 20 other files in that directory when you just wanted to freeze a two line program. But, hey, if you're happy...

Try this.
Save this in the directory with your file as setup.py; change the file name as indicated; and run it (no additional command line arguments needed).
Code: Select all
import sys
import py2exe

from distutils.core import setup


sys.argv.append("py2exe")

#Replace "file_to_freeze.py" value with your file name:
setup(options = {"py2exe": {"bundle_files": 1, "compressed": True}},
      console = ["file_to_freeze.py"])

Also, note that despite how wronged you feel, no one here remotely insulted you. This is how we talk. Read this (though honestly, I doubt you will), specifically the part on "How to Interpret Answers," and "Dealing with Rudeness".

-Mek
User avatar
Mekire
 
Posts: 1142
Joined: Thu Feb 07, 2013 11:33 pm
Location: Asakusa, Japan

Re: Creating a program

Postby Anders » Tue Jun 10, 2014 9:01 am

ok thanks for your help, will try to state myself clearer in future.
Thanks Mekire will look into your solution as soon as my time allows it... :)
Case closed!
Anders
 
Posts: 4
Joined: Wed Jun 04, 2014 12:59 pm


Return to General Coding Help

Who is online

Users browsing this forum: W3C [Linkcheck] and 5 guests