FAQ
Hello,

All my Python files have extension .py. However, I would like to install
scripts that are meant to be called by the user without the suffix, i.e.
the file scripts/doit.py should end up as /usr/bin/doit.

Apparently the scripts= option of the setup() function does not support
this directly. Is there a clever way to get what I want?


Best,

-Nikolaus

--
?Time flies like an arrow, fruit flies like a Banana.?

PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C

Search Discussions

  • Lie Ryan at Dec 5, 2009 at 1:52 am

    On 12/5/2009 11:34 AM, Nikolaus Rath wrote:
    Hello,

    All my Python files have extension .py. However, I would like to install
    scripts that are meant to be called by the user without the suffix, i.e.
    the file scripts/doit.py should end up as /usr/bin/doit.

    Apparently the scripts= option of the setup() function does not support
    this directly. Is there a clever way to get what I want?
    if this is on windows, you should add ".py" to the PATHEXT environment
    variable.

    on linux/unix, you need to add the proper #! line to the top of any
    executable scripts and of course set the executable bit permission
    (chmod +x scriptname). In linux/unix there is no need to have the .py
    extension for a file to be recognized as python script (i.e. just remove
    it).
  • Floris Bruynooghe at Dec 5, 2009 at 9:52 am

    On Dec 5, 1:52?am, Lie Ryan wrote:
    on linux/unix, you need to add the proper #! line to the top of any
    executable scripts and of course set the executable bit permission
    (chmod +x scriptname). In linux/unix there is no need to have the .py
    extension for a file to be recognized as python script (i.e. just remove
    it).
    The #! line will even get replaced by the interpreter used during
    installation, so you can safely write "#!/usr/bin/env python" in your
    development copy and get "#!/usr/bin/python" when users install it.
  • Nikolaus Rath at Dec 5, 2009 at 4:08 pm

    Lie Ryan <lie.1296 at gmail.com> writes:
    On 12/5/2009 11:34 AM, Nikolaus Rath wrote:
    Hello,

    All my Python files have extension .py. However, I would like to install
    scripts that are meant to be called by the user without the suffix, i.e.
    the file scripts/doit.py should end up as /usr/bin/doit.

    Apparently the scripts= option of the setup() function does not support
    this directly. Is there a clever way to get what I want?
    if this is on windows, you should add ".py" to the PATHEXT environment
    variable.

    on linux/unix, you need to add the proper #! line to the top of any
    executable scripts and of course set the executable bit permission
    (chmod +x scriptname). In linux/unix there is no need to have the .py
    extension for a file to be recognized as python script (i.e. just
    remove it).
    Sorry, but I think this is totally unrelated to my question. I want to
    rename files during the setup process. This is not going to happen by
    adding/changing any #! lines or the permissions of the file.

    I know that there is no need to have the .py extension, that's why I
    want to install the scripts without this suffix. But in my source
    distribution I want to keep the suffix for various reasons.

    Best,

    -Nikolaus

    --
    ?Time flies like an arrow, fruit flies like a Banana.?

    PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
  • Wolodja Wentland at Dec 5, 2009 at 11:37 am

    On Fri, Dec 04, 2009 at 19:34 -0500, Nikolaus Rath wrote:
    All my Python files have extension .py. However, I would like to install
    scripts that are meant to be called by the user without the suffix, i.e.
    the file scripts/doit.py should end up as /usr/bin/doit.
    Apparently the scripts= option of the setup() function does not support
    this directly. Is there a clever way to get what I want?
    Just name the file you want to install 'doit' and not 'doit.py'. That
    would be the easiest way. You might run into problems on Windows though,
    which IIRC (it's been a while) heavily relies on file suffixes and not
    on their content. That might have changed in the last 10 years though,
    so better check that first.

    You can also use entry points to create the executable at install time.
    Have a look at [1] which explains how this is done. This requires using
    Distribute/setuptools though, ...

    [1] http://packages.python.org/distribute/setuptools.html#automatic-script-creation
    --
    .''`. Wolodja Wentland <wentland at cl.uni-heidelberg.de>
    : :' :
    `. `'` 4096R/CAF14EFC
    `- 081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC
    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: not available
    Type: application/pgp-signature
    Size: 836 bytes
    Desc: Digital signature
    URL: <http://mail.python.org/pipermail/python-list/attachments/20091205/106234ae/attachment.pgp>
  • Nikolaus Rath at Dec 5, 2009 at 4:12 pm

    Wolodja Wentland <wentland at cl.uni-heidelberg.de> writes:
    On Fri, Dec 04, 2009 at 19:34 -0500, Nikolaus Rath wrote:
    All my Python files have extension .py. However, I would like to install
    scripts that are meant to be called by the user without the suffix, i.e.
    the file scripts/doit.py should end up as /usr/bin/doit.
    Apparently the scripts= option of the setup() function does not support
    this directly. Is there a clever way to get what I want?
    You can also use entry points to create the executable at install time.
    Have a look at [1] which explains how this is done. This requires using
    Distribute/setuptools though, ...

    [1] http://packages.python.org/distribute/setuptools.html#automatic-script-creation
    That looks perfect, thanks!


    Best,

    -Nikolaus

    --
    ?Time flies like an arrow, fruit flies like a Banana.?

    PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedDec 5, '09 at 12:34a
activeDec 5, '09 at 4:12p
posts6
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase