Repository: mesonbuild/meson

Issue:
setup.py: Install scripts without extensions on UNIX-like platforms
Because of issue #394 , meson install scripts as `xxx.py` , but in linux, install script with a extension name is no a good practice. And change the installed script name also break some package depend on meson.

Could you deal with it for different platform?

thx.



Discussion:
The case of Python's script suffixes is neverending pain. No matter what you set it to, someone's setup will be broken.

We're going to stick with the current one which seems the least broken unless someone can come up with a scheme that works for everybody.

I think we should install with suffix on windows and without on other (normal) systems.

Has anyone considered using [`entry_points`](https://pythonhosted.org/setuptools/setuptools.html#automatic-script-creation)? Obviously it would mean that setuptools would become a requirement, but is it particularly common no to have setuptools installed nowadays?

Automatic script creation in `setuptools` seems to be our best option. I think it's ok to require setuptools if you're building or installing since you can run uninstalled if you want to anyway.

New link is [here](https://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation) btw, looks like they've changed where their docs are hosted.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import os
 import sys
+from os import path
 
 if sys.version_info[0] < 3:
     print('Tried to install with Python 2, Meson only supports Python 3.')
@@ -25,8 +27,32 @@
 # plain distutils when setuptools is not available.
 try:
     from setuptools import setup
+    from setuptools.command.install_scripts import install_scripts as orig
 except ImportError:
     from distutils.core import setup
+    from distutils.command.install_scripts import install_scripts as orig
+
+from distutils.file_util import copy_file
+from distutils.dir_util import mkpath
+from stat import ST_MODE
+
+class install_scripts(orig):
+    def run(self):
+        if sys.platform == 'win32':
+            super().run()
+            return
+
+        self.outfiles = []
+        if not self.dry_run:
+            mkpath(self.install_dir)
+
+        # We want the files to be installed without a suffix on Unix
+        for infile in self.get_inputs():
+            in_stripped = infile[:-3] if infile.endswith('.py') else infile
+            outfile = path.join(self.install_dir, in_stripped)
+            # NOTE: Mode is preserved by default
+            copy_file(infile, outfile, dry_run=self.dry_run)
+            self.outfiles.append(outfile)
 
 from mesonbuild.coredata import version
 
@@ -46,6 +72,7 @@
                'mesonconf.py',
                'mesonintrospect.py',
                'wraptool.py'],
+      cmdclass={'install_scripts': install_scripts},
       data_files=[('share/man/man1', ['man/meson.1',
                                       'man/mesonconf.1',
                                       'man/mesonintrospect.1',


Test patch: