|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 |
|
3 |
| -from setuptools import setup |
4 |
| -from setuptools import find_packages |
| 3 | +from setuptools import setup, find_packages |
| 4 | +import platform |
5 | 5 |
|
6 |
| -import sys |
7 |
| -from platform import system |
| 6 | +yoke_package_data = [ |
| 7 | + 'assets/joypad/*', |
| 8 | + 'assets/joypad/img/*', |
| 9 | + 'vjoy/LICENSE.TXT' |
| 10 | +] |
8 | 11 |
|
9 |
| -setup(name='yoke', |
10 |
| - version='0.1.1', |
11 |
| - description='Yoke is a hackable Android gamepad for Linux (and Windows).', |
12 |
| - author='Simon Ramstedt', |
13 |
| - |
14 |
| - url='https://github.com/rmst/yoke', |
15 |
| - download_url='', |
16 |
| - license='MIT', |
17 |
| - install_requires=[ |
18 |
| - # 'numpy', |
19 |
| - 'zeroconf', |
20 |
| - *(['python-uinput'] if system() == 'Linux' else []) |
21 |
| - ], |
22 |
| - extras_require={ |
23 |
| - }, |
24 |
| - scripts=['bin/yoke', 'bin/yoke-enable-uinput', 'bin/yoke-disable-uinput'], |
25 |
| - packages=find_packages(), |
26 |
| - package_data={'yoke': [ |
27 |
| - 'assets/joypad/*', |
28 |
| - 'assets/joypad/img/*', |
29 |
| - ]}, |
30 |
| - platforms=['GNU/Linux', 'Windows'], |
31 |
| - keywords=['gamepad', 'video games', 'gaming', 'controller', 'Android'] |
| 12 | +if platform.system() == 'Windows': |
| 13 | + import ctypes # https://stackoverflow.com/questions/2963263/ |
| 14 | + if not (platform.release() in ('Vista', '7', '8', '8.1', 'post8.1', '10', 'post10')): |
| 15 | + raise SystemError('Yoke depends on the vJoy driver, which needs Windows Vista SP1 or higher.') |
| 16 | + elif platform.release() in ('Vista', '7', '8', '8.1', 'post8.1') or [int(v) for v in platform.version().split('.')[0:3]] <= [10, 0, 1803]: |
| 17 | + DLL_path = 'vjoy/vJoyInterface-' + platform.architecture()[0] + '-legacy.dll' |
| 18 | + else: |
| 19 | + DLL_path = 'vjoy/vJoyInterface-' + platform.architecture()[0] + '-modern.dll' |
| 20 | + yoke_package_data.append(DLL_path) |
| 21 | +elif platform.system() == 'Android': |
| 22 | + raise SystemError('This program is supposed to be installed on an external computer. ' |
| 23 | + 'For Android, you can download the APK at ' |
| 24 | + 'https://f-droid.org/en/packages/com.simonramstedt.yoke/') |
| 25 | +elif platform.system() != 'Linux': |
| 26 | + raise SystemError('Yoke is not yet compatible with ' + platform.system() + '. ' |
| 27 | + 'Please contact the author if you know any virtual joystick driver for your system.') |
| 28 | + |
| 29 | +# https://stackoverflow.com/questions/20288711/ |
| 30 | +from setuptools.command.install import install |
| 31 | +class PostInstallCommand(install): |
| 32 | + # vJoy_url cannot be cached from the previous conditionals. |
| 33 | + # After installation, pip parses setup.py again and the previous content of every variable is lost. |
| 34 | + def run(self): |
| 35 | + if platform.system() == 'Windows': |
| 36 | + if platform.release() in ('Vista', '7', '8', '8.1', 'post8.1') or [int(v) for v in platform.version().split('.')[0:3]] <= [10, 0, 1803]: |
| 37 | + vJoy_url = 'https://sourceforge.net/projects/vjoystick/files/Beta%202.x/2.1.8.39-270518/vJoySetup.exe/download' |
| 38 | + else: |
| 39 | + vJoy_url = 'https://sourceforge.net/projects/vjoystick/files/latest/download' |
| 40 | + print('You should now see a prompt to download the vJoy driver.\n' |
| 41 | + 'If you need to install this driver, you can do so anytime by visiting ' + vJoy_url) |
| 42 | + answer = ctypes.windll.user32.MessageBoxW(0, |
| 43 | + 'Yoke was installed succesfully, but can only work if the correct vJoy driver is installed. ' |
| 44 | + 'The driver for Windows ' + platform.release() + ', version ' + platform.version() + ' at:\n\n' + vJoy_url + '\n\n' |
| 45 | + 'Click OK if you want to download the installer now, or Cancel otherwise.', |
| 46 | + 'vJoy driver required', 33) # question prompt (33), OK (answer == 1) and Cancel (answer == 2) buttons |
| 47 | + if answer == 1: |
| 48 | + import webbrowser |
| 49 | + webbrowser.open_new(vJoy_url) |
| 50 | + install.run(self) |
| 51 | + |
| 52 | +setup( |
| 53 | + name='yoke', |
| 54 | + version='0.1.1', |
| 55 | + description='A hackable Android gamepad for Linux (and Windows).', |
| 56 | + author='Simon Ramstedt', |
| 57 | + |
| 58 | + url='https://github.com/rmst/yoke', |
| 59 | + download_url='', |
| 60 | + license='MIT License', |
| 61 | + dependency_links=[], |
| 62 | + install_requires=[ |
| 63 | + 'zeroconf', |
| 64 | + 'python-uinput; platform_system == "Linux"', |
| 65 | + ], |
| 66 | + extras_require={}, |
| 67 | + scripts=['bin/yoke', 'bin/yoke-enable-uinput', 'bin/yoke-disable-uinput'], |
| 68 | + cmdclass={ |
| 69 | + 'install': PostInstallCommand, |
| 70 | + }, |
| 71 | + packages=find_packages(), |
| 72 | + package_data={'yoke': yoke_package_data}, |
| 73 | + platforms=['Linux', 'Windows 7', 'Windows 8', 'Windows 10'], |
| 74 | + keywords=['gamepad', 'video games', 'gaming', 'controller', 'Android'], |
| 75 | + classifiers=[ |
| 76 | + 'Topic :: Games/Entertainment', |
| 77 | + 'Development Status :: 3 - Alpha', |
| 78 | + ] |
32 | 79 | )
|
0 commit comments