Skip to content

Commit

Permalink
PyInstaller support for generating executables.
Browse files Browse the repository at this point in the history
Typing 'make' on Linux will create Win32 and Linux executables.

Building Win32 executables from Linux requires that Python, pygame,
PGU, and PyInstaller all be installed in the current WINEPREFIX.
  • Loading branch information
Darren committed Sep 20, 2015
1 parent 42e366a commit d968dad
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.pyc
res
build
dist
.idea
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
all: linux wine

linux:
pyinstaller --clean --noconfirm padpyght-bin.spec
cd dist; tar czf padpyght-linux.tar.gz padpyght-bin

wine:
wine pyinstaller --clean --noconfirm padpyght-bin.spec
cd dist; zip -r padpyght-win32.zip padpyght-bin

clean:
rm -rf build/ dist/
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ An open source gamepad visualizer inspired by PadLight.

Usage
-----
Download and unzip the release package, and run `padpyght.exe`.

It will present you with a list of connected gamepads and available padpyght skins.
Select one of each, then click the "run" button.
If it's your first time running with that combination of gamepad and skin, the program will ask you to map the controls.
*Pay attention to the title of the window during this!*
The window title will tell you what to do, while the visualization animates each action.
If you make a mistake, you can revisit this mapper from the initial selection screen by clicking "remap" instead of "run."

Once in visualization mode, NumPad + and - will resize the window by 10% at a time.

Run from source
---------------
Command line: `python2 -m padpyght [skin name] [joypad number]`

If you have [PGU](http://code.google.com/p/pgu/) installed, you can omit both
Expand All @@ -18,6 +31,12 @@ it will immediately begin visualization as normal.

Use + and - on the number pad to change the window size during visualization.

Build packages
--------------
To build release packages, simply type `make` and find the resulting `padpyght-win32.zip` and `padpyght-linux.tar.gz` in the `dist/` directory.
It requires that PyInstaller, Python, PyGame, and PGU be installed, and that you have all of these things installed in Wine as well.
If you don't want to use Wine (if you don't care about making Windows binaries, or perhaps if you're using MSYS or similar from Windows and have no need to run Wine), just run `make linux` instead of the default target.

NOTE
----
There are a few tutorials I've seen on the internet for how to use padpyght (thanks so much, by the way, if you've made one of these!), written/recorded before a major rewrite of this project occurred in August 2015. If you're following one of these and you get lost, the pre-rewrite version may help you temporarily: https://github.com/lifning/padpyght/tree/legacy - but note that you'll be missing some of the newer features, such as interactive control mapping.
Expand All @@ -26,4 +45,4 @@ TODO
----
- Add trigger-clicks (i.e. Gamecube shoulders) and re-add stick-clicks
- Expose skin.ini-to-json converter in UI somehow
- Installer for Windows users unfamiliar with Python
- Find someone with a Mac
Binary file added gamepad.ico
Binary file not shown.
31 changes: 31 additions & 0 deletions padpyght-bin.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- mode: python -*-
a = Analysis(['start.py'],
pathex=['/home/lifning/git/padpyght'],
hiddenimports=[],
hookspath=None,
runtime_hooks=None)

pgu_theme = Tree('/usr/share/pgu/themes/default', prefix='default')
padpyght_skins = Tree('padpyght/skins', prefix='padpyght/skins')

pyz = PYZ(a.pure)

exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='padpyght.exe',
debug=False,
strip=None,
upx=True,
console=False,
icon='gamepad.ico')

coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
pgu_theme,
padpyght_skins,
strip=None,
upx=True,
name='padpyght-bin')
16 changes: 14 additions & 2 deletions padpyght/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,20 @@ def main(skin, joy_index):
name = pygame.joystick.Joystick(i).get_name()
joy_list.add('{}: {}'.format(i, name), value=i)

for dir_name in pkg_resources.resource_listdir('padpyght', 'skins'):
path = pkg_resources.resource_filename('padpyght', 'skins/%s' % dir_name)

def list_skin_paths():
if getattr(sys, 'frozen', False):
base_dir = os.path.join(sys._MEIPASS, 'padpyght', 'skins')
for dir_name in os.listdir(base_dir):
path = os.path.join(base_dir, dir_name)
yield dir_name, path
else:
for dir_name in pkg_resources.resource_listdir('padpyght', 'skins'):
path = pkg_resources.resource_filename('padpyght',
'skins/%s' % dir_name)
yield dir_name, path

for dir_name, path in list_skin_paths():
cfg = os.path.join(path, 'skin.json')
if os.path.exists(cfg):
skin_list.add(dir_name, value=dir_name)
Expand Down
2 changes: 2 additions & 0 deletions start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# convenience file for cases where running a module is inconvenient
import padpyght.__main__

0 comments on commit d968dad

Please sign in to comment.