G
Göktuğ Kayaalp
Hi all,
I'm using python to write command line apps from time to time. I wonder
*what is the conventional way to test-run these apps from within the
project itself, while developing, without installing*.
My usual practise is to have two entry points to the program as
executable scripts. I usually put executables into a directory called
`scripts/'. The source code of the program is organized into a package,
and the package has an entry point which is a function that is passed
the command line arguments (sys.argv[1:]). One of the scripts -- the
one that will be installed -- assumes that the package is installed. It
imports the entry function of the package and calls it:
#!/usr/bin/env python3.3
from package.module import main
import sys
if __name__ == '__main__':
exit(main(sys.argv[1:]))
The other script is for running the version of the package that is
currently being developed in the project directory. In that script,
I manipulate sys.path to have the project root at the very front:
#!/usr/bin/env python3.3
import sys
import os
sys.path.insert(0, os.path.join(os.path.realpath(".."), "sug/"))
from package import module
if __name__ == '__main__':
exit(module.main(sys.argv[1:]))
Even though I use virtualenvs for each project and have tests, I still
want to run and see effects of my changes immediately and do not like to
install the package every time I make a small change.
I have surveyed most popular projects on Github, only to see nothing in
common: some only have scripts like the first example, some use entry
point attributes in setup.py, some have these scripts very deep in the
package hierarchy etc. What is the `one true way' to achieve this?
I want to emphasise that I do not want to have to install the package
in order to be able to run the executable scripts.
cheers,
göktuğ
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
iQIcBAEBAgAGBQJScrmXAAoJEMWnx0cuRfJT2FAQAJHjS0vEABYfRdKzw9eQJYaW
16gFmw2Ba1Nr9t/LERMdHFSXelyoFHXXc8UaEjTgP2k+OHMlH6yPMmRDg5L0dcRh
5w8ord8yY0JbsJ3QwWn/B5/W+Iv9rQErLKd7hA2Hs7qvw99ofw4Gq3waBcqbXlhI
8Z0IU/RkKmGJJNq5/eeA9ZnJ8e5ZiUU6aSutg3cAVO/pZH+1jD4yXIw1/T6CEXky
RXYW0tTScgx8YOVgQO9hbjWHv5ke2BVICVNYMKbO7RnGsS1UkDkgIaGKFLX8UDpR
kwAuTLvKRO/wvxoOZf7ysO1LIqgubC5GVIULftrVSfpILMj8emI+npyxJ3M68XVS
id1StR7Hi8MHJvTU4g74s0zV6Wz8VxtWXYhKIHl41jpCYnZGBuhdVVIzYhrpBIAT
fm/jW4gRNRxSs9N3QHQs6t8tc/RL4nWDBqA696UF/tFoCminmwiF44gpmfoUcGr+
+cux+DnfWqRH9171UrLjCsaNe5GdnLws9tKtASwMG7NM4RhDAxxqw9gN9Myvfatz
zY9P8ulRv9UJiCZ7BshKH0I/wBXzYZ58mi5M0A8m+GgFEGlPkOjcXId3sW0yjG/R
bb98HpvjdUocJnoQtJlm0hBCsKQTE2qjMrV61UsLfqGJnDt3OBgk61E7ZufY5se8
r5dmZIvSexYc5tPBq2SB
=CFfi
-----END PGP SIGNATURE-----
I'm using python to write command line apps from time to time. I wonder
*what is the conventional way to test-run these apps from within the
project itself, while developing, without installing*.
My usual practise is to have two entry points to the program as
executable scripts. I usually put executables into a directory called
`scripts/'. The source code of the program is organized into a package,
and the package has an entry point which is a function that is passed
the command line arguments (sys.argv[1:]). One of the scripts -- the
one that will be installed -- assumes that the package is installed. It
imports the entry function of the package and calls it:
#!/usr/bin/env python3.3
from package.module import main
import sys
if __name__ == '__main__':
exit(main(sys.argv[1:]))
The other script is for running the version of the package that is
currently being developed in the project directory. In that script,
I manipulate sys.path to have the project root at the very front:
#!/usr/bin/env python3.3
import sys
import os
sys.path.insert(0, os.path.join(os.path.realpath(".."), "sug/"))
from package import module
if __name__ == '__main__':
exit(module.main(sys.argv[1:]))
Even though I use virtualenvs for each project and have tests, I still
want to run and see effects of my changes immediately and do not like to
install the package every time I make a small change.
I have surveyed most popular projects on Github, only to see nothing in
common: some only have scripts like the first example, some use entry
point attributes in setup.py, some have these scripts very deep in the
package hierarchy etc. What is the `one true way' to achieve this?
I want to emphasise that I do not want to have to install the package
in order to be able to run the executable scripts.
cheers,
göktuğ
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
iQIcBAEBAgAGBQJScrmXAAoJEMWnx0cuRfJT2FAQAJHjS0vEABYfRdKzw9eQJYaW
16gFmw2Ba1Nr9t/LERMdHFSXelyoFHXXc8UaEjTgP2k+OHMlH6yPMmRDg5L0dcRh
5w8ord8yY0JbsJ3QwWn/B5/W+Iv9rQErLKd7hA2Hs7qvw99ofw4Gq3waBcqbXlhI
8Z0IU/RkKmGJJNq5/eeA9ZnJ8e5ZiUU6aSutg3cAVO/pZH+1jD4yXIw1/T6CEXky
RXYW0tTScgx8YOVgQO9hbjWHv5ke2BVICVNYMKbO7RnGsS1UkDkgIaGKFLX8UDpR
kwAuTLvKRO/wvxoOZf7ysO1LIqgubC5GVIULftrVSfpILMj8emI+npyxJ3M68XVS
id1StR7Hi8MHJvTU4g74s0zV6Wz8VxtWXYhKIHl41jpCYnZGBuhdVVIzYhrpBIAT
fm/jW4gRNRxSs9N3QHQs6t8tc/RL4nWDBqA696UF/tFoCminmwiF44gpmfoUcGr+
+cux+DnfWqRH9171UrLjCsaNe5GdnLws9tKtASwMG7NM4RhDAxxqw9gN9Myvfatz
zY9P8ulRv9UJiCZ7BshKH0I/wBXzYZ58mi5M0A8m+GgFEGlPkOjcXId3sW0yjG/R
bb98HpvjdUocJnoQtJlm0hBCsKQTE2qjMrV61UsLfqGJnDt3OBgk61E7ZufY5se8
r5dmZIvSexYc5tPBq2SB
=CFfi
-----END PGP SIGNATURE-----