forked from delsauce/pre-commit-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
54 lines (47 loc) · 1.81 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''
pip package configuration for embedded c coding standard compliance
'''
import codecs
import os
from setuptools import setup
# pylint: disable-next=consider-using-with
reqs: list = open("requirements.txt", "r",encoding='utf-8').read().splitlines()
def read(rel_path):
'''
Supporting function to read the __init__.py file from the package
to get attributes. See get_version() below for more details.
'''
here = os.path.abspath(os.path.dirname(__file__))
# intentionally *not* adding an encoding option to open, See:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
with codecs.open(os.path.join(here, rel_path), 'r') as file_pointer:
return file_pointer.read()
def get_version(rel_path):
'''
Allows the version of the package to be fetched via the one
stored in the __init__.py file. This enables a single location
to store this information (rather than having to pass it in
with the metadata in the call to setup())
See here:
https://packaging.python.org/guides/single-sourcing-package-version/
'''
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
raise RuntimeError("Unable to find version string.")
setup(name='pre_commit_hooks',
description='C/C++ File formatting and cleanup per coding standards',
url='https://github.com/delsauce/pre-commit-hooks',
license='MIT',
packages=['pre_commit_hooks'],
zip_safe=False,
version=get_version("pre_commit_hooks/__init__.py"),
entry_points={
'console_scripts': [
'format-c-source=pre_commit_hooks.format_c_source:main',
],
},
python_requires='>=3.7',
install_requires=reqs
)