Skip to content

Commit

Permalink
undo setup.py simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
wenbingl committed Sep 28, 2021
1 parent 760daa5 commit 11c2d6b
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
###########################################################################

from setuptools import setup, find_packages
from setuptools.dist import Distribution
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools.command.develop import develop as _develop
from setuptools.command.build_py import build_py as _build_py

import os
import sys
Expand Down Expand Up @@ -81,7 +84,7 @@ def build_cmake(self, extension):
'-DOCOS_EXTENTION_NAME=' + pathlib.Path(self.get_ext_filename(extension.name)).name,
'-DCMAKE_BUILD_TYPE=' + config
]
# Uses to overwrite
# overwrite the Python module info if the auto-detection doesn't work.
# export Python3_INCLUDE_DIRS=/opt/python/cp38-cp38
# export Python3_LIBRARIES=/opt/python/cp38-cp38
for env in ['Python3_INCLUDE_DIRS', 'Python3_LIBRARIES']:
Expand All @@ -105,6 +108,23 @@ def build_cmake(self, extension):
self.get_ext_filename(extension.name))


class BuildPy(_build_py):
def run(self):
self.run_command("build_ext")
return super().run()


class BuildDevelop(_develop):
def run(self):
self.run_command("build_ext")
return super().run()


class BinaryDistribution(Distribution):
def has_ext_modules(self):
return True


def read_requirements():
with open(os.path.join(TOP_DIR, "requirements.txt"), "r") as f:
requirements = [_ for _ in [dedent(_) for _ in f.readlines()] if _ is not None]
Expand All @@ -130,7 +150,6 @@ def read_version():
if sys.platform == "win32":
load_msvcvar()


ext_modules = [
setuptools.extension.Extension(
name=str('onnxruntime_extensions._ortcustomops'),
Expand Down Expand Up @@ -167,9 +186,11 @@ def read_version():
ext_modules=ext_modules,
cmdclass=dict(
build_ext=BuildCMakeExt,
build_py=BuildPy,
develop=BuildDevelop
),
include_package_data=True,
has_ext_modules=lambda: True,
distclass=BinaryDistribution,
install_requires=read_requirements(),
classifiers=[
'Development Status :: 4 - Beta',
Expand Down

0 comments on commit 11c2d6b

Please sign in to comment.