Merge pull request #4004 from mesonbuild/nirbheek/console-entrypoint

Install meson.exe as the entrypoint on Windows
pull/3390/merge
Jussi Pakkanen 7 years ago committed by GitHub
commit f335c8bdeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .appveyor.yml
  2. 8
      mesonbuild/mesonmain.py
  3. 42
      run_meson_command_tests.py
  4. 110
      setup.py

@ -99,7 +99,7 @@ install:
- cmd: if %compiler%==msys2-mingw ( set "PATH=C:\msys64\mingw%PACMAN_BITS%\bin;%PATH%" )
- cmd: if %compiler%==msys2-mingw ( set "MESON_PYTHON_PATH=C:\msys64\mingw%PACMAN_BITS%\bin" )
- cmd: if %compiler%==msys2-mingw ( set "PYTHON=python3" )
- cmd: if %compiler%==msys2-mingw ( C:\msys64\usr\bin\pacman -S --needed --noconfirm "mingw%PACMAN_BITS%/mingw-w64-%PACMAN_ARCH%-python3" )
- cmd: if %compiler%==msys2-mingw ( C:\msys64\usr\bin\pacman -S --needed --noconfirm "mingw%PACMAN_BITS%/mingw-w64-%PACMAN_ARCH%-python3" "mingw%PACMAN_BITS%/mingw-w64-%PACMAN_ARCH%-python3-setuptools" )
# Cygwin
- cmd: if not %compiler%==cygwin ( set "PATH=%cd%;%MESON_PYTHON_PATH%;%PATH%;" )
- cmd: if %compiler%==cygwin ( set WRAPPER=ci\run-in-cygwin.bat )

@ -232,15 +232,17 @@ def run_script_command(args):
return cmdfunc(cmdargs)
def set_meson_command(mainfile):
if mainfile.endswith('.exe'):
# On UNIX-like systems `meson` is a Python script
# On Windows `meson` and `meson.exe` are wrapper exes
if not mainfile.endswith('.py'):
mesonlib.meson_command = [mainfile]
elif os.path.isabs(mainfile) and mainfile.endswith('mesonmain.py'):
# Can't actually run meson with an absolute path to mesonmain.py, it must be run as -m mesonbuild.mesonmain
mesonlib.meson_command = mesonlib.python_command + ['-m', 'mesonbuild.mesonmain']
else:
# Either run uninstalled, or full path to meson-script.py
mesonlib.meson_command = mesonlib.python_command + [mainfile]
# This won't go into the log file because it's not initialized yet, and we
# need this value for unit tests.
# We print this value for unit tests.
if 'MESON_COMMAND_TESTS' in os.environ:
mlog.log('meson_command is {!r}'.format(mesonlib.meson_command))

@ -131,29 +131,33 @@ class CommandTests(unittest.TestCase):
os.environ['PYTHONPATH'] = str(pylibdir)
os.environ['PATH'] = str(bindir) + os.pathsep + os.environ['PATH']
self._run(python_command + ['setup.py', 'install', '--prefix', str(prefix)])
self.assertTrue(pylibdir.is_dir())
# Check that all the files were installed correctly
self.assertTrue(bindir.is_dir())
self.assertTrue(pylibdir.is_dir())
from setup import packages
# Extract list of expected python module files
expect = set()
for pkg in packages:
expect.update([p.as_posix() for p in Path(pkg.replace('.', '/')).glob('*.py')])
# Check what was installed, only count files that are inside 'mesonbuild'
have = set()
for p in Path(pylibdir).glob('**/*.py'):
s = p.as_posix()
if 'mesonbuild' not in s:
continue
have.add(s[s.rfind('mesonbuild'):])
self.assertEqual(have, expect)
# Run `meson`
os.chdir('/')
if is_windows():
resolved_meson_command = python_command + [str(bindir / 'meson.py')]
else:
resolved_meson_command = python_command + [str(bindir / 'meson')]
# The python configuration on appveyor does not register .py as
# a valid extension, so we cannot run `meson` on Windows.
builddir = str(self.tmpdir / 'build1')
meson_setup = ['meson', 'setup']
meson_command = meson_setup + self.meson_args
stdo = self._run(meson_command + [self.testdir, builddir])
self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
resolved_meson_command = [str(bindir / 'meson')]
builddir = str(self.tmpdir / 'build1')
meson_setup = ['meson', 'setup']
meson_command = meson_setup + self.meson_args
stdo = self._run(meson_command + [self.testdir, builddir])
self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
# Run `/path/to/meson`
builddir = str(self.tmpdir / 'build2')
if is_windows():
# Cannot run .py directly because of the appveyor configuration,
# and the script is named meson.py, not meson
meson_setup = python_command + [str(bindir / 'meson.py'), 'setup']
else:
meson_setup = [str(bindir / 'meson'), 'setup']
meson_setup = [str(bindir / 'meson'), 'setup']
meson_command = meson_setup + self.meson_args
stdo = self._run(meson_command + [self.testdir, builddir])
self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
@ -168,7 +172,7 @@ class CommandTests(unittest.TestCase):
# Next part requires a shell
return
# `meson` is a wrapper to `meson.real`
resolved_meson_command = python_command + [str(bindir / 'meson.real')]
resolved_meson_command = [str(bindir / 'meson.real')]
builddir = str(self.tmpdir / 'build4')
(bindir / 'meson').rename(bindir / 'meson.real')
wrapper = (bindir / 'meson')

