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

PJ Eby pje at telecommunity.com
Fri Mar 29 19:54:22 CET 2013


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.
>
>


More information about the Catalog-SIG mailing list