-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to prepare for first integration as installable package
- Loading branch information
1 parent
e81e30f
commit 8d77102
Showing
3 changed files
with
74 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
], | ||
}, | ||
) |