how do you prevent distutils from downloading and building packages without consent?

lkcl luke.leighton at googlemail.com
Sat Mar 28 16:50:33 EDT 2009


ok - john, gabriel, i've now removed setuptools, which is the area
that's problematic for many people.  however.... there's a feature of
setuptools which _is_ useful:

-        entry_points = {'console_scripts':[
-                       'pyjsbuild=pyjs.build:main',
-                       'pyjscompile=pyjs:main',
-                       ]},

whoops - those are now gone.

i have a command, bootstrap.py, which replicates that exact
functionality: it creates a customised pyjsbuild which can go in /usr/
bin or /usr/local/bin and it will add the library locations to
sys.path and also as a -D option to the pyjs main() function - it's a
little obscure, but works out fine.

e.g. if you specify no arguments, this gets auto-generated, in ./bin/
pyjsbuild :

#!/usr/bin/python

pth = '/home/lkcl/src/sf.pyjamas/svn-pyjamas/pyjamas'

import os
import sys
sys.path[0:0] = [
  pth,
  ]

import pyjs, sys
pyjs.path += [os.path.join(pth, 'library'),
os.path.join(pth, 'library', 'builtins'),
os.path.join(pth, 'addons'),
]
sys.argv.extend(['-D', pth])

import pyjs.build

if __name__ == '__main__':
    pyjs.build.main()

if you specify "python bootstrap.py /usr/share/pyjamas /tmp" you get,
in /tmp/bin/pyjsbuild:


#!/usr/bin/python

pth = '/usr/share/python'

import os
import sys
sys.path[0:0] = [
  pth,
  ]

import pyjs, sys
pyjs.path += [os.path.join(pth, 'library'),
os.path.join(pth, 'library', 'builtins'),
os.path.join(pth, 'addons'),
]
sys.argv.extend(['-D', pth])

import pyjs.build

if __name__ == '__main__':
    pyjs.build.main()


so, would you (or anyone else) happen to know how i can get setup.py
to run bootstrap.py to create these two scripts, in a way that's
compatible with the setuptools "entry_points" thing?  i.e. taking the
option of "--install-data" as the first argument to bootstrap.py and
the option of "--prefix" as the second argument.

i envisage it to be something like:


from bootstrap import create_commands
if distutils.XXXXX.cmd == "build":
    create_commands(distutils.XXXXXX.install_data_path,
                    distutils.XXXXXX.prefix)

but it all looks a bit hair-raising, if you ask me.  i'm not often on
wobbly ground when it comes to python, but this is pretty specific
stuff that has to be got right across multiple platforms.

tia,

l.



More information about the Python-list mailing list