diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 1ad14f6..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include micromlgen/templates/* \ No newline at end of file diff --git a/micromlgen/__pycache__/micromlgen.cpython-36.pyc b/micromlgen/__pycache__/micromlgen.cpython-36.pyc new file mode 100644 index 0000000..8d0617f Binary files /dev/null and b/micromlgen/__pycache__/micromlgen.cpython-36.pyc differ diff --git a/micromlgen/micromlgen.py b/micromlgen/micromlgen.py index fe26439..010f256 100644 --- a/micromlgen/micromlgen.py +++ b/micromlgen/micromlgen.py @@ -1,3 +1,4 @@ +import os import re from math import factorial from jinja2 import FileSystemLoader, Environment @@ -26,8 +27,10 @@ def port(clf, test_set=None, classmap=None, **kwargs): 'enumerate': enumerate, } } - loader = FileSystemLoader('.') - template = Environment(loader=loader).get_template('./templates/svm.jinja') + dir_path = os.path.dirname(os.path.realpath(__file__)) + print(dir_path) + loader = FileSystemLoader(dir_path + '/templates') + template = Environment(loader=loader).get_template('svm.jinja') code = template.render(template_data) code = re.sub(r'\n\s*\n', '\n', code) diff --git a/micromlgen/templates/svm.jinja b/micromlgen/templates/svm.jinja index ddb4107..bd27038 100644 --- a/micromlgen/templates/svm.jinja +++ b/micromlgen/templates/svm.jinja @@ -1,6 +1,6 @@ #pragma once -{% include 'templates/kernel_function.jinja' %} +{% include 'kernel_function.jinja' %} /** * Predict class for features vector @@ -10,16 +10,16 @@ int predict(double *x) { double decisions[{{ DECISIONS_COUNT }}] = { 0 }; int votes[{{ CLASSES_COUNT }}] = { 0 }; - {% include 'templates/compute_kernels.jinja' %} + {% include 'compute_kernels.jinja' %} {% if CLASSES_COUNT == 2 %} - {% include 'templates/binary_classification.jinja' %} + {% include 'binary_classification.jinja' %} {% else %} - {% include 'templates/compute_decisions.jinja' %} - {% include 'templates/compute_votes.jinja' %} - {% include 'templates/compute_class.jinja' %} + {% include 'compute_decisions.jinja' %} + {% include 'compute_votes.jinja' %} + {% include 'compute_class.jinja' %} {% endif %} } -{% include 'templates/self_test.jinja' %} -{% include 'templates/classmap.jinja' %} +{% include 'self_test.jinja' %} +{% include 'classmap.jinja' %} diff --git a/setup.py b/setup.py index f45fbfb..ef7267b 100644 --- a/setup.py +++ b/setup.py @@ -2,17 +2,20 @@ setup( name = 'micromlgen', packages = ['micromlgen'], - version = '0.4', + version = '0.5', license='MIT', description = 'Generate C code for microcontrollers from Python\'s sklearn classifiers', author = 'Simone Salerno', author_email = 'web@agrimag.it', url = 'https://github.com/agrimagsrl/micromlgen', - download_url = 'https://github.com/agrimagsrl/micromlgen/archive/v_04.tar.gz', + download_url = 'https://github.com/agrimagsrl/micromlgen/archive/v_05.tar.gz', keywords = ['ML', 'microcontrollers', 'sklearn', 'machine learning'], install_requires=[ - 'jinja2', - ], + 'jinja2', + ], + package_data= { + 'micromlgen': ['templates/*.jinja'] + }, classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers',