summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-03-05 21:31:30 +0000
committerSteven Knight <knight@baldmt.com>2005-03-05 21:31:30 +0000
commit37f7563ea516a39234fc91a8ffd9cf22d9258e8b (patch)
tree165ab8ab18b63079883e02dccc84c03992cefc16
parentf7230b12d84220342c2671276beec9a9d590ce22 (diff)
downloadscons-37f7563ea516a39234fc91a8ffd9cf22d9258e8b.tar.gz
Enhance setup.py to install troff man pages on UNIX/Linux.
-rw-r--r--README16
-rw-r--r--SConstruct2
-rw-r--r--rpm/scons.spec.in5
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/README.txt16
-rw-r--r--src/RELEASE.txt3
-rw-r--r--src/setup.py49
-rw-r--r--src/test_setup.py158
8 files changed, 163 insertions, 89 deletions
diff --git a/README b/README
index 7a24f671..358cdc8d 100644
--- a/README
+++ b/README
@@ -126,10 +126,18 @@ And on Windows:
C:\scons\build\scons>python setup.py install
If this is the first time you are installing SCons on your system,
-the above command will install the scons script in the default system
-script directory (/usr/bin or C:\Python*\Scripts, for example) and
-the build engine in an appropriate stand-alone SCons library directory
-(/usr/lib/scons or C:\Python*\scons, for example).
+the above command will install:
+
+ -- the scons script in the default system script directory (/usr/bin
+ or C:\Python*\Scripts, for example);
+
+ -- the build engine in an appropriate stand-alone SCons library
+ directory (/usr/lib/scons or C:\Python*\scons, for example);
+
+ -- on UNIX or Linux systems, the troff-formatted man pages in an
+ appropriate directory (/usr/share/man/man1 or /usr/man/man1,
+ for example). This can be disabled by specifying the
+ "--no-install-doc" option on the command line.
Note that, by default, SCons does not install its library in the
standard Python library directories. If you want to be able to use the
diff --git a/SConstruct b/SConstruct
index 42758ad1..f928efb2 100644
--- a/SConstruct
+++ b/SConstruct
@@ -823,7 +823,7 @@ for p in [ scons ]:
commands = [
Delete(local),
- '$PYTHON $SETUP_PY install "--install-script=%s" "--install-lib=%s" --no-compile' % \
+ '$PYTHON $SETUP_PY install "--install-script=%s" "--install-lib=%s" --no-install-doc --no-compile' % \
(cwd_local, cwd_local_slv),
]
diff --git a/rpm/scons.spec.in b/rpm/scons.spec.in
index 7c30145e..dc6ec03e 100644
--- a/rpm/scons.spec.in
+++ b/rpm/scons.spec.in
@@ -40,10 +40,7 @@ defined Builder and/or Scanner objects.
python setup.py build
%install
-python setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES --install-lib=/usr/lib/scons --install-scripts=/usr/bin
-mkdir -p $RPM_BUILD_ROOT%_mandir/man1
-gzip -c scons.1 > $RPM_BUILD_ROOT%_mandir/man1/scons.1.gz
-gzip -c sconsign.1 > $RPM_BUILD_ROOT%_mandir/man1/sconsign.1.gz
+python setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES --install-lib=/usr/lib/scons --install-scripts=/usr/bin --install-data=/usr/share
%clean
rm -rf $RPM_BUILD_ROOT
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 4124c7c8..2fa54abf 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -222,6 +222,9 @@ RELEASE 0.97 - XXX
is old enough at this point that it probably isn't worth the
effort to make it do so.
+ - Enhanced the SCons setup.py script to install man pages on
+ UNIX/Linux systems.
+
From Wayne Lee:
- Avoid "maximum recursion limit" errors when removing $(-$) pairs
diff --git a/src/README.txt b/src/README.txt
index e31fb219..12645710 100644
--- a/src/README.txt
+++ b/src/README.txt
@@ -87,10 +87,18 @@ provided Python-standard setup script as follows:
# python setup.py install
If this is the first time you are installing SCons on your system,
-the above command will install the scons script in the default system
-script directory (/usr/bin or C:\Python*\Scripts, for example) and the
-build engine in an appropriate stand-alone SCons library directory
-(/usr/lib/scons or C:\Python*\scons, for example).
+the above command will install:
+
+ -- the scons script in the default system script directory (/usr/bin
+ or C:\Python*\Scripts, for example);
+
+ -- the build engine in an appropriate stand-alone SCons library
+ directory (/usr/lib/scons or C:\Python*\scons, for example);
+
+ -- on UNIX or Linux systems, the troff-formatted man pages in an
+ appropriate directory (/usr/share/man/man1 or /usr/man/man1,
+ for example). This can be disabled by specifying the
+ "--no-install-doc" option on the command line.
Note that, by default, SCons does not install its library in the
standard Python library directories. If you want to be able to use the
diff --git a/src/RELEASE.txt b/src/RELEASE.txt
index 4089d5aa..57809e8e 100644
--- a/src/RELEASE.txt
+++ b/src/RELEASE.txt
@@ -87,6 +87,9 @@ RELEASE 0.97 - XXX
different file. This may cause configuration tests to be re-run
the first time after you install 0.97.
+ - The SCons setup.py script now installs the "scons.1" and
+ "sconsign.1" man pages on UNIX and Linux systems.
+
Please note the following important changes since release 0.95:
- All Builder calls (both built-in like Program(), Library(),
diff --git a/src/setup.py b/src/setup.py
index d2b76c0c..bec2b183 100644
--- a/src/setup.py
+++ b/src/setup.py
@@ -37,6 +37,7 @@ if head:
try:
import distutils.core
import distutils.command.install
+ import distutils.command.install_data
import distutils.command.install_lib
import distutils.command.install_scripts
import distutils.command.build_scripts
@@ -51,15 +52,18 @@ your system, or on how to install SCons from a different package.
sys.exit(1)
_install = distutils.command.install.install
+_install_data = distutils.command.install_data.install_data
_install_lib = distutils.command.install_lib.install_lib
_install_scripts = distutils.command.install_scripts.install_scripts
_build_scripts = distutils.command.build_scripts.build_scripts
+install_doc = 1
standard_lib = 0
standalone_lib = 0
version_lib = 0
installed_lib_dir = None
+installed_man_pages_dir = None
installed_scripts_dir = None
def set_explicitly(name, args):
@@ -84,6 +88,8 @@ def set_explicitly(name, args):
class install(_install):
user_options = _install.user_options + [
+ ('no-install-doc', None,
+ "do not install SCons man pages"),
('standard-lib', None,
"install SCons library in standard Python location"),
('standalone-lib', None,
@@ -92,6 +98,7 @@ class install(_install):
"install SCons library in version-specific directory")
]
boolean_options = _install.boolean_options + [
+ 'no-install-doc',
'standard-lib',
'standalone-lib',
'version-lib'
@@ -99,6 +106,7 @@ class install(_install):
def initialize_options(self):
_install.initialize_options(self)
+ self.no_install_doc = 0
self.standard_lib = 0
self.standalone_lib = 0
self.version_lib = 0
@@ -106,7 +114,9 @@ class install(_install):
def finalize_options(self):
_install.finalize_options(self)
- global standard_lib, standalone_lib, version_lib
+ global install_doc, standard_lib, standalone_lib, version_lib
+ if self.no_install_doc:
+ install_doc = 0
standard_lib = self.standard_lib
standalone_lib = self.standalone_lib
version_lib = self.version_lib
@@ -194,6 +204,19 @@ class build_scripts(_build_scripts):
_build_scripts.finalize_options(self)
self.build_dir = os.path.join('build', 'scripts')
+class install_data(_install_data):
+ def initialize_options(self):
+ _install_data.initialize_options(self)
+ global install_doc
+ self.install_doc = install_doc
+ def finalize_options(self):
+ _install_data.finalize_options(self)
+ if self.install_doc:
+ global installed_man_pages_dir
+ installed_man_pages_dir = self.install_dir + '/man/man1'
+ else:
+ self.data_files = []
+
arguments = {
'name' : "scons",
'version' : "__VERSION__",
@@ -210,19 +233,31 @@ arguments = {
'scripts' : ['script/scons', 'script/sconsign'],
'cmdclass' : {'install' : install,
'install_lib' : install_lib,
+ 'install_data' : install_data,
'install_scripts' : install_scripts,
'build_scripts' : build_scripts}
}
-try:
- if sys.platform == 'win32' or sys.argv[1] == "bdist_wininst":
- arguments['data_files'] = [('.', ["script/scons.bat"])]
-except IndexError:
- pass
+is_win32 = 0
+if not sys.platform == 'win32':
+ try:
+ if sys.argv[1] == 'bdist_wininst':
+ is_win32 = 1
+ except IndexError:
+ pass
+else:
+ is_win32 = 1
+
+if is_win32:
+ arguments['data_files'] = [('.', ["script/scons.bat"])]
+else:
+ arguments['data_files'] = [('man/man1', ["scons.1", "sconsign.1"])]
apply(distutils.core.setup, (), arguments)
if installed_lib_dir:
print "Installed SCons library modules into %s" % installed_lib_dir
+if installed_man_pages_dir:
+ print "Installed SCons man pages into %s" % installed_man_pages_dir
if installed_scripts_dir:
- print "Installed SCons script into %s" % installed_scripts_dir
+ print "Installed SCons scripts into %s" % installed_scripts_dir
diff --git a/src/test_setup.py b/src/test_setup.py
index 4198af66..ab5b6513 100644
--- a/src/test_setup.py
+++ b/src/test_setup.py
@@ -25,7 +25,7 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
-Test how the setup.py script installs SCons (specifically, its libraries).
+Test how the setup.py script installs SCons.
Note that this is an installation test, not a functional test, so the
name of this script doesn't end in *Tests.py.
@@ -37,114 +37,134 @@ import shutil
import string
import sys
+#try:
+# version = os.environ['SCONS_VERSION']
+#except KeyError:
+# version = '__VERSION__'
+version = '0.96'
+
+scons_version = 'scons-%s' % version
+
import TestSCons
python = TestSCons.python
class MyTestSCons(TestSCons.TestSCons):
- def installed(self, lib):
+
+ scripts = [
+ 'scons',
+ 'sconsign',
+ ]
+
+ man_pages = [
+ 'scons.1',
+ 'sconsign.1',
+ ]
+
+ def __init__(self):
+ TestSCons.TestSCons.__init__(self)
+ self.root = self.workpath('root')
+ self.prefix = self.root + sys.prefix
+
+ self.lib_dir = os.path.join(self.prefix, 'lib')
+ self.standard_lib = os.path.join(self.lib_dir,
+ 'python%s' % sys.version[:3],
+ 'site-packages/')
+ self.standalone_lib = os.path.join(self.lib_dir, 'scons')
+ self.version_lib = os.path.join(self.lib_dir, scons_version)
+
+ self.bin_dir = os.path.join(self.prefix, 'bin')
+
+ self.man_dir = os.path.join(self.prefix, 'man', 'man1')
+
+ def run(self, *args, **kw):
+ kw['chdir'] = scons_version
+ kw['program'] = python
+ kw['stderr'] = None
+ return apply(TestSCons.TestSCons.run, (self,)+args, kw)
+
+ def must_have_installed_lib(self, lib):
lines = string.split(self.stdout(), '\n')
- return ('Installed SCons library modules into %s' % lib) in lines
+ line = 'Installed SCons library modules into %s' % lib
+ self.fail_test(not line in lines)
+
+ def must_have_installed_scripts(self):
+ lines = string.split(self.stdout(), '\n')
+ line = 'Installed SCons scripts into %s' % self.bin_dir
+ self.fail_test(not line in lines)
+ for script in self.scripts:
+ self.must_exist([self.bin_dir, script])
+
+ def must_have_installed_man_pages(self):
+ lines = string.split(self.stdout(), '\n')
+ line = 'Installed SCons man pages into %s' % self.man_dir
+ self.fail_test(not line in lines)
+ for mp in self.man_pages:
+ self.must_exist([self.man_dir, mp])
try:
cwd = os.environ['SCONS_CWD']
except KeyError:
cwd = os.getcwd()
-#try:
-# version = os.environ['SCONS_VERSION']
-#except KeyError:
-# version = '__VERSION__'
-version = '0.96'
-
-scons_version = 'scons-%s' % version
-
tar_gz = os.path.join(cwd, 'build', 'dist', '%s.tar.gz' % scons_version)
-test = MyTestSCons()
-
if not os.path.isfile(tar_gz):
print "Did not find an SCons package `%s'." % tar_gz
print "Cannot test package installation."
test.no_result(1)
-test.subdir('root', 'prefix')
-
-root = test.workpath('root')
-prefix = test.workpath('prefix')
+test = MyTestSCons()
-lib_dir = os.path.join(root + sys.prefix, 'lib')
-standard_lib = os.path.join(lib_dir,
- 'python%s' % sys.version[:3],
- 'site-packages/')
-standalone_lib = os.path.join(lib_dir, 'scons')
-version_lib = os.path.join(lib_dir, scons_version)
+test.subdir(test.root)
+# Unpack the .tar.gz file. This should create the scons_version/
+# subdirectory from which we execute the setup.py script therein.
os.system("gunzip -c %s | tar xf -" % tar_gz)
-# Verify that a virgin installation installs the standalone library.
-test.run(chdir = scons_version,
- program = python,
- arguments = 'setup.py install --root=%s' % root,
- stderr = None)
-test.fail_test(not test.installed(standalone_lib))
+# Verify that a virgin installation installs the standalone library,
+# the scripts and the man pages.
+test.run(arguments = 'setup.py install --root=%s' % test.root)
+test.must_have_installed_lib(test.standalone_lib)
+test.must_have_installed_scripts()
+test.must_have_installed_man_pages()
# Verify that --standard-lib installs into the Python standard library.
-test.run(chdir = scons_version,
- program = python,
- arguments = 'setup.py install --root=%s --standard-lib' % root,
- stderr = None)
-lines = string.split(test.stdout(), '\n')
-test.fail_test(not test.installed(standard_lib))
+test.run(arguments = 'setup.py install --root=%s --standard-lib' % test.root)
+test.must_have_installed_lib(test.standard_lib)
# Verify that --standalone-lib installs the standalone library.
-test.run(chdir = scons_version,
- program = python,
- arguments = 'setup.py install --root=%s --standalone-lib' % root,
- stderr = None)
-test.fail_test(not test.installed(standalone_lib))
+test.run(arguments = 'setup.py install --root=%s --standalone-lib' % test.root)
+test.must_have_installed_lib(test.standalone_lib)
# Verify that --version-lib installs into a version-specific library directory.
-test.run(chdir = scons_version,
- program = python,
- arguments = 'setup.py install --root=%s --version-lib' % root,
- stderr = None)
-test.fail_test(not test.installed(version_lib))
+test.run(arguments = 'setup.py install --root=%s --version-lib' % test.root)
+test.must_have_installed_lib(test.version_lib)
# Now that all of the libraries are in place,
# verify that a default installation finds the version-specific library first.
-test.run(chdir = scons_version,
- program = python,
- arguments = 'setup.py install --root=%s' % root,
- stderr = None)
-test.fail_test(not test.installed(version_lib))
+test.run(arguments = 'setup.py install --root=%s' % test.root)
+test.must_have_installed_lib(test.version_lib)
-shutil.rmtree(version_lib)
+shutil.rmtree(test.version_lib)
# Now with only the standard and standalone libraries in place,
# verify that a default installation finds the standalone library first.
-test.run(chdir = scons_version,
- program = python,
- arguments = 'setup.py install --root=%s' % root,
- stderr = None)
-test.fail_test(not test.installed(standalone_lib))
+test.run(arguments = 'setup.py install --root=%s' % test.root)
+test.must_have_installed_lib(test.standalone_lib)
-shutil.rmtree(standalone_lib)
+shutil.rmtree(test.standalone_lib)
# Now with only the standard libraries in place,
# verify that a default installation installs the standard library.
-test.run(chdir = scons_version,
- program = python,
- arguments = 'setup.py install --root=%s' % root,
- stderr = None)
-test.fail_test(not test.installed(standard_lib))
-
-# Verify that we're not warning about the directory in which
-# we've installed the modules when using a non-standard prefix.
-test.run(chdir = scons_version,
- program = python,
- arguments = 'setup.py install --prefix=%s' % prefix,
- stderr = None)
+test.run(arguments = 'setup.py install --root=%s' % test.root)
+test.must_have_installed_lib(test.standard_lib)
+
+# Verify that we don't warn about the directory in which we've
+# installed the modules when using a non-standard prefix.
+other_prefix = test.workpath('other-prefix')
+test.subdir(other_prefix)
+test.run(arguments = 'setup.py install --prefix=%s' % other_prefix)
test.fail_test(string.find(test.stderr(),
"you'll have to change the search path yourself")
!= -1)