Skip to content

Commit eede660

Browse files
committed
restructure install
1 parent 51541f6 commit eede660

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+227
-247
lines changed

m2cpp.py

Lines changed: 0 additions & 104 deletions
This file was deleted.

matlab2cpp/testsuite/__init__.py

Whitespace-only changes.

setup.py

Lines changed: 19 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,26 @@
1-
#!/usr/bin/env python
2-
# encoding: utf8
3-
4-
5-
import platform
6-
import os
7-
import sys
8-
9-
system = platform.system()
10-
11-
from distutils.core import setup
1+
"""Main installer."""
2+
from setuptools import setup, find_packages
123

134
setup(
14-
name='matlab2cpp',
15-
version='0.5',
16-
packages=['matlab2cpp', 'matlab2cpp/node', 'matlab2cpp/tree',
17-
'matlab2cpp/rules', 'matlab2cpp/testsuite', 'matlab2cpp/supplement',
18-
'matlab2cpp/manual', 'matlab2cpp/configure'],
19-
# package_dir={'': ''},
5+
name="matlab2cpp",
6+
version="2.0",
7+
packages=find_packages("src"),
8+
package_dir={"": "src"},
9+
entry_points={"console_scripts": ["m2cpp = matlab2cpp.__main__:main"]},
2010
url='http://github.com/jonathf/matlab2cpp',
2111
license='BSD',
2212
author="Jonathan Feinberg",
2313
author_email="jonathan@feinberg.no",
24-
description='Matlab to C++ converter'
14+
description="Matlab to C++ transpiler",
15+
tests_require=["pytest", "pytest-runner"],
16+
classifiers=[
17+
'Development Status :: 4 - Beta',
18+
'Environment :: Console',
19+
'Intended Audience :: Developers',
20+
'License :: OSI Approved :: BSD License',
21+
'Operating System :: OS Independent',
22+
'Natural Language :: English',
23+
'Programming Language :: Python',
24+
'Topic :: Software Development :: Compilers',
25+
],
2526
)
26-
27-
"""OPTIONAL the code below will copy the executable m2cpp to a folder which is in path."""
28-
#Windows
29-
if system == "Windows":
30-
system_path = sys.executable
31-
cwdir = os.getcwd()
32-
33-
new_file = open('m2cpp.bat', 'w')
34-
command_run = '@echo off\n' + system_path + ' ' + cwdir + os.sep + 'm2cpp.py' + ' %*'
35-
new_file.write(command_run)
36-
new_file.close()
37-
38-
#copy m2cpp.bat to sys.executable
39-
bat_dst = sys.executable
40-
bat_dst = os.path.dirname(bat_dst)
41-
42-
from shutil import copy
43-
copy("m2cpp.bat", bat_dst)
44-
45-
print()
46-
print("Program now runnable through 'm2cpp'")
47-
print("> m2cpp -h")
48-
49-
else: #Linux/Mac
50-
m2cpp = "cp -v m2cpp.py /usr/local/bin/m2cpp"
51-
os.system(m2cpp)
52-
chmod = "chmod 755 /usr/local/bin/m2cpp"
53-
print(chmod)
54-
os.system(chmod)
55-
56-
print()
57-
print("Program now runnable through 'm2cpp'")
58-
print("> m2cpp -h")
59-
60-

src/matlab2cpp/__init__.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
3+
"""
4+
5+
The toolbox is sorted into the following modules:
6+
7+
+----------------------------------+----------------------------------------+
8+
| Module | Description |
9+
+==================================+========================================+
10+
| :py:mod:`~matlab2cpp.qfunctions` | Functions for performing simple |
11+
| | translations |
12+
+----------------------------------+----------------------------------------+
13+
| :py:class:`~matlab2cpp.Builder` | Constructing a tree from Matlab code |
14+
+----------------------------------+----------------------------------------+
15+
| :py:class:`~matlab2cpp.Node` | Components in the tree representation |
16+
| | of the code |
17+
+----------------------------------+----------------------------------------+
18+
| :py:mod:`~matlab2cpp.collection` | The collcetion of various node |
19+
+----------------------------------+----------------------------------------+
20+
| :py:mod:`~matlab2cpp.configure` | Rutine for setting datatypes and |
21+
| | backends of the various nodes |
22+
+----------------------------------+----------------------------------------+
23+
| :py:mod:`~matlab2cpp.rules` | Translation rules |
24+
+----------------------------------+----------------------------------------+
25+
| :py:mod:`~matlab2cpp.supplement` | Functions for inserting and extraction |
26+
| | datatypes |
27+
+----------------------------------+----------------------------------------+
28+
| :py:mod:`~matlab2cpp.testsuite` | Suite for testing software |
29+
+----------------------------------+----------------------------------------+
30+
31+
32+
The simplest way to use the library is to use the quick translation functions.
33+
They are available through the `mc.qfunctions` module and mirrors the
34+
functionality offered by the `m2cpp` function.
35+
"""
36+
__version__ = "2.0"
37+
38+
try:
39+
import argcomplete
40+
except ImportError:
41+
argcomplete = None
42+
43+
from .parser import create_parser
44+
45+
46+
def m2cpp(args=None):
47+
"""
48+
Execute main parser.
49+
50+
Args:
51+
args (Optional[List[str]]):
52+
Argument to be parsed. If omitted, use ``sys.args``.
53+
"""
54+
parser = create_parser()
55+
if argcomplete is not None:
56+
argcomplete.autocomplete(parser)
57+
58+
args = parser.parse_args(args)
59+
60+
from matlab2cpp.frontend import execute_parser
61+
execute_parser(args)
62+
63+
64+
if __name__ == "__main__":
65+
m2cpp()
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)