104
104
if sys.platform == "win32":
106
scripts_dir = self.install_dir
106
scripts_dir = os.path.join(sys.prefix, 'Scripts')
107
107
script_path = self._quoted_path(os.path.join(scripts_dir,
109
109
python_exe = self._quoted_path(sys.executable)
110
110
args = self._win_batch_args()
111
111
batch_str = "@%s %s %s" % (python_exe, script_path, args)
112
batch_path = script_path + ".bat"
112
batch_path = os.path.join(self.install_dir, "bzr.bat")
113
113
f = file(batch_path, "w")
114
114
f.write(batch_str)
148
148
########################
150
150
command_classes = {'install_scripts': my_install_scripts,
152
from distutils.extension import Extension
154
155
from Pyrex.Distutils import build_ext
155
156
except ImportError:
156
158
# try to build the extension from the prior generated source.
157
print ("Pyrex not available, while bzr will build, "
158
"you cannot modify the C extensions.")
160
print ("The python package 'Pyrex' is not available."
161
" If the .c files are available,")
162
print ("they will be built,"
163
" but modifying the .pyx files will not rebuild them.")
159
165
from distutils.command.build_ext import build_ext
160
from distutils.extension import Extension
162
# Extension("bzrlib.modulename", ["bzrlib/foo.c"], libraries = []))
164
from distutils.extension import Extension
166
# Extension("bzrlib.modulename", ["bzrlib/foo.pyx"], libraries = []))
168
# Override the build_ext if we have Pyrex available
167
169
command_classes['build_ext'] = build_ext
170
unavailable_files = []
173
def add_pyrex_extension(module_name, **kwargs):
174
"""Add a pyrex module to build.
176
This will use Pyrex to auto-generate the .c file if it is available.
177
Otherwise it will fall back on the .c file. If the .c file is not
178
available, it will warn, and not add anything.
180
You can pass any extra options to Extension through kwargs. One example is
183
:param module_name: The python path to the module. This will be used to
184
determine the .pyx and .c files to use.
186
path = module_name.replace('.', '/')
187
pyrex_name = path + '.pyx'
190
ext_modules.append(Extension(module_name, [pyrex_name]))
192
if not os.path.isfile(c_name):
193
unavailable_files.append(c_name)
195
ext_modules.append(Extension(module_name, [c_name]))
198
add_pyrex_extension('bzrlib._dirstate_helpers_c')
199
add_pyrex_extension('bzrlib._knit_load_data_c')
202
if unavailable_files:
203
print 'C extension(s) not found:'
204
print ' %s' % ('\n '.join(unavailable_files),)
205
print 'The python versions will be used instead.'
169
209
if 'bdist_wininst' in sys.argv:
172
docs = glob.glob('doc/*.htm') + ['doc/default.css']
173
dev_docs = glob.glob('doc/developers/*.htm')
212
docs = glob.glob('doc/*.html') + ['doc/default.css']
213
dev_docs = glob.glob('doc/developers/*.html')
174
214
# python's distutils-based win32 installer
175
215
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
216
'ext_modules': ext_modules,
177
218
'data_files': [('Doc/Bazaar', docs),
178
219
('Doc/Bazaar/developers', dev_docs),
221
# for building pyrex extensions
222
'cmdclass': {'build_ext': build_ext},
182
225
ARGS.update(META_INFO)
237
283
zipfile='lib/library.zip')
286
# ad-hoc for easy_install
288
if not 'bdist_egg' in sys.argv:
289
# generate and install bzr.1 only with plain install, not easy_install one
290
DATA_FILES = [('man/man1', ['bzr.1'])]
241
293
ARGS = {'scripts': ['bzr'],
242
'data_files': [('man/man1', ['bzr.1'])],
294
'data_files': DATA_FILES,
243
295
'cmdclass': command_classes,
244
296
'ext_modules': ext_modules,
247
299
ARGS.update(META_INFO)
248
300
ARGS.update(BZRLIB)
249
301
ARGS.update(PKG_DATA)