Sorry, I meant to send this onlist.  Reposting:

In the end, after some great suggestions and debugging help from Ian Bicking, I managed to monkeypatch the monkeypatch to restore my original script. I was using a hybrid approach (sometimes importing distutils, sometimes setuptools) to avoid the script handling, but with this workaround, I should be able just to switch back to setuptools so that I don't have to think about it.

In my case, I have an install_script stub:

def install_script(self, dist, script_name, script_text, dev_path=None):
    self.write_script(script_name, script_text, 'b')

And I then monkeypatch setuptools if it's loaded:

if sys.platform != 'win32' and 'setuptools' in sys.modules:
    # Someone used easy_install to run this.  I really want the correct
    # script installed.
    import setuptools.command.easy_install
setuptools.command.easy_install.easy_install.install_script = install_script

You'll notice that I leave the patching alone on win32, because I understand the desirability of having an exe file there...

Thanks,
Douglas Mayle

On Apr 16, 2009, at 2:32 PM, P.J. Eby wrote:

At 01:03 PM 4/16/2009 -0400, Douglas Mayle wrote:
Hey everyone,
I'm having an annoying problem and I was directed here to see if you
knew what could be done.

I'm using distutils for my package instead of setuptools because it's
a command line app, and the half second that setup tools adds to each
launch for pkg_resource scanning is unacceptable.  I use the scripts
parameter, and it happily installs the script I expect and things are
running along.  If I try to use easy_install to install the package,
however, (and more importantly, if a user of mine does) it seems that
setuptools is monkeypatching the distutils module and replacing
setup.  This means that instead of just copying my script to bin,
setuptools is creating it's own script that does a pkg_resource scan
and then loads my script from the original location. Is there any way
to ensure that I'm using the distutils.core.setup that I expect, and
not the one that setuptools monkeypatches into place?

Use "easy_install -eb. MyPackage" to download the source (which will be placed in a 'mypackage/' subdirectory, then change to that directory and run "setup.py install" to install using distutils instead of setuptools.


_______________________________________________
Distutils-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to