[Distutils] Re: Proposed bdist_dumb fix
Thomas Heller
theller@python.net
Thu Nov 21 15:25:13 2002
Andrew Kuchling <akuchlin@mems-exchange.org> writes:
> Here's a proposed patch to alleviate the bdist_dumb problem. (Patch
> also attached to bug #410541.)
>
> It adds a --from-root Boolean option to bdist_dumb. from-root
> defaults to true, in which case you get the current behaviour. If you
> set it to false, the archive is built from $base, not /, so you end up
> with an archive containing ./lib/python2.3/site-packages/my-package on
> Unix. On Windows you should end up with
> ./Lib/site-packages/mypackage, ./Include/mypackage.h, etc. Ditto for
> the Mac.
>
> The only problem is on Unix if $platbase is different from $base. For
> example, you're installing Python code into /usr/share and C
> extensions into /usr/local/. Here the code simply throws up its hands
> and raises an exception.
>
> Thoughts? Is this a good solution? Does it work as I expect on
> Windows and MacOS 9?
>
> --amk (www.amk.ca)
> I'll never be cruel to an electron in a particle accelerator again.
> -- The Doctor, in "The Pirate Planet"
>
> Index: bdist_dumb.py
> ===================================================================
> RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_dumb.py,v
> retrieving revision 1.22
> diff -u -r1.22 bdist_dumb.py
> --- bdist_dumb.py 19 Nov 2002 13:12:28 -0000 1.22
> +++ bdist_dumb.py 21 Nov 2002 19:35:10 -0000
> @@ -33,9 +33,13 @@
> "directory to put final built distributions in"),
> ('skip-build', None,
> "skip rebuilding everything (for testing/debugging)"),
> + ('from-root=', None,
> + "build the archive using paths from the root directory "
> + "and not relative paths "
> + "(default: true)"),
> ]
>
> - boolean_options = ['keep-temp', 'skip-build']
> + boolean_options = ['keep-temp', 'skip-build', 'from-root']
>
> default_format = { 'posix': 'gztar',
> 'nt': 'zip',
> @@ -49,7 +53,8 @@
> self.keep_temp = 0
> self.dist_dir = None
> self.skip_build = 0
> -
> + self.from_root = 1
> +
> # initialize_options()
>
>
> @@ -97,9 +102,29 @@
> if os.name == "os2":
> archive_basename = archive_basename.replace(":", "-")
>
> - self.make_archive(os.path.join(self.dist_dir, archive_basename),
> - self.format,
> - root_dir=self.bdist_dir)
> + pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
> + if self.from_root:
> + archive_root = self.bdist_dir
> + else:
> + if (self.distribution.has_ext_modules() and
> + (install.install_base != install.install_platbase)):
> + raise DistutilsPlatformError, \
> + ("can't make a dumb built distribution where "
> + "base and platbase are different (%s, %s)"
> + % (repr(install.install_base),
> + repr(install.install_platbase)))
> + else:
> + # install_base usually is a full path; we need to
> + # make it a relative path so it can be the second argument
> + # to os.path.join().
> + t = install.install_base
> + if t[0:1] == os.sep:
> + t = t[1:]
> + archive_root = os.path.join(self.bdist_dir, t)
> +
> + # Make the archive
> + self.make_archive(pseudoinstall_root,
> + self.format, root_dir=archive_root)
>
> if not self.keep_temp:
> remove_tree(self.bdist_dir, dry_run=self.dry_run)
>
> _______________________________________________
> Distutils-SIG maillist - Distutils-SIG@python.org
> http://mail.python.org/mailman/listinfo/distutils-sig