Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.maint.python > #7934

Re: Application libraries private, Distutils metadata available for console scripts and introspection

Path csiph.com!news.mixmin.net!weretis.net!feeder4.news.weretis.net!storethat.news.telefonica.de!telefonica.de!news.panservice.it!bofh.it!news.nic.it!robomod
From Barry Warsaw <barry@debian.org>
Newsgroups linux.debian.maint.python
Subject Re: Application libraries private, Distutils metadata available for console scripts and introspection
Date Mon, 30 Nov 2015 17:30:04 +0100
Message-ID <qAzuY-5YC-79@gated-at.bofh.it> (permalink)
References <q3JXI-21j-5@gated-at.bofh.it> <q4bKi-8dy-13@gated-at.bofh.it> <qzdG9-2TH-5@gated-at.bofh.it>
X-Original-To debian-python@lists.debian.org
X-Mailbox-Line From debian-python-request@lists.debian.org Mon Nov 30 16:28:07 2015
Old-Return-Path <barry@debian.org>
X-Amavis-Spam-Status No, score=-7 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, LDO_WHITELIST=-5] autolearn=ham autolearn_force=no
X-Policyd-Weight NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .debian. - helo: .mail.wooz. - helo-domain: .wooz.) FROM/MX_MATCHES_NOT_HELO(DOMAIN)=0; rate: -5
Organization The Organization of Unorganized Woozalists
X-Mailer Claws Mail 3.12.0 (GTK+ 2.24.28; x86_64-pc-linux-gnu)
MIME-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Mailing-List <debian-python@lists.debian.org> archive/latest/13250
List-ID <debian-python.lists.debian.org>
List-URL <https://lists.debian.org/debian-python/>
List-Archive https://lists.debian.org/msgid-search/20151130112749.7c124547@limelight.wooz.org
Approved robomod@news.nic.it
Lines 28
Sender robomod@news.nic.it
X-Original-Date Mon, 30 Nov 2015 11:27:49 -0500
X-Original-Message-ID <20151130112749.7c124547@limelight.wooz.org>
X-Original-References <85bndmc0ln.fsf@benfinney.id.au> <85k2s99q1h.fsf@benfinney.id.au> <857fl49xop.fsf@benfinney.id.au>
Xref csiph.com linux.debian.maint.python:7934

Show key headers only | View raw


On Nov 27, 2015, at 09:56 AM, Ben Finney wrote:

>Python's import mechanism makes it infeasible to have a module file
>named without a suffix; this makes it infeasible to name a command file
>by Unix conventions of having no suffix for the implementation language.
>
>There are many approaches to address this, which I won't detail here,
>but suffice it to say that none of them work smoothly.

I agree that it makes sense to separate the importable module from the
executable script file, but I'd argue that's good practice anyway for ease of
development, use, and testing.  And there are good tools and techniques to
take advantage of that, including setuptools entry points, or shim-scripts
with only an import and an `__name__` conditional.

I've found it good to minimize the logic in executable scripts because they
are harder to test.  If essentially all your script does is import your main()
and then call it, you can more easily incorporate a unit test for main().
Entry points make this a no-brainer; you don't even have to write the shim,
although to invoke it you need to build the package, so either use
`$python -m` or tox to create the shim in the tox-managed venv.

(I don't personally like application private library directories, but if you
do, you will have to fiddle with sys.path somehow to make your main()
importable.)

Cheers,
-Barry

Back to linux.debian.maint.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Application libraries private, Distutils metadata available for console scripts and introspection Ben Finney <ben+debian@benfinney.id.au> - 2015-09-01 05:00 +0200
  Re: Application libraries private, Distutils metadata available for  console scripts and introspection Robert Collins <robertc@robertcollins.net> - 2015-09-01 06:50 +0200
    Re: Application libraries private, Distutils metadata available for console scripts and introspection Ben Finney <ben+debian@benfinney.id.au> - 2015-09-01 07:40 +0200
      Re: Application libraries private, Distutils metadata available for  console scripts and introspection Robert Collins <robertc@robertcollins.net> - 2015-09-01 09:40 +0200
  Re: Application libraries private, Distutils metadata available for console scripts and introspection Ben Finney <ben+debian@benfinney.id.au> - 2015-09-01 08:10 +0200
    Re: Application libraries private, Distutils metadata available for  console scripts and introspection Piotr Ożarowski <piotr@debian.org> - 2015-09-01 12:20 +0200
  Re: Application libraries private, Distutils metadata available for console scripts and introspection Ben Finney <ben+debian@benfinney.id.au> - 2015-09-02 10:40 +0200
    Re: Application libraries private, Distutils metadata available for  console scripts and introspection Robert Collins <robertc@robertcollins.net> - 2015-09-02 11:10 +0200
      Re: Application libraries private, Distutils metadata available for  console scripts and introspection Karsten Hilbert <Karsten.Hilbert@gmx.net> - 2015-09-02 11:20 +0200
        Re: Application libraries private, Distutils metadata available for  console scripts and introspection Robert Collins <robertc@robertcollins.net> - 2015-09-02 13:30 +0200
        Re: Application libraries private, Distutils metadata available for  console scripts and introspection Barry Warsaw <barry@debian.org> - 2015-09-02 15:50 +0200
      Re: Application libraries private, Distutils metadata available for console scripts and introspection Ben Finney <ben+debian@benfinney.id.au> - 2015-09-02 12:50 +0200
        Re: Application libraries private, Distutils metadata available for  console scripts and introspection Robert Collins <robertc@robertcollins.net> - 2015-09-02 13:30 +0200
      Re: Application libraries private, Distutils metadata available for  console scripts and introspection Barry Warsaw <barry@debian.org> - 2015-09-02 15:50 +0200
    Re: Application libraries private, Distutils metadata available for  console scripts and introspection Piotr Ożarowski <piotr@debian.org> - 2015-09-03 00:20 +0200
    Re: Application libraries private, Distutils metadata available for console scripts and introspection Ben Finney <ben+debian@benfinney.id.au> - 2015-11-27 00:00 +0100
      Re: Application libraries private, Distutils metadata available for  console scripts and introspection Piotr Ożarowski <piotr@debian.org> - 2015-11-27 00:30 +0100
      Re: Application libraries private, Distutils metadata available for  console scripts and introspection Barry Warsaw <barry@debian.org> - 2015-11-30 17:30 +0100

csiph-web