I have a python script for a word game that uses a dictionary which is a unformatted text file.
I want to create an executable file and pass it on to my friends. They use Windows, Mac or Linux and none of them have Python installed. How can I generate an executable from my script so all my friends can run it and test the game?
You can embedding the specific python binaries for each distribution in folders like python_win, python_mac, python_linux and create three distinct scripts launchers for each one passing on your application as parameter, this will work.
Related
As the title said, with any possible tricks or bugs,can we create a binary file can run both on Linux and Windows without any change?
(The file must be directly created by a compiler)
I know it's nearly impossible,but with some tricky methods,is that possible?
I need to write a small script that renames some files in a directory. This script needs to be run on Mac and Windows.
What is the best scripting language for this? I want to write something that runs just by calling it and there is no need to install anything else.
For example, writing a Perl script and compiling it to run on Windows and then compiling it to run on Mac. Can I do this?
Any other, more elegant solution?
Nothing matches your criteria. You will need to install something (e.g. perl) if you want something that runs on both systems.
If you had perl on both systems, you could indeed write a program that runs on both. You wouldn't even need two binaries as you suggest since Perl programs are distributed as source. (perl compiles them when it loads them, and even then, they are compiled to the same form on all systems.)
I have a 200mb zip file, which I want to extract to a temporary folder for processing. I have experience with rubyzip library before. However it seems that extracting all files using it is a bit of pain according to this blog post, needing to create directory before extracting individual files:
Is there an easier way to extract all things into a directory? It needs to work on both Mac OS X and Linux, but would be better if the solution is truly cross-platform.
Linux has a command line utility called unzip that will do it, IIRC. If that utility is available on Mac OS then you can just call it from ruby using system() or back ticks.
I have set up shuffle_play.rb in Ruby by Example to work on Windows, with mpg123 instead of ogg123. The critical part is a method called play_file, which initially I wrote like this
def play_file(file)
system("mpg123 \"#{file}\"")
end
I have mpg123 in the same directory as my script ... it didn't work. But this does work:
def play_file(file)
system("mpg123.exe \"#{file}\"")
end
I reckon it's because I don't have working directory in %PATH% (and indeed the problem goes away when I add it) but even then I don't know enough about Windows to know the difference. Could someone explain the rationale for this?
Probably the examples assume that you're on a *nix variant such as Linux or Mac. In those Operating Systems, the program is called mpg123, because those OS, don't care about extensions, the just check that the file has an executable attribute
On windows things are very different. Windows decides if something is a program depending on the extension (.exe, .com, .bat, .cmd, etc.). So the program in windows has to be called mpg123.exe. If you open a command line on windows, you can run the program without specifying the extension, as windows automatically tries the different extensions. This behaviour of trying different extensions happens ONLY in the command line and not when you try to invoke a program from another one.
There a environment variable called PATHEXT that list in which order windows tries the different extensions. On my computer that list is:
C:\Windows\System32>echo %PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW
I hope it was clear. And a suggestion if you want to code in ruby, install Linux or get a Mac.
I'm building a perl application that interacts with a PostgreSQL database via the DBD::Pg module, and that uses Perl/Tk for it's GUI. It works fairly well on my system, but I'm designing it for a family member to use for their business. They don't have a c++ compiler and don't have a clue what CPAN is. The goal is to not bog them down by having to load a c++ compiler and go to all of the trouble of building a module from source if I can avoid it.
I need to get the Tk module installed onto their computer along with Strawberry Perl (it includes DBD:Pg right out of the box). How do I go about including this module along with my application in order to make things easier on for my end user? Would simply copying my entire C:\strawberry\perl\site\lib\Tk folder into their computer during setup do the trick or does perl need more than that in order to use Tk and be happy with it?
Thanks for the help!
One way is to convert your application to an executable, using tools like perlapp, perl2exe, or par. If not, i think you can try Strawberry Perl portable versions.
You can use PAR::Packer module.
it generates exe on windows with a simple shell command.
> pp -o test.exe test.pl