@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
from mesonbuild.coredata import version
@ -24,70 +23,49 @@ if sys.version_info < (3, 5, 0):
'Meson requires Python 3.5.0 or greater')
sys.exit(1)
# We need to support Python installations that have nothing but the basic
# Python installation. Use setuptools when possible and fall back to
# 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 setuptools import setup
class install_scripts(orig):
def run(self):
if sys.platform == 'win32':
super().run()
return
# On windows, will create Scripts/meson.exe and Scripts/meson-script.py
# Other platforms will create bin/meson
entries = {'console_scripts': ['meson=mesonbuild.mesonmain:main']}
packages = ['mesonbuild',
'mesonbuild.backend',
'mesonbuild.compilers',
'mesonbuild.dependencies',
'mesonbuild.modules',
'mesonbuild.scripts',
'mesonbuild.wrap']
data_files = []
if sys.platform != 'win32':
# Only useful on UNIX-like systems
data_files = [('share/man/man1', ['man/meson.1']),
('share/polkit-1/actions', ['data/com.mesonbuild.install.policy'])]
if not self.skip_build:
self.run_command('build_scripts')
self.outfiles = []
if not self.dry_run:
self.mkpath(self.install_dir)
# We want the files to be installed without a suffix on Unix
for infile in self.get_inputs():
infile = os.path.basename(infile)
in_built = os.path.join(self.build_dir, infile)
in_stripped = infile[:-3] if infile.endswith('.py') else infile
outfile = os.path.join(self.install_dir, in_stripped)
# NOTE: Mode is preserved by default
self.copy_file(in_built, outfile)
self.outfiles.append(outfile)
setup(name='meson',
version=version,
description='A high performance build system',
author='Jussi Pakkanen',
author_email='jpakkane@gmail.com',
url='http://mesonbuild.com',
license=' Apache License, Version 2.0',
python_requires='>=3.5',
packages=['mesonbuild',
'mesonbuild.backend',
'mesonbuild.compilers',
'mesonbuild.dependencies',
'mesonbuild.modules',
'mesonbuild.scripts',
'mesonbuild.wrap'],
scripts=['meson.py'],
cmdclass={'install_scripts': install_scripts},
data_files=[('share/man/man1', ['man/meson.1']),
('share/polkit-1/actions', ['data/com.mesonbuild.install.policy'])],
classifiers=['Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: BSD',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Software Development :: Build Tools',
],
long_description='''Meson is a cross-platform build system designed to be both as
fast and as user friendly as possible. It supports many languages and compilers, including
GCC, Clang and Visual Studio. Its build definitions are written in a simple non-turing
complete DSL.''')
if __name__ == '__main__':
setup(name='meson',
version=version,
description='A high performance build system',
author='Jussi Pakkanen',
author_email='jpakkane@gmail.com',
url='http://mesonbuild.com',
license=' Apache License, Version 2.0',
python_requires='>=3.5',
packages=packages,
entry_points=entries,
data_files=data_files,
classifiers=['Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: BSD',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Software Development :: Build Tools',
],
long_description='''Meson is a cross-platform build system designed to be both as
fast and as user friendly as possible. It supports many languages and compilers, including
GCC, Clang and Visual Studio. Its build definitions are written in a simple non-turing
complete DSL.''')

Loading…
Cancel
Save