Use entry_points for ipa CLI

Fix problem with hard-coded shebang in ipa command line tool by using
a proper setuptools entry point for the console script. ipaclient is now
an executable Python package, too.

```
$ python -m ipaclient ping
```

is equivalent to

```
$ ipa ping
```

Related: https://pagure.io/freeipa/issue/6653
Closes: https://pagure.io/freeipa/issue/6850
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
This commit is contained in:
Christian Heimes 2017-04-07 15:03:08 +02:00 committed by Martin Basti
parent bad0f608c4
commit bf67974459
3 changed files with 22 additions and 4 deletions

5
ipa
View File

@ -24,8 +24,7 @@ Command Line Interface for IPA administration.
The CLI functionality is implemented in ipalib/cli.py
"""
from ipalib import api, cli
from ipaclient.__main__ import main
if __name__ == '__main__':
cli.run(api)
main()

15
ipaclient/__main__.py Normal file
View File

@ -0,0 +1,15 @@
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
"""
Command Line Interface for IPA administration.
The CLI functionality is implemented in ipalib/cli.py
"""
from ipalib import api, cli
def main():
cli.run(api)
if __name__ == '__main__':
main()

View File

@ -31,7 +31,6 @@ if __name__ == '__main__':
ipasetup(
name="ipaclient",
doc=__doc__,
scripts=['../ipa'],
package_dir={'ipaclient': ''},
packages=[
"ipaclient",
@ -60,6 +59,11 @@ if __name__ == '__main__':
"qrcode",
"six",
],
entry_points={
'console_scripts': [
'ipa = ipaclient.__main__:main'
]
},
extras_require={
"install": ["ipaplatform"],
"otptoken_yubikey": ["yubico", "usb"]