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
Console scripts #4
Conversation
- `gnureadline` replaced by `readline`. `gnureadline` is deprecated, and one should really only depend on `readline`. The code is not changed so that if `gnureadline` is installed that will be picked up. What's more, `gnureadline` is _explicitly_ wrong on Linux and will not work on Windoze. - The Python interface to XRootD identifies it self as `xrootd` in the `egg` setup (not `pyxrootd`). Fixed for `xrootd`.
Most (well, all but `alien_pfn`) shell scripts in bin are replaced by `setuptool` console scripts (i.e., scripts automatically generated on install). The scripts call functions in the `alien.py` module - e.g., - `alien_cp` calls the function `xjalienfs.alien.do_cp` roughly coded as def do_cp(): sys.argv = sys.argv[:1] + ['cp'] + sys.argv[1:] main() This allows setup-tools to set-up proper load paths, interpreters, and so on. It also allows pip to correctly remove files on uninstall, and so on.
Hi @cholmcc, I'm not sure I understand the purpose of this PR. Our target installation is CVMFS where dependencies are handled by the module files so I don't see the benefit of having to run a script to generate one line scripts, as there is nothing else for them to do anyway. Cheers, .costin |
The purpose of the PR is to make the Python package follow the general guidelines offered for best practises of Python packages. This means that it is strongly encourage to use
Concretely, for installations via
to just
Note, I use Python to find the installation directory to set Also note, when you run
to see what is going on. Thus, adopting this PR would vastly simplify the installation of the package. As I wrote in another PRs comments the idea is that the scripts are written at installation. To see what goes on, you can install the package with the PR package as
This will generate the scripts
For development, one can do
This will create an "installation" that points to the current development directory, and changes will be immediately be reflected in the "installation". Note, if one currently does
or
(as expected by users) then one will end up with an incomplete installation. This is entirely unexpected by most users. Finally, note that CVMFS is not the only "customer" of the package. Certainly others will also want to install the package - and some will also by-pass
then they will end up with a broken package. The PR fixes all these issues with no cost (development can be done as before) while making the code much more maintainable. Please reconsider this PR. If you want, I can make a new PR on top of current Christian |
Hi @cholmcc, @adriansev, I can't say that moving one liners in Python is appealing to me. If anything I suggest something else, and I think Adrian has already something in this direction: make As far as I understand the only missing point is how to add project's Is this approach addressing the use cases you are considering? Cheers, .costin |
Hi Costin,
No, the described approach does not address all the issues outlined. It
still requires external actions to be taken by the user - thus, many users
will end up with a broken install. The symlink approach (as used by
*BusyBox*) is not cross-platform, and
you still have the problem that you are essentially installing a module in
bin (or load paths have to be set - either in the environment or
hardcoded). setuptools entry-points are - in a sense - the Pythonic way
of making symlinks as *BusyBox* does, but it is
- more flexible
- platform independent
The only sure-fire way of installing scripts to accompany a Python package
or module is via setuptools entry-points.
I'm not sure what you mean by
I can't say that moving one liners in Python is appealing to me.
What "one-liners" are you referring to?
I really do not see why you don't apply the PR and get it over with. It is
by far the best technical solution that requires the least maintenance and
it improves the quality and usability of the package. I suggest that you
try out the PR and see for yourself what it does. Also, take the
alien_whereis command for example (or example/alien_envolope) . Instead of
writing most in Python and then some in (Ba)sh, with entry-points we can
write *all of it* in Python. That makes maintenance much easier.
Yours,
Christian
…On Fri, Feb 14, 2020 at 9:29 PM Costin Grigoras ***@***.***> wrote:
Hi @cholmcc <https://github.com/cholmcc>, @adriansev
<https://github.com/adriansev>,
I can't say that moving one liners in Python is appealing to me. If
anything I suggest something else, and I think Adrian has already something
in this direction: make alien_* symlinks to alien.py and have the entry
point look up the command from the name of $0. That to me looks like the
best of both worlds: no bunch of scripts, no need for setting up anything.
As far as I understand the only missing point is how to add project's bin/
to $PATH so standalone installations can work out of the box. Here I let
you two find the best solution.
Is this approach addressing the use cases you are considering?
Cheers,
.costin
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4?email_source=notifications&email_token=ABW6O4HS54L7CNFAOFHD2W3RC35MJA5CNFSM4KS5I7B2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL2K4RQ#issuecomment-586460742>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABW6O4HGJXPV757OUVV47Q3RC35MJANCNFSM4KS5I7BQ>
.
--
Christian Holm Christensen -------------------------------------------------
Sankt Hans Gade 23, 4, DK-2200 Copenhagen
http://cern.ch/cholm, +4524618591
|
Thanks a lot @cholmcc for the thorough explanation. I find the platform independence of this solution a very strong point. @adriansev, could you please reconsider the PR? Cheers, .costin |
@cholmcc could you please resubmit the console-scripts part only, rebased on current master? |
@cholmcc i realized that the same mechanics that recognize the format of sys.argv[0] i can use for all (almost all) entry points, so i setup the script names with the same entry point. can you please take a loot at master so see if there are any other problems? |
In this PR we create the using facing scripts (such as
alien_cp
) through thesetuptools
console-script mechanism. That is, the shell script present inbin/
of the repository are removed in favour of defining the entry-points insetup.py
.So what happens: When installing the package (via
pip
, directly viasetup.py
- f.ex. in develop mode),setuptools
writes small wrappers to the target installationbin
directory (e.g.,/usr/local/bin
,~/.local/bin
) which imports the appropriate module or package and executes the named function from that module.As an example
will generate the console-script
alien_cp
which essentially doesTo this end, we add a few (small) functions to
alien.py
- essentially doing, for exampleThe benefits of using
setuptools
entry points like this is that it can correctly take care of platform idiosyncrasies, set-up proper load paths, and so on.Remember, one can always install a package in developer mode (i.e., no scripts are actually copied to destination - instead a "pointer" is created at the destination that points back to the working directory. In this way, any changes made to the source is immediately reflected in the the "installation") by
The only script not rewritten like this is
alice_pfn
which remains a shell script that calls the entry pointalien_which
.