Author Topic: Packaging a python script as an executable  (Read 21994 times)

Avagart

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 567
  • Karma: +0/-0
    • View Profile
Re: Packaging a python script as an executable
« Reply #15 on: January 20, 2017, 12:11:31 AM »
Quote
it's obviously not the recommended way of doing things (the pythonic way).
It's right.

But
Quote
distribute a BAT file that executes the Python command like all other Python games do
It's... not exactly true. It's clearly java's way to execute programs. Just checked randomly some windows software written in python. Calibre, Deluge, TortoiseHG - they are python-indenpendent. OK, it's not just bloated exe that we was talking about. But also, their windows releases are not shipped via source code and instruction 'if you want to use this software, you need to download python and all dependencies', or with python installer. Sometimes games (Civilization 4 is good example) are using python as intepreter in more traditional way, but it's more about shipping game with portable python, with all dependencies already installed. No need to manually install third-party software or libraries. Especially that pip, altought handy, is really vulnerable part of python. So, despite being pythonic or unpythonic, I'd say that your assumption (that everyone who make windows software in python is just releasing sources) seems wrong for me.
« Last Edit: January 20, 2017, 12:22:30 AM by Avagart »

javelinrl

  • Rogueliker
  • ***
  • Posts: 86
  • Karma: +0/-0
  • Creator of Javelin
    • View Profile
    • Javelin - party-based roguelike (open-source RPG / strategy game)
Re: Packaging a python script as an executable
« Reply #16 on: January 20, 2017, 01:07:31 PM »
your assumption (that everyone who make windows software in python is just releasing sources) seems wrong for me.

That is not what I said, though. I deliberately said most Python games. I've seen a few Python roguelikes and that's how they do things. I can't say much for commercial games but I honestly doubt there are many commercial games written purely in Python.

I took a quick look at the projects you mention and at least one of them seems to be using bbfreeze, which compiles Python into an EXE.

Another uses MSVCCompiler, which seems to be more of an official approach. I wouldn't recommend it though since the project's build script alone is almost a thousand lines of Python code. https://wiki.python.org/moin/WindowsCompilers
« Last Edit: January 20, 2017, 01:09:15 PM by javelinrl »
Javelin, party-based roguelike (free RPG / strategy game for Win/Mac/Lin)
https://javelinrl.wordpress.com/

Avagart

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 567
  • Karma: +0/-0
    • View Profile
Re: Packaging a python script as an executable
« Reply #17 on: January 20, 2017, 02:31:22 PM »
Yeah, I made my own assumption about your assumpion :D I misunderstood *spirit* of your post, I'm sorry.

So, about python roguelikes - I'm working on roguelike collection now, and currently I'm into 7DRLS. Most of python roguelike developers (not only 7DRLs) include windows build (created usually by py2exe or pyinstaller). Examples: Swift Swurd by Neil Thapen, ZDay by Sheep, mujahid by Pat Wilson, Madness by hmp, Hive Awakening by Gero Kunter, Dungeon Themed Starvation Simulator by Mark R Johnson, Nightmare Tyrant by zasvid, and much, really much more. And it's true not only for 7DRLS, check, for example, ArmCom by Rev. Sudasana, Lands of Strangers by Aging Minotaur, rng clrc by Jan. I'm putting info about authors to show that it's really common practice, not the quirk of one or two developers.

Of course, there are roguelikes released only as source code (like, for example, Swamp Monster by cturner, Trinkets by Geek of Geeks and Dad) but it is the minority. Sometimes developers (as Geek of Geeks and Dad, if I remember correctly) stated that they wanted to build windows executable, but there was no more time. And only-sources releases, if at all, are mainly for 7DRL, I don't know much not-7drl python roguelikes without exe package. Also, I know about only one developer who used to ship roguelikes as sources with python installer (unable to find it now, unfortunately. Name of game was... Sandstorm? Something similar). Probably never spot any single roguelike released as sources with windows batch file.

One more word, because... Why is it important in my opinion? You stated that (yeah, I know I quoted it my previous post already)
Quote
you should just distribute a BAT file that executes the Python command like all other Python games do
If you'd make proper reasearch (you should do it, it's about packing python into windows executable, and, as you said, you wasn't using windows for long time) you would see that it isn't correct.  So, you gave KM advice basing on wrong conviction, and you presented this conviction as fact.

To be clear: hi, KM, most python developers release windows builds created in various ways, including py2exe.

edit: edits was about grammar
« Last Edit: January 20, 2017, 04:50:52 PM by Avagart »

Aukustus

  • Rogueliker
  • ***
  • Posts: 440
  • Karma: +0/-0
    • View Profile
    • The Temple of Torment
Re: Packaging a python script as an executable
« Reply #18 on: January 20, 2017, 03:17:54 PM »
Exe compilation is undoubtedly the only real way of doing Python game development on Windows.

javelinrl

  • Rogueliker
  • ***
  • Posts: 86
  • Karma: +0/-0
  • Creator of Javelin
    • View Profile
    • Javelin - party-based roguelike (open-source RPG / strategy game)
Re: Packaging a python script as an executable
« Reply #19 on: January 20, 2017, 07:37:39 PM »
No need to apologize, communication on the Internet is hard - it took a little while but I think we're on the same page now. I only knew a few Python RLs and games and you certainly know much more than me based on your examples and collecting work so it's pretty clear to me now that Python EXEs are a thing. It still stands though that it's a hack (maybe a necessary one, but still a hack) and not the official pythonic way of doing things, which Python developers are usually is so proud of. Again I understand now and admit that it must be a necessity for games but it still is a hack since Python doesn't compile to EXEs natively.
Javelin, party-based roguelike (free RPG / strategy game for Win/Mac/Lin)
https://javelinrl.wordpress.com/