Skip to content

Commit

Permalink
Remove distutils
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Jan 15, 2024
1 parent c251a5b commit 28bea1b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions rhodium/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import matplotlib.image as mpimg
import sklearn
from sklearn import tree
from distutils.version import StrictVersion
from packaging.version import Version
from prim import Prim
from io import BytesIO, StringIO

Expand Down Expand Up @@ -170,7 +170,7 @@ def _create_graph(self, **kwargs):
dot_data = StringIO()
feature_names, class_names = self._get_names(**kwargs)

if StrictVersion(sklearn.__version__) >= StrictVersion('0.17'):
if Version(sklearn.__version__) >= Version('0.17'):
tree.export_graphviz(clf,
out_file=dot_data,
feature_names=feature_names,
Expand Down
23 changes: 15 additions & 8 deletions rhodium/test/ffi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Rhodium. If not, see <http://www.gnu.org/licenses/>.
import os
improt platform
import subprocess
import unittest
from ..model import *
from ..optimization import *
Expand All @@ -26,20 +28,25 @@ class TestNativeModel(unittest.TestCase):

@classmethod
def setUpClass(cls):
from distutils.ccompiler import new_compiler, show_compilers

# determine the relative path to the source file
dir = os.path.dirname(__file__)
cwd = os.getcwd()
common_prefix = os.path.commonprefix([dir, cwd])
rel_dir = os.path.relpath(dir, cwd)
src = os.path.join(rel_dir, "test.c")

compiler = new_compiler("gcc")
(obj,) = compiler.compile([src]) #, extra_preargs=["-m64"])
compiler.link_shared_lib([obj], "test")

libname = compiler.library_filename("test", lib_type="shared")

if platform.system() == "Linux":
libname = "libtest.so"
elif platform.system() == "Darwin":
libname = "libtest.dylib"
elif platform.system() == "Windows":
libname = "test.dll"

result = subprocess.run(["gcc", "-shared", "-o", lib_name, "-c", src], capture_output=True)
print(result.stdout)
print(result.stderr)
result.check_returncode()

cls.sopath = os.path.join(os.getcwd(), libname)

def testNormalReturn(self):
Expand Down
Binary file removed rhodium/test/test.dll
Binary file not shown.
Binary file removed rhodium/test/test.o
Binary file not shown.

0 comments on commit 28bea1b

Please sign in to comment.