forked from pyinstaller/pyinstaller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
205 lines (173 loc) · 6.81 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#! /usr/bin/env python
#-----------------------------------------------------------------------------
# Copyright (c) 2005-2017, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from __future__ import print_function
import codecs
import sys, os
from setuptools import setup
# Hack required to allow compat to not fail when pypiwin32 isn't found
os.environ["PYINSTALLER_NO_PYWIN32_FAILURE"] = "1"
from PyInstaller import (__version__ as version, is_linux, is_win, is_cygwin,
HOMEPATH, PLATFORM, compat)
REQUIREMENTS = [
'setuptools',
'pefile >= 2017.8.1',
'macholib >= 1.8',
]
# dis3 and xdis are used for our version of modulegraph
if sys.version_info < (3,):
REQUIREMENTS.append('dis3')
elif sys.version_info < (3, 4):
REQUIREMENTS.append('xdis')
# For Windows install PyWin32 if not already installed.
if sys.platform.startswith('win'):
# Windows support depends on pefile library.
# ::TODO:: #1920 require a specific version minimum
# REQUIREMENTS.append('pefile')
# ::TODO:: #1920 future is currently only needed for the included pefile,
# remove 'future' as requirement when pypi pefile is used
REQUIREMENTS.append('future')
try:
import pywintypes
except ImportError:
# try using pywin32-ctypes, as pypiwin32 doesn't compile for msys2
try:
import win32ctypes.pywin32.pywintypes
except ImportError:
# 'pypiwin32' is PyWin32 package made installable by 'pip install'
# command. Prefer it by default.
REQUIREMENTS.append('pypiwin32')
# Create long description from README.rst and doc/CHANGES.rst.
# PYPI page will contain complete PyInstaller changelog.
def read(filename):
try:
return unicode(codecs.open(filename, encoding='utf-8').read())
except NameError:
return open(filename, 'r', encoding='utf-8').read()
long_description = u'\n\n'.join([read('README.rst'),
read('doc/CHANGES.rst')])
if sys.version_info < (3,):
long_description = long_description.encode('utf-8')
CLASSIFIERS = """
Development Status :: 6 - Mature
Environment :: Console
Intended Audience :: Developers
Intended Audience :: Other Audience
Intended Audience :: System Administrators
License :: OSI Approved :: GNU General Public License v2 (GPLv2)
Natural Language :: English
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
Operating System :: POSIX
Operating System :: POSIX :: AIX
Operating System :: POSIX :: BSD
Operating System :: POSIX :: Linux
Operating System :: POSIX :: SunOS/Solaris
Programming Language :: C
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development
Topic :: Software Development :: Build Tools
Topic :: Software Development :: Interpreters
Topic :: Software Development :: Libraries :: Python Modules
Topic :: System :: Installation/Setup
Topic :: System :: Software Distribution
Topic :: Utilities
""".strip().splitlines()
#-- plug-in building the bootloader
from distutils.core import Command
from distutils.command.build import build
from setuptools.command.bdist_egg import bdist_egg
class build_bootloader(Command):
"""
Wrapper for distutil command `build`.
"""
user_options =[]
def initialize_options(self): pass
def finalize_options(self): pass
def bootloader_exists(self):
# Checks is the console, non-debug bootloader exists
exe = 'run'
if is_win or is_cygwin:
exe = 'run.exe'
exe = os.path.join(HOMEPATH, 'PyInstaller', 'bootloader', PLATFORM, exe)
return os.path.isfile(exe)
def compile_bootloader(self):
import subprocess
src_dir = os.path.join(HOMEPATH, 'bootloader')
cmd = [sys.executable, './waf', 'configure', 'all']
rc = subprocess.call(cmd, cwd=src_dir)
if rc:
raise SystemExit('ERROR: Failed compiling the bootloader. '
'Please compile manually and rerun setup.py')
def run(self):
if getattr(self, 'dry_run', False):
return
if self.bootloader_exists():
return
print('No precompiled bootloader found. Trying to compile it for you ...',
file=sys.stderr)
self.compile_bootloader()
class MyBuild(build):
# plug `build_bootloader` into the `build` command
def run(self):
self.run_command('build_bootloader')
build.run(self)
class MyBDist_Egg(bdist_egg):
def run(self):
self.run_command('build_bootloader')
bdist_egg.run(self)
#--
setup(
install_requires=REQUIREMENTS,
name='PyInstaller',
version=version,
description='PyInstaller bundles a Python application and all its '
'dependencies into a single package.',
long_description=long_description,
keywords='packaging app apps bundle convert standalone executable '
'pyinstaller macholib cxfreeze freeze py2exe py2app bbfreeze',
author='Giovanni Bajo, Hartmut Goebel, David Vierra, David Cortesi, Martin Zibricky',
author_email='[email protected]',
license=('GPL license with a special exception which allows to use '
'PyInstaller to build and distribute non-free programs '
'(including commercial ones)'),
url='http://www.pyinstaller.org',
cmdclass = {'build_bootloader': build_bootloader,
'build': MyBuild,
'bdist_egg': MyBDist_Egg,
},
classifiers=CLASSIFIERS,
zip_safe=False,
packages=['PyInstaller'],
package_data={
# This includes precompiled bootloaders and icons for bootloaders.
'PyInstaller': ['bootloader/*/*'],
# This file is necessary for rthooks (runtime hooks).
'PyInstaller.loader': ['rthooks.dat'],
},
include_package_data=True,
entry_points={
'console_scripts': [
'pyinstaller = PyInstaller.__main__:run',
'pyi-archive_viewer = PyInstaller.utils.cliutils.archive_viewer:run',
'pyi-bindepend = PyInstaller.utils.cliutils.bindepend:run',
'pyi-grab_version = PyInstaller.utils.cliutils.grab_version:run',
'pyi-makespec = PyInstaller.utils.cliutils.makespec:run',
'pyi-set_version = PyInstaller.utils.cliutils.set_version:run',
],
}
)