##// END OF EJS Templates
Merge pull request #12623 from farisachugthai/setupbase
Matthias Bussonnier -
r26142:2b4bc75a merge
parent child
Show More
@@ -12,18 +12,19 This includes:
12 # Copyright (c) IPython Development Team.
12 # Copyright (c) IPython Development Team.
13 # Distributed under the terms of the Modified BSD License.
13 # Distributed under the terms of the Modified BSD License.
14
14
15
16 import re
17 import os
15 import os
16 import re
18 import sys
17 import sys
18 from glob import glob
19 from logging import log
20
21 from setuptools import Command
22 from setuptools.command.build_py import build_py
19
23
20 from distutils import log
24 # TODO: Replacement for this?
21 from distutils.command.build_py import build_py
22 from distutils.command.build_scripts import build_scripts
25 from distutils.command.build_scripts import build_scripts
23 from distutils.command.install import install
26 from setuptools.command.install import install
24 from distutils.command.install_scripts import install_scripts
27 from setuptools.command.install_scripts import install_scripts
25 from distutils.cmd import Command
26 from glob import glob
27
28
28 from setupext import install_data_ext
29 from setupext import install_data_ext
29
30
@@ -115,14 +116,14 def find_package_data():
115 """
116 """
116 # This is not enough for these things to appear in an sdist.
117 # This is not enough for these things to appear in an sdist.
117 # We need to muck with the MANIFEST to get this to work
118 # We need to muck with the MANIFEST to get this to work
118
119
119 package_data = {
120 package_data = {
120 'IPython.core' : ['profile/README*'],
121 'IPython.core' : ['profile/README*'],
121 'IPython.core.tests' : ['*.png', '*.jpg', 'daft_extension/*.py'],
122 'IPython.core.tests' : ['*.png', '*.jpg', 'daft_extension/*.py'],
122 'IPython.lib.tests' : ['*.wav'],
123 'IPython.lib.tests' : ['*.wav'],
123 'IPython.testing.plugin' : ['*.txt'],
124 'IPython.testing.plugin' : ['*.txt'],
124 }
125 }
125
126
126 return package_data
127 return package_data
127
128
128
129
@@ -229,7 +230,7 def find_entry_points():
229 command line scripts.
230 command line scripts.
230
231
231 Each of our entry points gets both a plain name, e.g. ipython, and one
232 Each of our entry points gets both a plain name, e.g. ipython, and one
232 suffixed with the Python major version number, e.g. ipython3.
233 suffixed with the Python major version number, e.g. ipython3.
233 """
234 """
234 ep = [
235 ep = [
235 'ipython%s = IPython:start_ipython',
236 'ipython%s = IPython:start_ipython',
@@ -247,10 +248,10 if __name__ == '__main__':
247
248
248 class build_scripts_entrypt(build_scripts):
249 class build_scripts_entrypt(build_scripts):
249 """Build the command line scripts
250 """Build the command line scripts
250
251
251 Parse setuptools style entry points and write simple scripts to run the
252 Parse setuptools style entry points and write simple scripts to run the
252 target functions.
253 target functions.
253
254
254 On Windows, this also creates .cmd wrappers for the scripts so that you can
255 On Windows, this also creates .cmd wrappers for the scripts so that you can
255 easily launch them from a command line.
256 easily launch them from a command line.
256 """
257 """
@@ -269,7 +270,7 class build_scripts_entrypt(build_scripts):
269 with open(outfile, 'w') as f:
270 with open(outfile, 'w') as f:
270 f.write(script_src.format(executable=sys.executable,
271 f.write(script_src.format(executable=sys.executable,
271 mod=mod, func=func))
272 mod=mod, func=func))
272
273
273 if sys.platform == 'win32':
274 if sys.platform == 'win32':
274 # Write .cmd wrappers for Windows so 'ipython' etc. work at the
275 # Write .cmd wrappers for Windows so 'ipython' etc. work at the
275 # command line
276 # command line
@@ -323,7 +324,7 class install_symlinked(install):
323 # Run all sub-commands (at least those that need to be run)
324 # Run all sub-commands (at least those that need to be run)
324 for cmd_name in self.get_sub_commands():
325 for cmd_name in self.get_sub_commands():
325 self.run_command(cmd_name)
326 self.run_command(cmd_name)
326
327
327 # 'sub_commands': a list of commands this command might have to run to
328 # 'sub_commands': a list of commands this command might have to run to
328 # get its work done. See cmd.py for more info.
329 # get its work done. See cmd.py for more info.
329 sub_commands = [('install_lib_symlink', lambda self:True),
330 sub_commands = [('install_lib_symlink', lambda self:True),
@@ -332,7 +333,7 class install_symlinked(install):
332
333
333 class install_scripts_for_symlink(install_scripts):
334 class install_scripts_for_symlink(install_scripts):
334 """Redefined to get options from 'symlink' instead of 'install'.
335 """Redefined to get options from 'symlink' instead of 'install'.
335
336
336 I love distutils almost as much as I love setuptools.
337 I love distutils almost as much as I love setuptools.
337 """
338 """
338 def finalize_options(self):
339 def finalize_options(self):
@@ -356,7 +357,7 def git_prebuild(pkg_dir, build_cmd=build_py):
356
357
357 for use in IPython.utils.sysinfo.sys_info() calls after installation.
358 for use in IPython.utils.sysinfo.sys_info() calls after installation.
358 """
359 """
359
360
360 class MyBuildPy(build_cmd):
361 class MyBuildPy(build_cmd):
361 ''' Subclass to write commit data into installation tree '''
362 ''' Subclass to write commit data into installation tree '''
362 def run(self):
363 def run(self):
@@ -371,12 +372,12 def git_prebuild(pkg_dir, build_cmd=build_py):
371 # this one will only fire for build commands
372 # this one will only fire for build commands
372 if hasattr(self, 'build_lib'):
373 if hasattr(self, 'build_lib'):
373 self._record_commit(self.build_lib)
374 self._record_commit(self.build_lib)
374
375
375 def make_release_tree(self, base_dir, files):
376 def make_release_tree(self, base_dir, files):
376 # this one will fire for sdist
377 # this one will fire for sdist
377 build_cmd.make_release_tree(self, base_dir, files)
378 build_cmd.make_release_tree(self, base_dir, files)
378 self._record_commit(base_dir)
379 self._record_commit(base_dir)
379
380
380 def _record_commit(self, base_dir):
381 def _record_commit(self, base_dir):
381 import subprocess
382 import subprocess
382 proc = subprocess.Popen('git rev-parse --short HEAD',
383 proc = subprocess.Popen('git rev-parse --short HEAD',
@@ -385,14 +386,14 def git_prebuild(pkg_dir, build_cmd=build_py):
385 shell=True)
386 shell=True)
386 repo_commit, _ = proc.communicate()
387 repo_commit, _ = proc.communicate()
387 repo_commit = repo_commit.strip().decode("ascii")
388 repo_commit = repo_commit.strip().decode("ascii")
388
389
389 out_pth = pjoin(base_dir, pkg_dir, 'utils', '_sysinfo.py')
390 out_pth = pjoin(base_dir, pkg_dir, 'utils', '_sysinfo.py')
390 if os.path.isfile(out_pth) and not repo_commit:
391 if os.path.isfile(out_pth) and not repo_commit:
391 # nothing to write, don't clobber
392 # nothing to write, don't clobber
392 return
393 return
393
394
394 print("writing git commit '%s' to %s" % (repo_commit, out_pth))
395 print("writing git commit '%s' to %s" % (repo_commit, out_pth))
395
396
396 # remove to avoid overwriting original via hard link
397 # remove to avoid overwriting original via hard link
397 try:
398 try:
398 os.remove(out_pth)
399 os.remove(out_pth)
General Comments 0
You need to be logged in to leave comments. Login now