Skip to content

static link TA-LIB on Linux #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ docs/.tadoc.org.html
*.pyc
build/
dist/
c-ta-lib/
*.so
.*
*~
Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
build:
python3 setup.py build_ext --inplace

build_static:
TA_LINK_STATIC=1 TA_INCLUDE_PATH=c-ta-lib/include TA_LIBRARY_PATH=c-ta-lib/lib python3 setup.py build_ext --inplace

install:
python3 setup.py install

install_static:
TA_LINK_STATIC=1 TA_INCLUDE_PATH=c-ta-lib/include TA_LIBRARY_PATH=c-ta-lib/lib python3 setup.py install

talib/_func.pxi: tools/generate_func.py
python3 tools/generate_func.py > talib/_func.pxi

Expand All @@ -28,3 +34,12 @@ test: build

sdist:
python3 setup.py sdist --formats=gztar,zip

sdist_static:
TA_LINK_STATIC=1 TA_INCLUDE_PATH=c-ta-lib/include TA_LIBRARY_PATH=c-ta-lib/lib python3 setup.py sdist --formats=gztar,zip

talib_static:
tools/build_talib_from_source.bash ${PWD}/c-ta-lib

wheel_static:
TA_LINK_STATIC=1 TA_INCLUDE_PATH=c-ta-lib/include TA_LIBRARY_PATH=c-ta-lib/lib python3 setup.py bdist_wheel
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ $ sudo make install
Note: if your directory path includes spaces, the installation will probably
fail with ``No such file or directory`` errors.

###### Link static ta-lib in Linux

Linux build can link `ta-lib` static, so there is no need to install `ta-lib` global, may be easier to distribute.

1. build `ta-lib` to current dir, `make talib_static`, it download`ta-lib` and build it to `c-ta-lib` of current dir.
2. install static link version of ta-lib-python, `make install_static`

A bool environment variables `TA_LINK_STATIC` is used to tell `setup.py` do static link `ta-lib`, it find `libta_lib.a`
in all `library_dirs`, when found, it set `lib_talib_name` with empty str to disable dynamic link.


### Troubleshooting

If you get a warning that looks like this:
Expand Down
Loading