Skip to content

Commit

Permalink
Improvements to prepare for first integration as installable package
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejPatro committed May 24, 2020
1 parent e81e30f commit 8d77102
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 40 deletions.
34 changes: 1 addition & 33 deletions cmake_tidy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,7 @@
###############################################################################


import sys

from cmake_tidy.commands.format.format_command import FormatCommand
from cmake_tidy.utils import ExitCodes
from cmake_tidy.utils.command_line_handling.command_line_parser import CommandLineParser
from cmake_tidy.version import show_version


def main(args=sys.argv[1:]):
parser = __init_parser()
arguments = parser.parse(args)
sys.exit(__execute(arguments, parser))


def __init_parser() -> CommandLineParser:
parser = CommandLineParser()
parser.add_command(FormatCommand)
return parser


def __execute(arguments, parser) -> int:
if arguments.sub_command:
return arguments.func(arguments)
__handle_basic_functionality(arguments, parser)
return ExitCodes.SUCCESS


def __handle_basic_functionality(arguments, parser) -> None:
if arguments.version:
show_version()
else:
parser.print_help()

from cmake_tidy.run import main

if __name__ == "__main__":
main()
42 changes: 42 additions & 0 deletions cmake_tidy/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
###############################################################################
# Copyright Maciej Patro (maciej.patro@gmail.com)
# MIT License
###############################################################################


import sys

from cmake_tidy.commands.format.format_command import FormatCommand
from cmake_tidy.utils import ExitCodes
from cmake_tidy.utils.command_line_handling.command_line_parser import CommandLineParser
from cmake_tidy.version import show_version


def run():
main()


def main(args=sys.argv[1:]):
parser = __init_parser()
arguments = parser.parse(args)
sys.exit(__execute(arguments, parser))


def __init_parser() -> CommandLineParser:
parser = CommandLineParser()
parser.add_command(FormatCommand)
return parser


def __execute(arguments, parser) -> int:
if arguments.sub_command:
return arguments.func(arguments)
__handle_basic_functionality(arguments, parser)
return ExitCodes.SUCCESS


def __handle_basic_functionality(arguments, parser) -> None:
if arguments.version:
show_version()
else:
parser.print_help()
38 changes: 31 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,48 @@
import os
import re

from pip.req import parse_requirements
from setuptools import setup, find_packages

from cmake_tidy.version import VERSION

install_requirements = parse_requirements('./requirements.txt', session=False)
install_requirements = [str(ir.req) for ir in install_requirements]


def load_version():
filename = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cmake_tidy", "version.py"))
with open(filename, "rt") as version_file:
return re.search(r"VERSION = '([0-9a-z.-]+)'", version_file.read()).group(1)


setup(
name='cmake-tidy',
version=VERSION,
version=load_version(),
python_requires='>=3.6.0',
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
url='https://github.com/MaciejPatro/cmake-tidy',
license=open('LICENSE').read(),
license='LICENSE',
author='Maciej Patro',
author_email='maciejpatro@gmail.com',
description='cmake-tidy is a tool to format/ analyze cmake source files.',
long_description=open('README.adoc').read(),
long_description_content_type='text/markdown',
install_requires=install_requirements,
description='cmake-tidy is a tool to format/analyze cmake source files.',
long_description='For More information visit https://github.com/MaciejPatro/cmake-tidy',
long_description_content_type='text/plain',
package_data={
'': ['*.json', '*.adoc', '*.txt']
},
classifiers=[
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8'
],
keywords=['cmake', 'format', 'static-analysis', 'developer', 'tool'],
entry_points={
'console_scripts': [
'cmake-tidy=cmake_tidy.run:run',
],
},
)

0 comments on commit 8d77102

Please sign in to comment.