Skip to content

Commit

Permalink
Setup clean (openucx#7)
Browse files Browse the repository at this point in the history
* Setup clean

* Added Makefile for extensions
* Updated setup.py
    - removed hardcoded paths
    - use setuptools

* fixups

* Update clean

* Use python3

* update location
  • Loading branch information
TomAugspurger authored and Akshay-Venkatesh committed Jan 9, 2019
1 parent e827c4b commit d97cf7e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
*.*~
pybind/build
pybind/call_myucp.c
pybind/call_myucp.*.so
pybind/ucp_py.c
pybind/ucp_py.*.so
pybind/*.a
pybind/*.o

dask-worker-space
__pytestcache__
__pycache__
*.egg-info/
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CC = gcc

pybind/libucp_py_ucp_fxns.a: pybind/ucp_py_ucp_fxns.o pybind/buffer_ops.o
ar rcs $@ $^

pybind/%.o: pybind/%.c
$(CC) -shared -fPIC -c $^ -o $@

install: pybind/libucp_py_ucp_fxns.a
cd pybind && \
python3 setup.py build_ext && \
python3 -m pip install -e .

clean:
rm pybind/*.o pybind/*.a
rm -rf pybind/build pybind/ucx_py.egg-info
rm pybind/ucp_py.c
45 changes: 24 additions & 21 deletions pybind/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,39 @@
import os
import sys

from distutils.core import setup, Command
from distutils.extension import Extension
from setuptools import setup
from setuptools.extension import Extension
from Cython.Build import cythonize

import os
ucx_dir='/home/akvenkatesh/ucx-github/build'
cuda_dir='/cm/extra/apps/CUDA.linux86-64/9.2.88.1_396.26'
if 'UCX_PY_UCX_PATH' in os.environ.keys():
ucx_dir=os.environ['UCX_PY_UCX_PATH']
if 'UCX_PY_CUDA_PATH' in os.environ.keys():
cuda_dir=os.environ['UCX_PY_CUDA_PATH']

try:
print("building libucp_py_ucp_fxns.a")
print("getcwd: " + str(os.getcwd()))
UCX_DIR = os.environ.get("UCX_PY_UCX_PATH", "/usr/local/")
CUDA_DIR = os.environ.get("UCX_PY_CUDA_PATH", "/usr/local/cuda")


msg = "The path '{}' does not exist. Set the {} environment variable."

if not os.path.exists(UCX_DIR):
print(msg.format(UCX_DIR, "UCX_PY_UCX_PATH"), file=sys.stderr)
sys.exit(1)


if not os.path.exists(CUDA_DIR):
print(msg.format(CUDA_DIR, "UCX_PY_CUDA_PATH"), file=sys.stderr)
sys.exit(1)


if not os.path.exists("libucp_py_ucp_fxns.a"):
assert os.system("gcc -shared -fPIC -c ucp_py_ucp_fxns.c -o ucp_py_ucp_fxns.o") == 0
assert os.system("gcc -shared -fPIC -c buffer_ops.c -o buffer_ops.o") == 0
assert os.system("ar rcs libucp_py_ucp_fxns.a ucp_py_ucp_fxns.o buffer_ops.o") == 0
except:
if not os.path.exists("libucp_py_ucp_fxns.a"):
print("Error building external library, please create libucp_py_ucp_fxns.a manually.")
sys.exit(1)


ext_modules = cythonize([
Extension("ucp_py",
sources=["ucp_py.pyx"],
include_dirs=[os.getcwd(), ucx_dir+'/include', cuda_dir+'/include'],
library_dirs=[os.getcwd(), ucx_dir+'/lib', cuda_dir+'/lib64'],
runtime_library_dirs=[os.getcwd(), ucx_dir+'/lib', cuda_dir+'/lib64'],
libraries=['ucp_py_ucp_fxns', 'ucp', 'uct', 'ucm', 'ucs', 'cuda', 'cudart'])
include_dirs=[os.getcwd(), UCX_DIR + '/include', CUDA_DIR + '/include'],
library_dirs=[os.getcwd(), UCX_DIR + '/lib', CUDA_DIR + '/lib64'],
runtime_library_dirs=[os.getcwd(), UCX_DIR + '/lib', CUDA_DIR + '/lib64'],
libraries=['ucp_py_ucp_fxns', 'ucp', 'uct', 'ucm', 'ucs', 'cuda', 'cudart']),
])

setup(
Expand Down

0 comments on commit d97cf7e

Please sign in to comment.