Re: [Distutils] setup.cfg new format proposal

2009-09-14 Thread Glyph Lefkowitz
On Fri, Sep 11, 2009 at 1:40 PM, Jim Fulton j...@zope.com wrote:

 On Fri, Sep 11, 2009 at 11:49 AM, Tarek Ziadé ziade.ta...@gmail.com
 wrote:
  On Fri, Sep 11, 2009 at 5:36 PM, Jim Fulton j...@zope.com wrote:
  On Fri, Sep 11, 2009 at 11:14 AM, Tarek Ziadé ziade.ta...@gmail.com
 wrote:
  2009/9/11  exar...@twistedmatrix.com:
  On 02:33 pm, ziade.ta...@gmail.com wrote:
  I'm a little skeptical about creating a new mini language
 (particularly one
  with branching) for setup.cfg,
 
  Me too.


Me three.  Even after hearing the motivating use-cases, like:

 So you can for example define a list of dependencies that changes wether
  you are under windows or linux, etc..

 OK. I've never had that situation. I'm sure someone has, but it
 doesn't see common.


Twisted actually has this.  On Windows, we need pywin32 to implement many of
the features which can be implemented with just the stdlib on Posix.  But
this is the only thing I can imagine computing based on the execution
environment.

 try to run this with lxml source tarball:
 
  $ python setup.py --name
 
  I don't know what it is doing, but a whole lot more that what it is
  suppose to do
  just to let me know the 'name' metadata.
 
  So if name was in setup.cfg, it would be better.


One big problem I have with this discussion is that it seems to be
approaching the whole problem backwards.  Distutils projects seem to have a
history of defining new file formats rather than or before new APIs.
 (PKG-INFO, MANIFEST.in, egg-info, etc etc).

I may be missing some context, but I did about an hour of googling around
before responding here, and for the life of me I can't find a simple answer
to the question: how do I currently programatically get the metadata out of
a distribution?

The answer seems to be a bizarre combination of running setup.py, maybe
reading PKG-INFO, maybe something to do with egg-info...?  Or maybe making
some direct calls with xmlrpclib?  Or setuptools?  Setuptools must be able
to do it internally, but I can't find an API in the documentation.

Before trying to make the metadata static, let's try to have the metadata,
for real, at all.  Here's an example of something I want to be able to do
with metadata:

from distutils.something import (
load_metadata, pypi_metadata, installed_metadata)
meta = installed_metadata(Twisted)
meta2 = load_metadata(/home/glyph/Downloads/Twisted-x.y)
meta3 = pypi_metadata(Twisted)
if meta2.version  meta.version:
print 'More recent version of Twisted already downloaded!'
if meta3.version  meta2.version:
print 'More recent version of Twisted is available online!'


Important points here:

   - I can get the same metadata, in the same format, from PyPI, from a
   directory containing the distribution, and from my installed system.
   - There are supported functions that abstract this stuff away for me.
Working with the packages, I don't have to know how the metadata is
   actually declared.
   - There is a single data structure, hopefully with some API documentation
   I can look at.

Now, maybe the data structure that I want already exists and I just don't
know about it (is it a distutils Distribution, maybe?) but it's certainly
hard to get a handle on one.

In order to be useful, the code that loads this metadata is going to need to
execute setup.py sometimes anyway.  Tarek, as you said in your blog post,
there will always be edge cases.  So it doesn't seem too useful to be
focusing on getting rid of that requirement right away.  And when you
download from PyPI, you probably eventually have to execute a bunch of
untrusted code that somebody uploaded to a wiki, as root.  Again it would be
nice to fix that, but we have a long way to go :).

For what it's worth, on the implementation side of things, I think that the
library code on the client side should receive enough metadata that it can
do the job of applying the execution environment locally.  I don't
necessarily want to send pypi a bunch of information about my machine just
to figure out what distutils would tell me if I tried to install something.

