Repository: borgbackup/borg

Issue:
openbsd, netbsd, solaris, illumos, cygwin: platform.posix module not built, but required
due to a linux/freebsd/darwin only platform check, the posix module is not built on netbsd.


Discussion:
```
(borg-env) -bash-4.4$ pip install -e .
Obtaining file:///vagrant/borg/borg
Collecting msgpack-python>=0.4.6 (from borgbackup==1.0.10.dev49+ng82fd84e)
Installing collected packages: msgpack-python, borgbackup
  Running setup.py develop for borgbackup
Successfully installed borgbackup msgpack-python-0.4.8
(borg-env) -bash-4.4$ py.test
Traceback (most recent call last):
  File "/vagrant/borg/borg-env/lib/python3.4/site-packages/_pytest/config.py", line 325, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/vagrant/borg/borg')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/vagrant/borg/borg-env/lib/python3.4/site-packages/_pytest/config.py", line 362, in _importconftest
    mod = conftestpath.pyimport()
  File "/vagrant/borg/borg-env/lib/python3.4/site-packages/py/_path/local.py", line 662, in pyimport
    __import__(modname)
  File "/vagrant/borg/borg-env/lib/python3.4/site-packages/_pytest/assertion/rewrite.py", line 216, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/vagrant/borg/borg/conftest.py", line 14, in <module>
    from borg.testsuite import has_lchflags, has_llfuse
  File "/vagrant/borg/borg/src/borg/testsuite/__init__.py", line 15, in <module>
    from ..platform import get_flags, umount
  File "/vagrant/borg/borg/src/borg/platform/__init__.py", line 13, in <module>
    from .posix import process_alive, get_process_id, local_pid_alive
ImportError: No module named 'borg.platform.posix'
ERROR: could not load /vagrant/borg/borg/conftest.py
```
```
-    if sys.platform.startswith(('linux', 'freebsd', 'darwin')):
+    if sys.platform.startswith(('linux', 'freebsd', 'darwin', 'netbsd')):
         ext_modules.append(Extension('borg.platform.posix', [platform_posix_source]))
```
Solaris seems to have the same problem: https://golem.enkore.de/job/borg-solaris/278/console

Maybe invert the condition, `if not sys.platform.startswith(('win32', 'cygwin'))` (also gnu0?). Otherwise: Solaris = sunos5.
Since we're importing it unconditionally the if should just go away, or we need to add an if in platform/init:

from .posix import process_alive, get_process_id, local_pid_alive
@enkore "Maybe invert the condition, if not sys.platform.startswith(('win32', 'cygwin')) (also gnu0?)."

Shouldn't cygwin behave posixish?

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -373,7 +373,7 @@ def run(self):
     Extension('borg.item', [item_source]),
     Extension('borg.crc32', [crc32_source]),
 ]
-    if sys.platform.startswith(('linux', 'freebsd', 'darwin')):
+    if not sys.platform.startswith(('win32', )):
         ext_modules.append(Extension('borg.platform.posix', [platform_posix_source]))
 
     if sys.platform == 'linux':
diff --git a/src/borg/platform/__init__.py b/src/borg/platform/__init__.py
--- a/src/borg/platform/__init__.py
+++ b/src/borg/platform/__init__.py
@@ -10,10 +10,13 @@
 from .base import set_flags, get_flags
 from .base import SaveFile, SyncFile, sync_dir, fdatasync
 from .base import swidth, umount, API_VERSION
-from .posix import process_alive, get_process_id, local_pid_alive
-
+from .base import process_alive, get_process_id, local_pid_alive
 
 OS_API_VERSION = API_VERSION
+
+if not sys.platform.startswith(('win32', )):
+    from .posix import process_alive, get_process_id, local_pid_alive
+
 if sys.platform.startswith('linux'):  # pragma: linux only
     from .linux import API_VERSION as OS_API_VERSION
     from .linux import acl_get, acl_set
diff --git a/src/borg/platform/base.py b/src/borg/platform/base.py
--- a/src/borg/platform/base.py
+++ b/src/borg/platform/base.py
@@ -162,3 +162,23 @@ def swidth(s):
 def umount(mountpoint):
     """un-mount the FUSE filesystem mounted at <mountpoint>"""
     return 0  # dummy, see also posix module
+
+
+def get_process_id():
+    """
+    Return identification tuple (hostname, pid, thread_id) for 'us'. If this is a FUSE process, then the PID will be
+    that of the parent, not the forked FUSE child.
+    """
+    raise NotImplementedError
+
+
+def process_alive(host, pid, thread):
+    """
+    Check if the (host, pid, thread_id) combination corresponds to a potentially alive process.
+    """
+    raise NotImplementedError
+
+
+def local_pid_alive(pid):
+    """Return whether *pid* is alive."""
+    raise NotImplementedError


Test patch: