[Distutils] EasyInstall: svn support
Phillip J. Eby
pje at telecommunity.com
Sun May 29 22:49:29 CEST 2005
At 02:46 PM 5/29/2005 -0500, Ian Bicking wrote:
>I just tried out EasyInstall, and it seems to work pretty well. Well,
>I've only tried downloading packages, not really using them, but I'll try
>that next...
>
>I added support to download from subversion repositories.
Thanks! I was going to suggest you might want to look at contributing
that. :)
> Basically it detects the svn index page (for http repositories, which
> can't be detected based on the URL), or the svn: URL type, and downloads
> from there. I'd like for it to fix up the version based on the svn
> revision, but I haven't looked closely enough at that part yet, or if
> it's even possible since setup.py typically has a version hardcoded in
> it. I'm not even sure what the version number should look like, so that
> it sorts properly with released versions (or even if it should sort with
> released versions at all; should versions also indicate branches, like
> stable vs. development?)
Yeah, I think sticking with the setup.py version is best; EasyInstall and
pkg_resources use the generated PKG-INFO to find out stuff like that.
>Anyway, I've attached a diff against 0.3a1 and the compete modified
>easy_install.py file.
I was a bit puzzled by the diff at first; looks like you created a reversed
diff.
>--- easy_install.py 2005-05-29 14:30:03.858797032 -0500
>+++ orig/setuptools-0.3a1/easy_install.py 2005-05-28
>21:36:42.000000000 -0500
>@@ -154,7 +154,6 @@
> """
>
> import sys, os.path, pkg_resources, re, zipimport
>-import shutil
> from pkg_resources import *
>
>
>@@ -220,7 +219,7 @@
> if isinstance(spec,Requirement):
> pass
> else:
>- scheme = URL_SCHEME(spec).group(1)
This won't work with non-URL specs. Note that spec is allowed to be a
local filename, or a version requirement (e.g. "FooPackage==1.2"). Anyway,
I moved the group() to the _download_url() call, where it should accomplish
the intent here.
As for this next bit below, you're just skipping the archive checks if the
source is a directory, right? There aren't any changes to the archive
handling parts?
> # Anything else, try to extract and build
>- if not os.path.isdir(dist_filename):
>- import zipfile, tarfile
>- if zipfile.is_zipfile(dist_filename):
>- self._extract_zip(dist_filename, self.tmpdir)
>+ import zipfile, tarfile
>+ if zipfile.is_zipfile(dist_filename):
>+ self._extract_zip(dist_filename, self.tmpdir)
>+ else:
>+ import tarfile
>+ try:
>+ tar = tarfile.open(dist_filename)
>+ except tarfile.TarError:
>+ raise RuntimeError(
>+ "Not a valid tar or zip archive: %s" % dist_filename
>+ )
> else:
>- import tarfile
>- try:
>- tar = tarfile.open(dist_filename)
>- except tarfile.TarError:
>- raise RuntimeError(
>- "Not a valid tar or zip archive: %s" % dist_filename
>- )
>- else:
>- self._extract_tar(tar)
>+ self._extract_tar(tar)
>
> # Find the setup.py file
> from glob import glob
>@@ -374,7 +372,7 @@
> destination = os.path.join(self.instdir, os.path.basename(egg_path))
> ensure_directory(destination)
>- if not os.path.exists(destination) or not self.samefile(egg_path,
>destination):
>+ if not self.samefile(egg_path, destination):
I don't understand what this change is for. Since install_egg is only
called with an existing .egg file or directory, this means that if the
destination doesn't exist, it can't be the same file. So, the addition
here seems redundant.
>- # Check if it is a subversion index page:
Before doing this, I think it would be a good idea to check the headers for
a text/html Content-Type, so as not to be readline() a big chunk of binary. :)
>- def _download_svn(self, scheme, url, filename):
>- os.system("svn checkout -q %s %s" % (url, filename))
Why checkout instead of export? Oh, I see, it's so you can use svn info
later. Never mind.
>- # Actually, this probably doesn't do anything; but somehow this
>- # information should get put into the version string...
It indeed doesn't do anything; you'd be better off munging the setup.py to
change the setup version.
Maybe what I can do is have the build stuff look for a .svn dir in the
build area, and if one is present, grab the revision and add it to the end
of the version string supplied to setup(). Or simpler still, I could add a
'--tag-svn-revision' option to bdist_egg, that would make *it* do
that. I've been thinking it would be nice to have a '--tag-build=NUMBER'
or '--tag-date' option for bdist_egg anyway, to support daily builds and
such. So adding an option to "get the tag value from 'svn info'" would
just be a minor variation on the theme.
Anyway, do you have some handy svn: and http: subversion URLs that I could
play with for testing?
More information about the Distutils-SIG
mailing list