Skip to content

Commit 33e5089

Browse files
author
Pan
committed
Modified libssh build script. Added building libssh to setup.py, updated setup.py
1 parent 5f26be4 commit 33e5089

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

ci/install_ssh.sh renamed to ci/build_ssh.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ fi
77
mkdir -p src && cd src
88
cmake -DCMAKE_BUILD_TYPE=Release ../libssh
99
make -j6
10-
sudo make install
1110
cd ..

setup.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import os
55
import sys
66
from glob import glob
7-
from multiprocessing import cpu_count
7+
# from multiprocessing import cpu_count
8+
from subprocess import check_call
89

910
import versioneer
1011
from setuptools import setup, find_packages
@@ -20,6 +21,21 @@
2021
else:
2122
USING_CYTHON = True
2223

24+
25+
def build_ssh():
26+
cmd = './ci/build_ssh.sh'
27+
return check_call(cmd, env=os.environ, shell=True)
28+
29+
30+
# Only build libssh if running a build
31+
if (len(sys.argv) >= 2 and not (
32+
'--help' in sys.argv[1:] or
33+
sys.argv[1] in (
34+
'--help-commands', 'egg_info', '--version', 'clean',
35+
'--long-description')) and
36+
__name__ == '__main__'):
37+
build_ssh()
38+
2339
ON_WINDOWS = platform.system() == 'Windows'
2440

2541
ext = 'pyx' if USING_CYTHON else 'c'
@@ -32,10 +48,11 @@
3248

3349
# _comp_args = ["-ggdb"]
3450
_comp_args = ["-O3"] if not ON_WINDOWS else None
35-
cython_directives = {'embedsignature': True,
36-
'boundscheck': False,
37-
'optimize.use_switch': True,
38-
'wraparound': False,
51+
cython_directives = {
52+
'embedsignature': True,
53+
'boundscheck': False,
54+
'optimize.use_switch': True,
55+
'wraparound': False,
3956
}
4057
cython_args = {
4158
'cython_directives': cython_directives,
@@ -47,13 +64,18 @@
4764
if USING_CYTHON:
4865
sys.stdout.write("Cython arguments: %s%s" % (cython_args, os.linesep))
4966

67+
68+
_lib_dir = os.path.abspath("./src/src")
5069
extensions = [
51-
Extension(sources[i].split('.')[0].replace(os.path.sep, '.'),
52-
sources=[sources[i]],
53-
include_dirs=["libssh/include"],
54-
libraries=_libs,
55-
extra_compile_args=_comp_args,
56-
**cython_args
70+
Extension(
71+
sources[i].split('.')[0].replace(os.path.sep, '.'),
72+
sources=[sources[i]],
73+
include_dirs=["libssh/include"],
74+
libraries=_libs,
75+
library_dirs=[_lib_dir],
76+
runtime_library_dirs=[_lib_dir],
77+
extra_compile_args=_comp_args,
78+
**cython_args
5779
)
5880
for i in range(len(sources))]
5981

0 commit comments

Comments
 (0)