0

I made a Python script that I would like to turn into a standalone .exe file to distribute it among my not so tech savvy friends. I am using Linux to do all the coding of course and I don't have any Windows computers to compile it on. My application has no user interface so I would need it to run in a command shell like Command Prompt. How would I do this?

My code:

import string
import collections


def caesar(rotate_string, number_to_rotate_by):

    upper = collections.deque(string.ascii_uppercase)
    lower = collections.deque(string.ascii_lowercase)

    upper.rotate(number_to_rotate_by)
    lower.rotate(number_to_rotate_by)

    upper = ''.join(list(upper))
    lower = ''.join(list(lower))

    return rotate_string.translate(string.maketrans(string.ascii_uppercase, upper)).translate(string.maketrans(string.ascii_lowercase, lower))


print("Enter message:")
message = raw_input()

print("Enter rotation:")
rotation = raw_input()

print caesar(message, int(rotation))
Caden Mitchell
  • 133
  • 1
  • 4
  • In theory it shouldn't be too hard (assuming you have a copy of Windows Python, and Windows wheels for any extension modules), but in practice, AFAIK, nobody supports it. pyInstaller, cx_Freeze, py2exe, etc. all have no knowledge of cross-compiling, so you need to run them under Windows to create a Windows executable. – abarnert Jul 06 '18 at 04:16
  • 2
    @RohithS98 How are any of those answers going to help the OP here? Using a shbang and chmod +x will do nothing on Windows; py2exe won't run on Linux; etc. – abarnert Jul 06 '18 at 04:18
  • In the linked duplicate, don't look at the accepted answer (cross-compiling was added to PyInstaller 1.4, but removed again in 1.5), but [the second answer by SparkAndShine](https://stackoverflow.com/a/35605479/908494), which shows how to do it with WINE, Windows Python, and current PyInstaller. – abarnert Jul 06 '18 at 04:22
  • Although, if you can run Windows in a virtual machine, or get a free or super-cheap cloud-hosted Windows dev box or something, or get time on someone's Windows Python build system, that would probably make things a lot easier. – abarnert Jul 06 '18 at 04:24
  • Also, you're really going to want to test that your command-line tool actually works on Windows (and in `cmd` instead of `bash`) before distributing it to your not so tech savvy friends. If running your script with Windows Python under WINE works, that's a pretty good indication it will work on real Windows, but not perfect—and if it fails, that's only a mediocre indication it will fail on real Windows. Again, a VM would be simpler, if possible. – abarnert Jul 06 '18 at 04:28

1 Answers1

0

You could use cx_freeze, I use it to create Windows executables on Linux and vice-versa.