Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58205
| 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 | <self@gkayaalp.com> |
| 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 | Göktuğ Kayaalp <self@gkayaalp.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1890.1383251481.18130.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
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ğ
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Testing python command line apps -- Running from within the projects w/o installing Göktuğ Kayaalp <self@gkayaalp.com> - 2013-10-31 22:12 +0200
csiph-web