summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2004-12-07 03:25:18 +0000
committerBrett Cannon <bcannon@gmail.com>2004-12-07 03:25:18 +0000
commit84667c063a1e93a985134f7cef376edf82941c02 (patch)
tree04ea49ba40272d175f7ae7dd5a3253d00887d3b3
parent516592f4ff13ee39ebd115088c7429631328e2db (diff)
downloadcpython-git-84667c063a1e93a985134f7cef376edf82941c02.tar.gz
Change code in setup.py for parsing LDFLAGS and CPPFLAGS to use optparse
instead of getopt. Required making use of gettext._ as optional (optparse changed OK'ed by Greg Ward in private email).
-rw-r--r--Lib/optparse.py5
-rw-r--r--Misc/NEWS2
-rw-r--r--setup.py11
3 files changed, 11 insertions, 7 deletions
diff --git a/Lib/optparse.py b/Lib/optparse.py
index 4a3d3a8950..6d3c94bff3 100644
--- a/Lib/optparse.py
+++ b/Lib/optparse.py
@@ -69,7 +69,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import sys, os
import types
import textwrap
-from gettext import gettext as _
+try:
+ from gettext import gettext as _
+except ImportError:
+ _ = lambda arg: arg
def _repr(self):
return "<%s at 0x%x: %s>" % (self.__class__.__name__, id(self), self)
diff --git a/Misc/NEWS b/Misc/NEWS
index 380bf9a972..ffeb29b02c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,8 @@ Extension Modules
Library
-------
+- optparse now optionally imports gettext. This allows its use in setup.py.
+
- the deprecated tzparse module was removed.
- the pickle module no longer uses the deprecated bin parameter.
diff --git a/setup.py b/setup.py
index c9f94ab183..807cd59468 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
__version__ = "$Revision$"
-import sys, os, imp, re, getopt
+import sys, os, imp, re, optparse
from distutils import log
from distutils import sysconfig
@@ -253,11 +253,10 @@ class PyBuildExt(build_ext):
('CPPFLAGS', '-I', self.compiler.include_dirs)):
env_val = os.getenv(env_var)
if env_val:
- # getopt is used instead of optparse because the latter imports
- # gettext which imports struct which has not been built yet
- # when this method is needed
- options = getopt.getopt(env_val.split(), arg_name[1] + ':')[0]
- for arg_option, directory in options:
+ parser = optparse.OptionParser()
+ parser.add_option(arg_name, dest="dirs", action="append")
+ options = parser.parse_args(env_val.split())[0]
+ for directory in options.dirs:
add_dir_to_list(dir_list, directory)
if os.path.normpath(sys.prefix) != '/usr':