If there were such an API then setup.cfg would simply be a small
implementation detail.  The problem with lxml will still need to be
addressed, by promoting awareness of the fact that your setup.py may be
executed to do things other than install or submit your package.  Before
adding conditional support to setup.cfg I would want to have a separate
'metadata.py' whose responsibilities were clearer: just produce the
metadata, don't do any pre-build steps.  Ideally that would be easy to load
correctly from setup.py as well.

Inspecting metadata could also be made easier by having an API more like
this for setup.py:

d = Distribution(... metadata )
if d.installing:
my_project.custom_prepare_for_build()
d.setup()

since you can't really tell what setup() is going to do until you've already
called it.

So finally, if there's still no standard programmatic way to get at the
distribution metadata 

Re: [Distutils] [buidout] ignoring site-packages

2009-09-14 Thread Martijn Faassen

Chris Withers wrote:

Martijn Faassen wrote:
A long-standing issue with using buildout is that even though it 
creates a restricted environment, it still uses the site-packages of 
the system 


I thought the --no-site-packages stuff had already been implemented and 
was just waiting for Jim to review the branch?


I hadn't realized Gary did so much work. I glanced at the branch briefly 
today and it looked very interesting. I'm looking forward to seeing 
those features. (And thanks to Gary if he's listening!)


Regards,

Martijn

___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig


Re: [Distutils] Compile C code and install to script dir?

2009-09-14 Thread OB
Thank you for the quick response. Unfortunately, there are still a few
difficulties I am having.

One issue is that I do not have an Extention in this package to piggyback
the hello.c - hello compilation onto. This compilation would also be
performed for /every/ Extension given in ext_modules. If no extensions are
given, the compilation never happens. If files that are not really python
extensions are given, distutils crashes when trying to construct the egg
because there is no real extension.

Another issue for me is that the link_executable command seems to not
include data the environment variable LDPATH, unlike link_shared_object and
preprocess. This isn't a huge deal, but it meant that I had to manually
insert the LDPATH flags into link_executable's extra_preargs

If, instead of overriding build_ext, I try to do this outside of setup, a
few issues get much harder. Without access to build_ext's self.build_temp
and self.build_lib, how do I put the compiled binary into the right egg
directory? 

Any further advice would be greatly appreciated!
-Orion

On 9/12/09 2:45 am, Floris Bruynooghe floris.bruynoo...@gmail.com wrote:

 On Fri, Sep 11, 2009 at 01:15:07PM -0700, OB wrote:
 I am trying to get distutils to compile a single C script and install the
 binary to the same script directory as the entry point scripts that are
 generated for the python part of the module. I would like to use all the
 includes, CFLAGS, etc that are used when compiling extension modules, but
 this C script is not an extension. Is there a way to do this through setup,
 or do I need to use distutils.ccompiler.new_compiler() and try to hunt down
 CFLAGS, default libs, etc?
 
 (Ignoring the setuptools part of your question as I don't use that,
 but I'm pretty sure it's very similar if not the same)
 
 If you don't want to create the compiler the easiest is to extend the
 build_ext command:
 
 
 from distutils.command.build_ext import build_ext
 
 class MyBuildExt(build_ext):
 def run(self):
 build_ext.run(self)
 self.compiler.link_executable(['hello.c'], 'hello')
 
 setup(name='foo',
   ...
   cmdclass = {'build_ext': MyBuildExt})
 
 
 Here build_ext.run() will be setting all the include dirs, macros,
 libs, rpaths etc into the compiler, which is what you want I think.
 Obviously play around with the arguments to link_executable(), or you
 could do it in 2 steps and create the object files first with
 self.compiler.compile() if you want/need.
 
 If you don't want to extend build_ext then you've got to create the
 compiler with distutils.ccompiler.new_compiler() and
 distutils.sysconfig.customize_compiler().  Hunting down the settings
 is a bit harder then, you'll be reading build_ext.finalize_options()
 and build_ext.run() to figure this out.
 
 Regards
 Floris


___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig