Skip to content

Instantly share code, notes, and snippets.

@thorrr
Created January 23, 2014 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thorrr/8588128 to your computer and use it in GitHub Desktop.
Save thorrr/8588128 to your computer and use it in GitHub Desktop.
Bloomberg OpenAPI: build python bindings
bloomberg_c_url := http://cdn.gotraffic.net/open/blpapi_cpp_3.7.5.1-windows.zip
bloomberg_python_url := http://cdn.gotraffic.net/open/blpapi-py-3.5.3.zip
artifacts_dir := artifacts
install_dir := Blpapi
UNZIP = unzip $| -d $$d
#UNZIP = tar -xf $| -C $$d
.PHONY: all clean downloads clean_downloads install repl
all: install
bloomberg_c_archive := $(artifacts_dir)/blpapi-cpp.zip
$(bloomberg_c_archive):
wget -O $@ $(bloomberg_c_url)
bloomberg_python_archive := $(artifacts_dir)/blpapi-py.zip
$(bloomberg_python_archive):
wget -O $@ $(bloomberg_python_url)
download_files := $(bloomberg_c_archive) $(bloomberg_python_archive)
downloads: $(download_files)
clean_downloads:
rm $(download_files)
$(download_files): | $(artifacts_dir)
$(artifacts_dir):
mkdir -p $@
#have to patch one of the headers from char* to const char*
blpapi_cpp: | $(bloomberg_c_archive)
d=/tmp/blpapi_cpp_tmp &&\
rm -rf $$d &&\
mkdir -p $$d &&\
$(UNZIP) &&\
mv $$d/* ./$@ &&\
cd ./$@ && ln -s lib Linux &&\
echo -e "350c\n const char *groupdIdBuffer,\n." | patch -e include/blpapi_providersession.h
blpapi_python: | $(bloomberg_python_archive)
d=/tmp/blpapi_python_tmp &&\
rm -rf $$d &&\
mkdir -p $$d &&\
$(UNZIP) &&\
mv $$d/* ./$@
install: $(install_dir)
$(install_dir): | blpapi_cpp blpapi_python
cd ./blpapi_python &&\
TFILE="/tmp/sedfile$$$$.tmp" &&\
sed ./setup.py -e "s/ platform == 'linux2':/ platform == 'linux2' or platform == 'cygwin':/" > "$$TFILE" &&\
cp setup.py setup.py.org && mv "$$TFILE" setup.py &&\
BLPAPI_ROOT="$(shell pwd)/blpapi_cpp/" \
python setup.py install --prefix "$(shell pwd)/$(install_dir)"
repl: $(install_dir)
PYTHONPATH="$(shell pwd)/$(install_dir)/lib/python2.7/site-packages:$$PYTHONPATH" \
python -i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment