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