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

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 2015-11-30 17:30 +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>
Organization The Organization of Unorganized Woozalists

Show all headers | 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