1. Éric Araujo
  2. distutils2-features

Commits

Éric Araujo  committed b8bf775

Try to work around the options initialization problem. Does not work.

  • Participants
  • Parent commits 899ad71
  • Branches configure

Comments (0)

Files changed (3)

File src/distutils2/command/configure.py

View file
  • Ignore whitespace
     negative_opt = negative_build_opt.copy()
     negative_opt.update(negative_install_opt)
 
+    # Sentinel value to prevent double-checking of option conflicts
+    # (options set in install from configure would cause an error in
+    # finalize_install_options)
+    _from_configure = False
 
     # -- Proper configure methods -------------------------------------
 
         self.install_lib = None         # set to either purelib or platlib
         self.install_scripts = None
         self.install_data = None
-        self.install_userbase = get_config_var('userbase')
-        self.install_usersite = get_path('purelib', '%s_user' % os.name)
+        self.install_userbase = None
+        self.install_usersite = None
 
         self.compile = None
         self.optimize = None
         # that's wrong on any platform.
 
         if ((self.prefix or self.exec_prefix or self.home) and
-            (self.install_base or self.install_platbase)):
+            (self.install_base or self.install_platbase) and
+            not self._from_configure):
             raise DistutilsOptionError(
                 "must supply either prefix/exec-prefix/home or "
                 "install-base/install-platbase -- not both")
 
-        if self.home and (self.prefix or self.exec_prefix):
+        if (self.home and (self.prefix or self.exec_prefix) and
+            not self._from_configure):
             raise DistutilsOptionError(
                 "must supply either home or prefix/exec-prefix -- not both")
 
-        if self.user and (self.prefix or self.exec_prefix or self.home or
-                          self.install_base or self.install_platbase):
+        if (self.user and (self.prefix or self.exec_prefix or self.home or
+                           self.install_base or self.install_platbase) and
+            not self._from_configure):
+
             raise DistutilsOptionError(
                 "can't combine user with prefix/exec_prefix/home or "
                 "install_base/install_platbase")
                 self.warn("exec-prefix option ignored on this platform")
                 self.exec_prefix = None
 
+        # Set default values for user site-packages scheme
+        if self.install_userbase is None:
+            self.install_userbase = get_config_var('userbase')
+        if self.install_usersite is None:
+            self.install_usersite = get_path('purelib', '%s_user' % os.name)
+
         # Now the interesting logic -- so interesting that we farm it out
         # to other methods.  The goal of these methods is to set the final
         # values for the install_{lib,scripts,data,...}  options, using as

File src/distutils2/command/install.py

View file
  • Ignore whitespace
 
     # All options are basically defined, initialized and finalized in
     # configure, except for the ones that conflict with options from
-    # build.  See the little dance done with 'force' as an example
-    # ('force_install' on configure).
+    # build (example: 'force', 'force_install' on configure).
 
     user_options = configure.install_options + [
         ('force', 'f',
         self.warn_dir = 1
 
     def finalize_options(self):
-        self.force_install = self.force
+        # Find out the build directories, i.e. where to install from, from
+        # the 'configure' or 'build' command.  Also take other options from
+        # 'configure'.
+        self.set_undefined_options('configure',
+            *(option[0].rstrip('=').replace('-', '_')
+              for option in self.install_options
+              if option[0] not in self.negative_opt))
+        self.set_undefined_options('configure', ('force_install', 'force'))
+        self.set_undefined_options('build', 'build_base', 'build_lib')
+        self._from_configure = True
         configure.finalize_install_options(self)
-        self.force = self.force_install
-
-        # Find out the build directories, i.e. where to install from.
-        self.set_undefined_options('build', 'build_base', 'build_lib')
 
     # -- Command execution methods -------------------------------------
 

File src/distutils2/tests/test_configure.py

View file
  • Ignore whitespace
     # + test running configure first and then install
 
     def test_together(self):
-        dist = self.run_cmd('configure --prefix /TEST3 install')
+        dist = self.run_cmd('--dry-run configure --prefix /TEST3 install')
         install = dist.get_command_obj('install')
         self.assertEqual(install.prefix, '/TEST3')
 
     # (use options that are not taken from build by install)
 
     def test_together(self):
-        dist = self.run_cmd('configure --build-base . --prefix . '
+        dist = self.run_cmd('configure --build-base TEST1 --prefix TEST2 '
                             'build install')
         build = dist.get_command_obj('build')
         install = dist.get_command_obj('install')
-        self.assertEqual(build.build_base, 'build')
-        self.assertEqual(install.prefix, '/usr')
+        self.assertEqual(build.build_base, 'TEST1')
+        self.assertEqual(install.prefix, 'TEST2')
 
     def test_separate(self):
         dist = self.run_cmd('configure --executable=python-goats '