|
| 1 | +import os |
| 2 | +import subprocess |
| 3 | +import sys |
| 4 | +import pkg_resources |
| 5 | + |
| 6 | +import subprocess |
| 7 | +import sys |
| 8 | + |
| 9 | +from glob import glob |
| 10 | +from os.path import abspath, basename, dirname, join, normpath, relpath |
| 11 | +from shutil import rmtree |
| 12 | +from textwrap import dedent |
| 13 | + |
| 14 | +from setuptools import setup |
| 15 | +from setuptools import Command |
| 16 | + |
| 17 | +here = normpath(abspath(dirname(__file__))) |
| 18 | + |
| 19 | +class CleanCommand(Command): |
| 20 | + """Custom clean command to tidy up the project root.""" |
| 21 | + CLEAN_FILES = './build ./dist ./*.pyc ./*.tgz ./*.egg-info ./__pycache__'.split(' ') |
| 22 | + |
| 23 | + user_options = [] |
| 24 | + |
| 25 | + def initialize_options(self): |
| 26 | + pass |
| 27 | + def finalize_options(self): |
| 28 | + pass |
| 29 | + def run(self): |
| 30 | + global here |
| 31 | + |
| 32 | + for path_spec in self.CLEAN_FILES: |
| 33 | + # Make paths absolute and relative to this path |
| 34 | + abs_paths = glob(normpath(join(here, path_spec))) |
| 35 | + for path in [str(p) for p in abs_paths]: |
| 36 | + if not path.startswith(here): |
| 37 | + # Die if path in CLEAN_FILES is absolute + outside this directory |
| 38 | + raise ValueError("%s is not a path inside %s" % (path, here)) |
| 39 | + print('removing %s' % relpath(path)) |
| 40 | + try: |
| 41 | + rmtree(path) |
| 42 | + except: |
| 43 | + pass |
| 44 | + |
| 45 | +long_description=dedent(""" |
| 46 | + cpp2python |
| 47 | +
|
| 48 | + Script helps to convert C/C++ sources to C/C++ -like Python sources. |
| 49 | +
|
| 50 | + It does few simple edit operations, like removing semicolons and type declarations. After it you must edit code manually, but you'll spend less time to do it. |
| 51 | +
|
| 52 | + Utility will make mistaces and will not generate ready for use code, so, it won't help you, unless if you know either C/C++ and Python |
| 53 | +
|
| 54 | + For better result, it is recomented to format your code to ANSI style before doing conversion. |
| 55 | +
|
| 56 | + NO ANY BACKUPS ARE CREATED. YOU MAY PERMANENTLY CORRUPT YOR SOURCES |
| 57 | +
|
| 58 | + Usage: |
| 59 | +
|
| 60 | + cpp2python.py DIR|FILE |
| 61 | + cpp2python.py -v|--version|-h|--help |
| 62 | +
|
| 63 | + When directory name is given - tries to find source files by C/C++ suffixes, when file name is given - processes given file |
| 64 | +
|
| 65 | + Author: Andrei Kopats hlamer@tut.by License: GPL |
| 66 | +""") |
| 67 | + |
| 68 | +setup( |
| 69 | + cmdclass={ |
| 70 | + 'clean': CleanCommand, |
| 71 | + }, |
| 72 | + |
| 73 | + name='cpp2python', |
| 74 | + version='0.1.0', |
| 75 | + |
| 76 | + description='Helps to convert C/C++ sources to C/C++ -like Python sources.', |
| 77 | + long_description=long_description, |
| 78 | + url='https://github.com/hlamer/cpp2python', |
| 79 | + author='Andrei Kopats', |
| 80 | + author_email='hlamer@tut.by', |
| 81 | + license='GPL', |
| 82 | + # See https://pypi.python.org/pypi?%3Aaction=list_classifiers |
| 83 | + classifiers=[ |
| 84 | + # How mature is this project? Common values are |
| 85 | + # 3 - Alpha |
| 86 | + # 4 - Beta |
| 87 | + # 5 - Production/Stable |
| 88 | + 'Development Status :: 3 - Alpha', |
| 89 | + |
| 90 | + # Indicate who your project is intended for |
| 91 | + 'Intended Audience :: Developers', |
| 92 | + 'Topic :: Software Development', |
| 93 | + |
| 94 | + # Pick your license as you wish (should match "license" above) |
| 95 | + 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', |
| 96 | + |
| 97 | + 'Programming Language :: Python :: 2.7', |
| 98 | + 'Programming Language :: Python :: 3.4', |
| 99 | + ], |
| 100 | + keywords='cpp python', |
| 101 | + |
| 102 | + entry_points = { |
| 103 | + 'console_scripts': [ |
| 104 | + 'cpp2python = cpp2python:main' |
| 105 | + ] |
| 106 | + }, |
| 107 | +) |
0 commit comments