Repository: mesonbuild/meson

Issue:
 windows build broken with 0.52.0
We get a: 
```meson.build:182:2: ERROR: Search directory \usr\local\lib\tensorflow_cc is not an absolute path.```
This is from: 
```tf_tensorflow_lib = cc.find_library('libtensorflow_cc', dirs: tensorflow_libdir, required: false)```
and tensorflow_libdir is initialized through an array option with default value `['/usr/local/lib/tensorflow_cc/']`.



Discussion:
Would it be possible for you to bisect the problematic commit?
Bisecting leads to https://github.com/mesonbuild/meson/commit/fd7e8c540063870391e6ce75aa0fb179180fa057
On Windows, a leading-slash `/foo/bar` directory is not absolute. This ambiguity is handled correctly by Python 3 `pathlib`. As a guess, perhaps for legacy reasons `os.path.isabs` allowed this relative path to be treated as absolute.  So this is perhaps moreso a remnant of errant Python 2 behavior that was corrected in Python 3.

The OS-specific search path arrays might be something to put in a Meson 
```meson
if 'linux'
  tf_root = ['/usr/lib/tensorflow', '/lib/tensorflow']
elif 'windows'
  tf_root = ['c:/tensorflow', meson.source_root() / 'tensorflow']
elif ...
...
endif
```

MWE (without the if/elif): https://github.com/scivision/meson-tensorflow/blob/master/meson.build
here I use `meson build -Dtf_root=c:/foo` to tell the directory, but could also add if/elf trivially.
@scivision do you mean that we should work around this in our [meson.build](https://github.com/LeelaChessZero/lc0/blob/master/meson.build) file? Sure we can work around it, but we provide default paths for lots of dependencies in out [meson_options.txt](https://github.com/LeelaChessZero/lc0/blob/master/meson_options.txt) to reduce command line options on unix/macos builds and depend on the paths being unavailable on windows.

This used to work fine so far and I would rather avoid complicating our scripts further for no real gain. 
Moreover, paths starting with `/` may not be absolute under windows, but the objective (as I understand it) is to disallow paths relative to the source code, which is certainly not the case here.
OK perhaps a sensible Meson-internal workaround is to say if the host machine is Windows, just disregard the leading "/" paths as that's a Unix convention. That would keep the benefits of Pathlib without requiring further awkward Meson internal or end-user workarounds.

Thanks for providing that feedback!
@dcbaker would you suggest I do if "host_machine" is_windows since we would be finding the library on the host instead of the target? I want to keep in mind cross builds too.

Resolving patch:
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1557,6 +1557,10 @@ def find_library_method(self, args, kwargs):
         search_dirs = mesonlib.stringlistify(kwargs.get('dirs', []))
         search_dirs = [Path(d).expanduser() for d in search_dirs]
         for d in search_dirs:
+            if mesonlib.is_windows() and d.root.startswith('\\'):
+                # a Unix-path starting with `/` that is not absolute on Windows.
+                # discard without failing for end-user ease of cross-platform directory arrays
+                continue
             if not d.is_absolute():
                 raise InvalidCode('Search directory {} is not an absolute path.'.format(d))
         search_dirs = list(map(str, search_dirs))


Test patch: