Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate console_scripts wrappers on wheel install (optional) #1067

Closed
dholth opened this issue Jul 20, 2013 · 20 comments
Closed

generate console_scripts wrappers on wheel install (optional) #1067

dholth opened this issue Jul 20, 2013 · 20 comments
Labels
auto-locked Outdated issues that have been locked by automation C: wheel The wheel format and 'pip wheel' command
Milestone

Comments

@dholth
Copy link
Member

dholth commented Jul 20, 2013

bdist_wheel will stop putting pre-generated setuptools console_scripts into wheels.

When that happens pip will need to generate them (and it would be cool to be able to tell it it doesn't have to) for example, wheel's own command "wheel install-scripts packagename" does it.

@qwcode
Copy link
Contributor

qwcode commented Jul 20, 2013

ok, so pip would need this in 1.5 (a few months away), before you could release this change in bdist_wheel (i.e. wheel)

don't understand this "and it would be cool to be able to tell it it doesn't have to"

@dholth
Copy link
Member Author

dholth commented Jul 20, 2013

I mean if you aren't going to use the console scripts you could avoid writing them out at all.

@qwcode
Copy link
Contributor

qwcode commented Jul 20, 2013

in another issue, you mention, that it's a new option --skip-scripts, but I don't see it in your default branch.
so it's a new option, defaulted to false? not just a change in default behavior, period?

@dholth
Copy link
Member Author

dholth commented Jul 20, 2013

I just pushed --skip-scripts to https://bitbucket.org/dholth/wheel/. I decided it was probably better to keep the admittedly less-than-cross-platform scripts wrappers in wheels until pip can do something about them.

@dholth
Copy link
Member Author

dholth commented Jul 20, 2013

In the meantime I'm loving wheel install-scripts pkgname. Every time I get the error "can't find the old version of pip because you're doing development" I can just run that.

@pfmoore
Copy link
Member

pfmoore commented Aug 20, 2013

I've closed #1152 as a duplicate, but there's a bit more analysis in that issue that's worth reviewing (for anyone reading this issue in isolation).

@pfmoore
Copy link
Member

pfmoore commented Oct 16, 2013

I might try to work on this. As the contents of the SCRIPTS section of wheels is typically only setuptools-generated wrapper scripts, I propose that the default behaviour be to ignore the contents of SCRIPTS and generate new wrappers based on entry-points.txt (probably using the embedded distlib's script generation feature). For the (likely rare) cases where SCRIPTS contains things that are needed, add an --include-legacy-scripts flag that copies anything in SCRIPTS that is not already generated as an entry point.

Does that seem reasonable?

As an extra, it may be possible to extend entry_points.txt to say that a wrapper should be "versioned" - i.e., as well as cmd.exe, we also generate cmdX.exe and cmdX.y.exe (where X.Y is the target Python version). This would only be a short-term measure, though - proper metadata for versioned scripts should be a Metadata 2.0 feature.

@dstufft
Copy link
Member

dstufft commented Oct 16, 2013

We should be able to reliably tell which scripts are entrypoints or not, see if their name matches an entry in entry_points.txt

Your idea about extending made me think though, we can make arbitrary entry points, so why not make just "pip" be the console_entrypoint, and then add a console_version_entrypoint that will do string formatting for like %(py_major)s and %(py_minor)s. For setuptools this would install just a pip binary which isn't the most ideal thing but it would work and we could possibly get this added to setuptools itself. Nick should be consulted as he had an idea along this lines for the new metadata 2.0 so we'd want something that could be easily translated.

@pfmoore
Copy link
Member

pfmoore commented Oct 16, 2013

We should be able to reliably tell which scripts are entrypoints or not, see if their name matches an entry in entry_points.txt

Relatively reliably, yes. For windows, entry point XXX matches XXX.exe and XXX-script.exe. For Unix it matches XXX (I assume - I'd need to check that). So any of the above 3 should be ignored if XXX is a console script entry point (because the wheel could have been generated on Windows or Unix). Are there gui script entry points? I can't remember offhand but if there are, include those too.

Anything else I guess we can just copy across. Although in practice, I suspect there's a good chance they would be relatively unreliable anyway (in my experience, anything else is usually a Unix shell script that won't work on Windows, or maybe a bat file that sort-of works). I don't recall ever seeing a custom script that worked the way I expected it to on Windows... So I tend to prefer omitting them by default as a way of pushing people towards using entry points rather than rolling their own solution. It's just an idea at the moment, so let's wait to see how the code looks before worrying too much.

@dstufft
Copy link
Member

dstufft commented Oct 16, 2013

Yes there is gui entry points I forget what they are called.

It's perfectly reasonable to have a linux only (or Windows only) wheel that contains hand crafted scripts, I don't think we should break that.

@qwcode
Copy link
Contributor

qwcode commented Oct 17, 2013

I vote for not omitting custom scripts by default if possible. That seems like too much of a change. Ditto on trying to determine what's custom based on matching with the entry points.

As for using distlib's script support, recall this thread: https://mail.python.org/pipermail/distutils-sig/2013-July/021872.html

I don't think distlib wrappers enforce the script to have properly fulfilled dependencies, where setuptools wrappers do. That's a difference to be aware of, but not sure if the implications are that important.

@pfmoore
Copy link
Member

pfmoore commented Oct 17, 2013

Happy to skip the "don't emit custom scripts by default" bit. But if we include pregenerated entry points and try to write our own, we'll get in a mess unless wheel building tools are converted to skip entry point scripts (that's pip wheel/bdist_wheel, wheel convert and distlib). That's an option, as there aren't that many wheels "in the wild" yet, but it makes a subtly incompatible wheel, and I thought that was deferred for Wheel 1.1.

Yeah, distlib script support would have to be thought through.

@dstufft I'm not saying it's not possible to have hand crafted scripts, just that in my experience it doesn't happen now and this is a short-term proposal pending Metadata 2.0/sdist 2.0/etc. So "good enough" may be reasonable for now.

@pfmoore
Copy link
Member

pfmoore commented Oct 17, 2013

I don't think distlib wrappers enforce the script to have properly fulfilled dependencies, where setuptools wrappers do. That's a difference to be aware of, but not sure if the implications are that important.

Personally, I consider that a feature not an issue. The dependency checking means that setuptools wrappers are dependent on pkg_resources at runtime, which I view as a significant downside.

@dstufft
Copy link
Member

dstufft commented Oct 17, 2013

I don't think we need to include the pre generated scripts, infact I think we shouldn't. I just know if we skip custom scripts we're going to break things for people. Openstack for instance use a custom script on Linux (but entrypoints on Windows) in order to cut out pkg_resources. Importing pkg_resource was causing enough delay on start up that they felt that was a better option.

I agree on getting rid of the pkg_resources runtime checks being a feature not an issue. It would greatly speed up start up time on those scripts and enable better -e usage. If someone really wants it they could simply implement the check themselves.

@pfmoore
Copy link
Member

pfmoore commented Oct 17, 2013

Note that the fun bit about not including the pregenerated scripts will be wheel convert (a critical use case for me and possibly many Windows users for migrating wininst installers). The wininst does include the wrappers (and that won't change) so all we're doing is moving the "ignore wrappers" logic from wheel installs to wheel convert. Still a good idea, certainly, but it needs doing.

I see another chain of prerequisites starting up. I'll raise a feature request for wheel for now. I can get away for the initial stages by hand-hacking wheels, but ultimately this will need to be part of the wheel spec. (Actually, @dholth didn't this come up before and did you say that omitting script wrappers should be left for Wheel 1.1? If so, we're hitting a bit of a chicken and egg issue here...)

@dstufft
Copy link
Member

dstufft commented Oct 17, 2013

The wheel library currently has an option where you can ask it not to generate the scripts (it was on by default for one version). Theoretically once a version of pip that generates scripts is available it could turn the generating of scripts off by default.

@pfmoore
Copy link
Member

pfmoore commented Oct 17, 2013

OK, cool. That still leaves wheel convert (and less importantly wheel install) needing to change, correct?

@dstufft
Copy link
Member

dstufft commented Oct 17, 2013

Uhh, Yea wheel convert would want to have the same thing as we're doing in pip where it excludes any entry points. For wheel install it would want to generate scripts as well (however it has it's own command to generate them already).

@pfmoore
Copy link
Member

pfmoore commented Oct 24, 2013

See #1251 for work in progress on this

@dstufft
Copy link
Member

dstufft commented Nov 2, 2013

Fixed in #1251

@dstufft dstufft closed this as completed Nov 2, 2013
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: wheel The wheel format and 'pip wheel' command
Projects
None yet
Development

No branches or pull requests

4 participants