Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd .py extension when installing scripts on Windows platforms
    primarykey
    data
    text
    <p>How can I configure <code>setup.py</code> to install scripts with a <code>.py</code> prefix on Windows platforms but without the prefix on all others? The problem I'm trying to solve is that <a href="http://docs.python.org/3/faq/windows.html#how-do-i-make-python-scripts-executable" rel="nofollow">Windows requires a <code>.py</code> extension to recognize and execute Python scripts</a>.</p> <p>I have a package set up like the following:</p> <pre><code>MyPackage ├── CHANGES ├── ... ├── scripts │   └── myprogram ├── setup.py └── mypackage ├── __init__.py ├── ... └── myprogram.py </code></pre> <p>In my setup.py file I declare <code>scripts/myprogram</code> as an installable script with</p> <pre><code>#!/usr/bin/env python # -*- coding: UTF-8 -*- from setuptools import setup ... setup( name='MyPackage', ... packages=['mypackage'], scripts=['scripts/myprogram'], ... ) </code></pre> <p>The <code>myprogram</code> script is just a thin wrapper that simply calls <code>mypackage.myprogram.main()</code>:</p> <pre><code>#!/usr/bin/env python # -*- coding: UTF-8 -*- from mypackage import myprogram myprogram.main() </code></pre> <p>On *nix platforms, this installs <code>myprogram</code> as an executable by the name of <code>myprogram</code>, which is what I desire, but on Windows, it also installs as <code>myprogram</code> in the <code>C:\PythonXX\Scripts</code> directory, and is thus not recognized on the command line. How can I get the setup script to install <code>myprogram</code> as <code>myprogram.py</code> on Windows, so that Windows recognizes the file type to make it executable?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload