Skip to content

Commit

Permalink
changes to accomodate manylinux tag for pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
srohit0 committed Nov 19, 2019
1 parent 45d6579 commit 20db1a6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
9 changes: 4 additions & 5 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@
#

UNAME_M := $(shell uname -m)
ifeq (, $(shell which python3 ))

PYTHON=$(shell which python3)
ifeq (, $(PYTHON) )
$(error "python3 not found in $(PATH)")
endif

PYVER=$(shell python3 -c "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)")

CC=/usr/bin/clang++-8
LD=/usr/bin/ld
PYTHON=/usr/bin/python$(PYVER)
SWIG=/usr/bin/swig

ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
EIGEN_INCLUDES=-isystem $(ROOT_DIR)/packages/eigen-eigen-323c052e1731
DNNC_INCLUDES= -I$(ROOT_DIR)/include
PY_INCLUDES= -I$(wildcard /usr/include/python$(PYVER)*)
PY_INCLUDES= -I$(shell python3 -c "from sysconfig import get_paths as gp; print(gp()['include'])")

LD_FLAGS=-shared
CPP_FLAGS=-O3 -Wall -std=c++17 -fPIC -march=native
Expand Down
43 changes: 39 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# how to run this script: python setup.py bdist_wheel
# hot to test install: python -m pip install ~/dnnc/master/dnnCompiler/dist/dnnc-0.1-py3-none-any.whl --root pip_install_test
# reference: https://dzone.com/articles/executable-package-pip-install
# how to test install: python -m pip install ~/dnnc/master/dnnCompiler/dist/dnnc-0.1-py3-none-any.whl --root pip_install_test

import os, sys, glob
import shutil, errno
import shutil, errno, subprocess, multiprocessing
import setuptools


NAME='deepC'
VERSION=0.12

Expand All @@ -20,6 +20,26 @@ def is_pure(self):
def has_ext_modules(self):
return True;

from setuptools.command.build_ext import build_ext as buildext
class make_build(setuptools.Command):

def initialize_options(self):
self.jobs = multiprocessing.cpu_count()

def finalize_options(self):
self.jobs = int(self.jobs)

def run(self):
cmd = "make CC=g++ SRC -j " + str(self.jobs)
subprocess.call(cmd, shell=True)
cmd = "make CC=g++ all "
subprocess.call(cmd, shell=True)

class build_ext(buildext):
def run(self):
self.run_command('make_build')


#create the links to src dir inside deepC for proper installation.
def link_dir(dir_name):
try:
Expand All @@ -41,13 +61,26 @@ def source_files(directory):
paths.append(os.path.join(path, filename))
return paths

cmdclass = {
'make_build': make_build,
'build_ext': build_ext,
}

ext_modules = [
setuptools.Extension(
name=str(NAME+".dnnc"),
sources=[
str(source_files('include')) +
str(source_files('packages'))
])
]

packages = setuptools.find_packages()

tests_require = []
tests_require.append('unittest')
install_requires = []
install_requires.extend([
'numpy>=1.16.1',
'onnx==1.5.0',
])

Expand All @@ -58,6 +91,8 @@ def source_files(directory):
long_description_content_type="text/markdown",
long_description=long_description,
packages=packages,
ext_modules=ext_modules,
cmdclass=cmdclass,
include_package_data=True,
package_data={'':['_dnnc.so'] +
source_files('include') +
Expand Down

0 comments on commit 20db1a6

Please sign in to comment.