-3

I have a program I'm thinking through right now and doing tons of investigating on. One of the stipulations with the program is that I want it so it can only run on Linux. I DO NOT want the program to be usable on Windows or Apple...Linux only. I have my reasons.

I know you can use certain modules(tkinter...root.mainloop()), ie, that will cause a program to not run in Windows if you leave certain things out. Is there a way you can accomplish the same task without using any particular module...just 'base code'?

confused
  • 1,283
  • 6
  • 21
  • 37
  • Very related: http://stackoverflow.com/questions/1854/python-what-os-am-i-running-on – sashkello Feb 04 '14 at 22:31
  • Do you intend to distribute the source for your script, or will you be packaging it into some kind of binary distribution? – Greg Hewgill Feb 04 '14 at 22:39
  • Given the nature of the program...binary distribution. Once the program is written and compiled I will destroy the source code. Quite sensitive coding. – confused Feb 04 '14 at 23:04
  • 2
    I would note that if you really intend to "destroy the source code", you might reconsider your choice of Python. Most methods of bundling up a Python script into an executable simply embed the script text in an archive along with a Python interpreter - the script is still there for somebody willing to poke around a bit. – Greg Hewgill Feb 04 '14 at 23:23

1 Answers1

9

Just test for Linux:

import platform
import sys


if platform.system() != 'Linux':
    sys.stderr('Linux required\n')
    sys.exit(1)
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Okay, I didn't realize there was a REAL nice shortcut for finding out the operating system. Thanks. – confused Feb 04 '14 at 22:39