Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; 'package,': 0.03; 'root': 0.05; 'installed.': 0.07; 'subject: -- ': 0.07; 'sys': 0.07; '__name__': 0.09; 'arguments': 0.09; 'attributes': 0.09; 'executable': 0.09; 'subject:command': 0.09; 'tests,': 0.09; 'python': 0.11; 'changes': 0.15; "'__main__':": 0.16; 'developing,': 0.16; 'filename:fname piece:signature': 0.16; 'hierarchy': 0.16; 'imports': 0.16; 'itself,': 0.16; 'received:72.5': 0.16; 'received:72.5.230': 0.16; 'received:sender1.zohomail.com': 0.16; 'received:zohomail.com': 0.16; 'script,': 0.16; 'scripts.': 0.16; 'subject: \n ': 0.16; 'subject:projects': 0.16; 'sys.path': 0.16; 'subject:python': 0.16; 'apps': 0.16; 'all,': 0.19; 'module': 0.19; 'command': 0.22; 'import': 0.22; 'install': 0.23; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'directory.': 0.24; 'skip:e 30': 0.24; 'cheers,': 0.24; 'source': 0.25; 'script': 0.25; 'subject:/': 0.26; 'installed': 0.27; 'point': 0.28; 'function': 0.29; 'points': 0.29; 'wonder': 0.29; "i'm": 0.30; 'code': 0.31; 'usually': 0.31; 'assumes': 0.31; 'run': 0.32; 'running': 0.33; 'skip:# 10': 0.33; 'subject:the': 0.34; 'subject:from': 0.34; 'usual': 0.35; 'version': 0.36; 'entry': 0.36; 'example,': 0.37; 'two': 0.37; 'project': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'called': 0.40; 'even': 0.60; 'most': 0.60; 'skip:o 30': 0.61; 'from:charset:utf-8': 0.61; 'first': 0.61; 'content-disposition:inline': 0.62; 'developed': 0.63; 'within': 0.65; 'subject:Testing': 0.84 Date: Thu, 31 Oct 2013 22:12:07 +0200 From: =?utf-8?B?R8O2a3R1xJ8=?= Kayaalp To: python-list@python.org Subject: Testing python command line apps -- Running from within the projects w/o installing MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8t9RHnE3ZwKMSgU+" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Zoho-Virus-Status: 1 X-ZohoMailClient: External X-Mailman-Approved-At: Thu, 31 Oct 2013 21:31:20 +0100 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 81 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383251481 news.xs4all.nl 16003 [2001:888:2000:d::a6]:36395 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58205 --8t9RHnE3ZwKMSgU+ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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__ =3D=3D '__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__ =3D=3D '__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=C3=B6ktu=C4=9F --8t9RHnE3ZwKMSgU+ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----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----- --8t9RHnE3ZwKMSgU+--