[Add] use ccompiler from numpy if there is one

This commit is contained in:
nanoric 2019-04-15 10:11:14 -04:00
parent 48590fdafd
commit 430220959d
2 changed files with 21 additions and 3 deletions

View File

@ -18,7 +18,6 @@ services:
before_script: before_script:
- psql -d postgresql://postgres:${VNPY_TEST_POSTGRESQL_PASSWORD}@localhost -c "create database vnpy;" - psql -d postgresql://postgres:${VNPY_TEST_POSTGRESQL_PASSWORD}@localhost -c "create database vnpy;"
- mysql -u root --password=${VNPY_TEST_MYSQL_PASSWORD} -e 'CREATE DATABASE vnpy;' - mysql -u root --password=${VNPY_TEST_MYSQL_PASSWORD} -e 'CREATE DATABASE vnpy;'
- alias make="make -j2"
script: script:
- pip install psycopg2 mongoengine pymysql # we should support all database in test environment - pip install psycopg2 mongoengine pymysql # we should support all database in test environment
@ -43,6 +42,7 @@ matrix:
packages: packages:
- g++-8 - g++-8
before_install: before_install:
- alias make="make -j2"
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
- sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-8 90 - sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-8 90
- sudo update-alternatives --install /usr/bin/gcc cc /usr/bin/gcc-8 90 - sudo update-alternatives --install /usr/bin/gcc cc /usr/bin/gcc-8 90
@ -51,7 +51,7 @@ matrix:
- python -m pip install --upgrade pip wheel setuptools - python -m pip install --upgrade pip wheel setuptools
# Linux install script # Linux install script
- pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl - pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
- bash ./install.sh - NPY_NUM_BUILD_JOBS=2 bash ./install.sh
- name: "sdist install under Ubuntu: gcc-7" - name: "sdist install under Ubuntu: gcc-7"
addons: addons:
@ -61,6 +61,7 @@ matrix:
packages: packages:
- g++-7 - g++-7
before_install: before_install:
- alias make="make -j2"
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
- sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-7 90 - sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-7 90
- sudo update-alternatives --install /usr/bin/gcc cc /usr/bin/gcc-7 90 - sudo update-alternatives --install /usr/bin/gcc cc /usr/bin/gcc-7 90
@ -78,7 +79,7 @@ matrix:
- pip install numpy - pip install numpy
- pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl - pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
- python setup.py sdist - python setup.py sdist
- pip install dist/`ls dist` - NPY_NUM_BUILD_JOBS=2 pip install dist/`ls dist`
- name: "pip install under osx" - name: "pip install under osx"
os: osx os: osx

View File

@ -22,6 +22,23 @@ import sys
from setuptools import Extension, find_packages, setup from setuptools import Extension, find_packages, setup
def hook_compiler():
"""
if numpy is installed, use compiler from that instead of setuptools,
which run faster in multi-core env
"""
try:
from numpy.distutils.ccompiler import CCompiler_compile
import distutils.ccompiler
distutils.ccompiler.CCompiler.compile = CCompiler_compile
except ImportError:
pass
hook_compiler()
with open("vnpy/__init__.py", "rb") as f: with open("vnpy/__init__.py", "rb") as f:
version_line = re.search( version_line = re.search(
r"__version__\s+=\s+(.*)", f.read().decode("utf-8") r"__version__\s+=\s+(.*)", f.read().decode("utf-8")