Skip to content

Commit 261e697

Browse files
authored
Fix building on readthedocs. Simplify embedded libssh build (#20)
* Fix building on readthedocs. Simplify embedded libssh build.
1 parent 465f876 commit 261e697

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

setup.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@
2020

2121
_PYTHON_MAJOR_VERSION = int(platform.python_version_tuple()[0])
2222
ON_WINDOWS = platform.system() == 'Windows'
23-
SYSTEM_LIBSSH = bool(os.environ.get('SYSTEM_LIBSSH', 0))
23+
ON_RTD = os.environ.get('READTHEDOCS') == 'True'
24+
SYSTEM_LIBSSH = bool(os.environ.get('SYSTEM_LIBSSH', 0)) or \
25+
ON_RTD or ON_WINDOWS
2426

2527
if ON_WINDOWS and _PYTHON_MAJOR_VERSION < 3:
2628
raise ImportError(
2729
"ssh-python requires Python 3 or above on Windows platforms.")
2830

29-
# Only build libssh if running a build
30-
if (len(sys.argv) >= 2 and not (
31+
# Only build libssh if SYSTEM_LIBSSH is not set and running a build
32+
if not SYSTEM_LIBSSH and (len(sys.argv) >= 2 and not (
3133
'--help' in sys.argv[1:] or
3234
sys.argv[1] in (
3335
'--help-commands', 'egg_info', '--version', 'clean',
3436
'sdist', '--long-description')) and
35-
__name__ == '__main__'):
36-
if not (ON_WINDOWS and _PYTHON_MAJOR_VERSION != 2):
37-
build_ssh()
37+
__name__ == '__main__'):
38+
build_ssh()
3839

3940
ext = 'pyx' if USING_CYTHON else 'c'
4041
sources = glob('ssh/*.%s' % (ext,))
@@ -63,7 +64,8 @@
6364

6465
runtime_library_dirs = ["$ORIGIN/."] if not SYSTEM_LIBSSH else None
6566
_lib_dir = os.path.abspath("./src/lib") if not SYSTEM_LIBSSH else "/usr/local/lib"
66-
include_dirs = ["libssh/include"] if ON_WINDOWS or not SYSTEM_LIBSSH else ["/usr/local/include"]
67+
include_dirs = ["libssh/include"] if (ON_WINDOWS or ON_RTD) or \
68+
not SYSTEM_LIBSSH else ["/usr/local/include"]
6769

6870
extensions = [
6971
Extension(

0 commit comments

Comments
 (0)