Issue #31 resolved

Scripts API does not work when vendored

Paul Moore
created an issue

The code that locates the Windows executable launchers for ScriptMaker uses finder as follows:

#!python result = finder('distlib').find(name).bytes

This does not work when distlib is not directly available, but is vendored (as pip does, making distlib available as pip.vendor.distlib).

This is probably fixable by not hardcoding the name 'distlib', but rather obtaining it from __name__. Using __name__[:-8] seems to work, but it's a pretty ugly hack...

Comments (9)

  1. Vinay Sajip

    I think it needs to be e.g.

    # the current package is ...distlib.scripts
    distlib_package = __name__.rsplit('.', 1)[0]     # find distlib package
    result = finder(distlib_package).find(name).bytes
    

    Can you confirm whether that works in the vendored version?

  2. Paul Moore reporter

    Yes, it does. I should have thought of that...

    I know it's a pain, but any chance this could be released relatively soon so I could vendor it into pip?

  3. Vinay Sajip

    I'll see what I can do, but mightn't it be better to see if anything comes out of the woodwork? For now, you can assume that's the approach I'll take when I fix this.

  4. Paul Moore reporter

    I'll see what I can do. It's somewhat difficult as I'm not sure how easily we can temporarily patch the vendored distlib. I'll ask for advice on pypa-dev.

  5. Marcus Smith

    Just a thought here Vinay, but you seem to be using "micro" releases for what seem like "minor" releases to me. i.e. your "0.1.X" series seems like "0.X" releases to me (you'd be up to 0.4 now), and stuff like this issue could be in a quick patch or micro releases (0.4.1). Just a thought.

  6. Vinay Sajip

    It doesn't feel like I'm 40% of the way to a 1.0 :-) As things like PEP 426 are still in a state of flux / not declared stable, I want to be miserly with the minor releases at the moment.

  7. Log in to comment