[Catalog-sig] How to determine if archive is an sdist or bdist

James Carpenter nawkboy at gmail.com
Mon Apr 1 00:13:46 CEST 2013


Do you have a module/function/line number in easy_install I should use? I'm
sure I can dig it out myself but it sounds like you might just be able to
put your finger on it in only a minute or two.

Same question for a pre-existing utility function for reading a
requirements file. I'm guessing there is one burried down in the PIP code,
but I haven't looked yet.

A third more interesting question, is whether there is any way to determine
the origin of an installed package. I am building up a build-info to push
into Artifactory and it takes a "type" if available when listing
dependencies of a build. In Java/Maven land a typical type would be jar,
war, pom, etc. My current understanding is this is a non-sense question,
since once a Python module is installed it looks the same regardless of
whether it came from an sdist, wheel, etc.

In case your wondering, I am building a set of utilities to support
continuous deployment within Python. I am using Artifactory as my
repository manager (think internal PyPI server). I hope to publish these
utilities externally when I get done in a few weeks.




On Fri, Mar 29, 2013 at 1:54 PM, PJ Eby <pje at telecommunity.com> wrote:

> On Fri, Mar 29, 2013 at 11:00 AM, James Carpenter <nawkboy at gmail.com>
> wrote:
> > Looks like the idea of using a custom command is a better approach then.
>
> I'm not sure why you think that.  The only kinds of archives whose
> file types are ambiguous from the name, are sdist, bdist_dumb, and
> random raw source dumps.  Everything else has a unique extension like
> .egg, .exe, .msi, rpm, etc.  If you have a .zip, .tar.gz, .tgz, or
> some other archive name, you can find out if it's an sdist by
> inspecting its contents as I described.  And if it's not an sdist, you
> can usually tell if it's a raw source dump by checking for a setup.py
> in the archive root or a depth-1 subdirectory off the root.  (That's
> what easy_install does, anyway, when it's given an archive it doesn't
> know what to do with.)
>
> >
> > Is a custom command my only choice or can I register pre/post hooks to
> any
> > given command?
> >
> >
> > On Thu, Mar 28, 2013 at 3:36 PM, PJ Eby <pje at telecommunity.com> wrote:
> >>
> >> On Thu, Mar 28, 2013 at 3:57 PM, James Carpenter <nawkboy at gmail.com>
> >> wrote:
> >> > Is there an easy way to programmatically tell if an archive (tar.gz,
> >> > zip,
> >> > etc.) in the dist directory is a binary or sdist? I would like to
> >> > post-process the contents of a dist directory and classify each build
> >> > artifact there (egg, sdist, bdist, etc.).
> >>
> >> An sdist always has a single subdirectory in the archive's root
> >> directory, named for the package+version, and containing a PKG-INFO
> >> and setup.py (plus a bunch of other stuff).
> >>
> >> A bdist_dumb will not have such a subdirectory in the archive root;
> >> instead it will have one or more directories like /usr, /opt, /Program
> >> Files.
> >>
> >> Other bdist formats?  Hard to say.
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/catalog-sig/attachments/20130331/2c92e28a/attachment.html>


More information about the Catalog-SIG mailing list