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

Finding Larch server #46

Open
bruceravel opened this issue Nov 30, 2016 · 2 comments
Open

Finding Larch server #46

bruceravel opened this issue Nov 30, 2016 · 2 comments

Comments

@bruceravel
Copy link
Owner

bruceravel commented Nov 30, 2016

@newville : In the recent PR, the find_larch function is pretty much guaranteed to fail on a linux machine. The function presumes that "python" and "larch_server" are in the same location in the path, which I am guessing is the case with anaconda.

I want to add a check for those two executables prior to your loop through @dirlist using the File::Which module, which is already a Demeter dependency.

use File::Which qw(which);

later...

  my $pyexe_ = which($python_exe);
  my $larch_ = which("larch_server");
  if ((-e $pyexe_) && (-e $larch_))  {
    $larch_exe = "$pyexe_ $larch_";
    return $larch_exe;
  }
  foreach my $d (@dirlist) {
    my $pyexe_ =  File::Spec->catfile($d, $python_exe);
    my $larch_ =  File::Spec->catfile($d, $pyscript_dir, 'larch_server');
    if ((-e $pyexe_) && (-e $larch_))  {
      $larch_exe = "$pyexe_ $larch_";
      last;
    }
  }
  return $larch_exe;

In the case where python and larch_server are locatable in the path using whatever mechanism File::Which uses, then we are good to go. If not, then, we can dig through your hand crafted list of potential paths.

It works for me and I doubt that it will break for you.

@newville
Copy link
Contributor

newville commented Dec 1, 2016

@bruceravel

@newville : In the recent PR, the find_larch function is pretty much guaranteed to fail on a linux machine. The function presumes that "python" and "larch_server" are in the same location in the path, which I am guessing is the case with anaconda.

And on Mac OSX and on Fedora/CentOS too. System python on Fedora/CentOS is /usr/bin/python and installing with that does install to /usr/bin/larch_server. It is different on Debian/Ubuntu?

I think that is "normal python behavior" (even for Apple or Macports Python which uses the wacky version Frameworks thing, the executables get installed next to python). Windows is a special case, with the main executable is {C:/Python27}/python.exe and runnable scripts going to {C:/Python27}/Scripts/larch_server.

I want to add a check for those two executables prior to your loop through @dirlist using the File::Which module, which is already a Demeter dependency.

OK. @dirlist does include the PATH variable -- does File::Which do anything more than that? Except that the test you have might be happy to find python and larch_server in separate places. But that could indicate a problem / version conflict.

For Linux (and Mac for that matter), it's probably fine to simply drop $pyexe altogether, as larch_server should be chmod +x and will invoke python via #!/usr/bin/env python.

@bruceravel
Copy link
Owner Author

@newville : On my ubuntu/debian machines, the python executable in in /usr/bin, as expected [*] for something installed by the package manager. larch_server is in /usr/local/bin, as expected for something not installed by the package manager. My problem isn't with using the hand-curated directory list -- it is with the requirement that the two be co-located in $PATH. File::Which offers a quick and easy API to resolve the problem in a way that works on lots of platforms, but does not do anything more than a search through $PATH on a unix-y system.

Co-location does not preclude the possibility of a version conflict. Requiring co-location simply failed on my Ubuntu machines.

If you are comfortable not using $pyexe_, I have no problem with that.

[*] well ... expected in the sense of doing what the Linux Foundation Filesystem Hierarchy Standard suggests, which is not uniformly adopted and probably not observed by non-Linux systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants