Skip to content

Commit 058a212

Browse files
committed
Use setuptools entry points instead of a custom script
Should fix #190 and related issues (e.g. the script will not work correctly ansible-cmdb if it's been installed into a non-activated virtualenv).
1 parent 43efad1 commit 058a212

File tree

3 files changed

+11
-76
lines changed

3 files changed

+11
-76
lines changed

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,19 @@ def get_data_files(path, strip='', prefix=''):
4242
package_dir={'': 'src'},
4343
packages=find_packages('src'),
4444
include_package_data=True,
45-
data_files=\
45+
data_files=
4646
get_data_files(
4747
'src/ansiblecmdb/data',
4848
strip='src',
4949
prefix='lib'
50-
) +
51-
[['lib/ansiblecmdb/', ['src/ansible-cmdb.py']]],
50+
),
5251
zip_safe=False,
5352
install_requires=['mako', 'pyyaml', 'ushlex', 'jsonxs'],
54-
scripts=[
55-
'src/ansible-cmdb',
56-
],
53+
entry_points={
54+
'console_scripts': [
55+
'ansible-cmdb = ansiblecmdb.cli:main',
56+
],
57+
},
5758

5859
classifiers=[
5960
'Development Status :: 5 - Production/Stable',

src/ansible-cmdb

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

src/ansible-cmdb.py renamed to src/ansiblecmdb/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def parse_user_params(user_params):
139139
return {}
140140

141141

142-
if __name__ == "__main__":
142+
def main():
143143
log = get_logger()
144144
data_dir = get_data_dir()
145145
tpl_dir = os.path.join(data_dir, 'tpl')
@@ -243,3 +243,6 @@ def parse_user_params(user_params):
243243
"""
244244
sys.stderr.write(debug_txt)
245245
sys.exit(1)
246+
247+
if __name__ == "__main__":
248+
main()

0 commit comments

Comments
 (0)