In the long run we want to move away from manual script generation. The state of the art are setuptools' entry points for console script [1]. Setuptools or wheels auto-generates CLI scripts with correct shebang to the current Python interpreter. This will also fix an outstanding issue with virtual envs and tox testing. Console scripts take virtual envs correctly into account.
To prepare FreeIPA's code base for console script entry points, the body of all scripts must be moved into importable modules. About half of the scripts in install/tools are already in the correct form. Some scripts like ipa-ca-install have to be changed. The ipa script also needs a minor overhaul. Entry points can only import one object and call one function. It's possible to call a method on a sub-object but it is neither possible to instantiate a class and call a method on the instance, or to call a function with an additional argument.
install/tools
ipa-ca-install
ipa
The approach has another big benefit. It's going to be much easier to grep for code, imports and function calls. There will be no extra Python code in directories outside the package directories.
# ipa-backup from ipaserver.install.ipa_backup import Backup Backup.run_cli()
becomes
ipa-backup = ipaserver.install.ipa_backup:Backup.run_cli
code:
>>> import pkg_resources >>> e = pkg_resources.EntryPoint.parse('ipa-backup = ipaserver.install.ipa_backup:Backup.run_cli') >>> e EntryPoint.parse('ipa-backup = ipaserver.install.ipa_backup:Backup.run_cli') >>> e.resolve() <bound method type.run_cli of <class 'ipaserver.install.ipa_backup.Backup'>>
[1] https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-console-scripts-entry-point
client/ipa-client-automount
daemons/dnssec/ipa-dnskeysyncd
daemons/dnssec/ipa-ods-exporter
install/tools/ipa-adtrust-install
install/tools/ipa-replica-manage
install/certmonger/ipa-server-guard
install/oddjob/com.redhat.idm.trust-fetch-domains
install/restart_scripts/renew_ca_cert
install/restart_scripts/stop_pkicad
ipatests/ipa-run-tests
ipatests/ipa-test-task
makeapi
Metadata Update from @cheimes: - Issue assigned to someone - Issue set to the milestone: Future Releases
master:
ipa-4-5:
Log in to comment on this ticket.