mitsuhiko / pipsi

pip script installer
Other
2k stars 133 forks source link

Pipsi only shares console_scripts and not scripts #93

Closed pjz closed 7 years ago

pjz commented 7 years ago

Scripts packaged using the scripts argument to setup.py aren't shared, and they probably should be.

RonnyPfannschmidt commented 7 years ago

pipsi tries hard to find those, but its easy to fail, if you want proper support, use a reasonable mechanism, the scripts argument isn't and its only supported on a best effort basis

pjz commented 7 years ago

If I need to package up a shell script with a python package, what's a "reasonable mechanism" ?

untitaker commented 7 years ago

For shell scripts I don't think there is one, but I think @RonnyPfannschmidt was talking about console_scripts.

RonnyPfannschmidt commented 7 years ago

@pjz pipsi does not care about shell scripts at all, it has no sane way to run them with the right python to begin with and its not portable to stuff like windows

pipsi is about python stuff - if you want pipsi to ship shell stuff, then do it as an executable that gives you something as output to feed to eval

after all there is a need to fill in direly needed metadata if the shell script is supposed to invoke something of the right python version

@untitaker i was talking about the scripts section, at least last i took a look we checked if a distribution had scripts in the script location

pjz commented 7 years ago

What I want to ship is some convenience wrappers around the much more powerful console_script that pipsi installs. I'm not doing anything super special in my setup.py; I just say scripts = [ 'bin/foo.sh', 'bin/bar.sh' ] and pip installs them correctly into the virtualenv's bin directory. I just would like them to be linked from the .local/bin as well, like the main console_script endpoint is.

RonnyPfannschmidt commented 7 years ago

@pjz interestingly, according to https://github.com/mitsuhiko/pipsi/blob/master/pipsi.py#L110-L134 and the surrounding code, the scripts should be copied by default if they where executable as intended

pjz commented 7 years ago

I don't see that. I see it only looks in the package metadata for console_scripts in https://github.com/mitsuhiko/pipsi/blob/master/pipsi.py#L47-L49 . This method seems prone to failure if the organization of the metadata changes. How about something more robust like:

on L242ish add

venv_files = set(os.listdir(BIN_DIR))

and then line 255 could be someting as simple as:

scripts = set(os.listdir(BIN_DIR)) - venv_files

...but may have to be more complicated to work correctly on windows.

RonnyPfannschmidt commented 7 years ago

@pjz the lines before try RECORD/INSTALLED-files before falling back to console_scripts going for all ofbin-dir is inherently broken due to dependencies potentially having scripts

pjz commented 7 years ago

and RECORD/INSTALLED presumably fail in the -e ./mypackage case. Which is my case, so I may just be out of luck.

And good catch on the dependencies; I hadn't considered that.