summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-06-29 20:41:51 +0000
committerwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-06-29 20:41:51 +0000
commitbfa5a2a0bc5fcd6fbbfb63613d4ff9ce2dc7af38 (patch)
treec6a773d6b6905d3e50043ecef3088d2d541443ed /setup.py
parent6d952cc3772a84163307a99b8f5152f5bf3cbacf (diff)
downloaddocutils-bfa5a2a0bc5fcd6fbbfb63613d4ff9ce2dc7af38.tar.gz
use different hacks for installing data files for Python 2.2
and Python 2.3+; thanks to Guy D. Alcos! git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4644 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index 903e58682..46daaeb71 100755
--- a/setup.py
+++ b/setup.py
@@ -8,6 +8,7 @@ import glob
try:
from distutils.core import setup
from distutils.command.build_py import build_py
+ from distutils.command.install_data import install_data
except ImportError:
print 'Error: The "distutils" standard module, which is required for the '
print 'installation of Docutils, could not be found. You may need to '
@@ -15,10 +16,25 @@ except ImportError:
print 'system using your package manager.'
sys.exit(1)
-# From <http://groups.google.de/groups?as_umsgid=f70e3538.0404141327.6cea58ca@posting.google.com>.
-from distutils.command.install import INSTALL_SCHEMES
-for scheme in INSTALL_SCHEMES.values():
- scheme['data'] = scheme['purelib']
+if sys.hexversion < 0x02030000:
+ # Hack for Python < 2.3.
+ # From <http://groups.google.de/groups?as_umsgid=f70e3538.0404141327.6cea58ca@posting.google.com>.
+ from distutils.command.install import INSTALL_SCHEMES
+ for scheme in INSTALL_SCHEMES.values():
+ scheme['data'] = scheme['purelib']
+
+
+class smart_install_data(install_data):
+
+ # Hack for Python > 2.3.
+ # From <http://wiki.python.org/moin/DistutilsInstallDataScattered>,
+ # by Pete Shinners.
+
+ def run(self):
+ #need to change self.install_dir to the library dir
+ install_cmd = self.get_finalized_command('install')
+ self.install_dir = getattr(install_cmd, 'install_lib')
+ return install_data.run(self)
def do_setup():
@@ -28,7 +44,15 @@ def do_setup():
kwargs['py_modules'] = extras
if sys.hexversion >= 0x02030000: # Python 2.3
kwargs['classifiers'] = classifiers
+ # Install data files properly. Note that we use a different
+ # hack for Python 2.2, which does not *always* work, though;
+ # see
+ # <http://article.gmane.org/gmane.text.docutils.user/2867>.
+ # So for Python 2.3+, we prefer this hack.
+ kwargs['cmdclass'] = {'install_data': smart_install_data}
else:
+ # Install data files properly. (Another hack for Python 2.2
+ # is at the top of this file.)
kwargs['cmdclass'] = {'build_py': dual_build_py}
dist = setup(**kwargs)
return dist