Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install meson.exe as the entrypoint on Windows #4004

Merged
merged 3 commits into from Aug 11, 2018

Conversation

Projects
None yet
9 participants
@nirbheek
Copy link
Member

nirbheek commented Aug 10, 2018

Thanks to Rafael Rivera for the suggestion

Fixes #1877

@nirbheek nirbheek force-pushed the nirbheek/console-entrypoint branch 2 times, most recently from 042e78d to ddf5855 Aug 10, 2018

@MathieuDuponchelle
Copy link
Contributor

MathieuDuponchelle left a comment

Looks good to me, and actually allows me to have usable meson after install on Windows, up until now I was always explicitly typing python3 C:/path/to/meson.py, that was a bit cumbersome :)

if 'MESON_COMMAND_TESTS' in os.environ:
mlog.log('meson_command is {!r}'.format(mesonlib.meson_command))
print('meson_command is {!r}'.format(mesonlib.meson_command))

This comment has been minimized.

@MathieuDuponchelle

MathieuDuponchelle Aug 10, 2018

Contributor

hrm, why would you switch to a print? If I understand correctly, mlog.log will jump through some extra hoops to avoid locale errors etc

This comment has been minimized.

@nirbheek

nirbheek Aug 10, 2018

Author Member

Hmm, good point. I thought it would be simpler because it's only used in tests, but then the tests might fail on certain locales.

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Aug 10, 2018

Looks like msys2-mingw python doesn't ship with setuptools? Needs to be installed with pacman

C:\msys64\mingw32\lib\python3.6\distutils\dist.py:261: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg)
C:\msys64\mingw32\lib\python3.6\distutils\dist.py:261: UserWarning: Unknown distribution option: 'entry_points' warnings.warn(msg)

How strange.

fdo-mirror pushed a commit to freedesktop/gstreamer-gst-build that referenced this pull request Aug 10, 2018

scripts: Fix fetching of meson command to run
Don't assume that meson is always a python script, on Windows it can
be (and soon will almost always be) an executable.

See: Meson MSI installer and mesonbuild/meson#4004
Install meson.exe as the entrypoint on Windows
Thanks to Rafael Rivera for the suggestion

Fixes #1877

@nirbheek nirbheek force-pushed the nirbheek/console-entrypoint branch from c7bd268 to 2ee2802 Aug 10, 2018

setup: Require setuptools and entry_points:
This gives us a consistent experience and a simpler setup across all
operating systems. Setuptools is available everywhere these days.
@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Aug 11, 2018

So I nuked distutils and now we require setuptools. Do we need to support distutils for some platforms or is this ok? I know for a fact that macOS and Windows Python installers ship with setuptools, and on MSYS2 you can install it with pacman. That leaves Linux, and Fedora ships with setuptools by default.

@lazka

This comment has been minimized.

Copy link
Contributor

lazka commented Aug 11, 2018

There are so many things depending on setuptools for install that I don't think this is going to be a problem.

@ignatenkobrain

This comment has been minimized.

Copy link
Member

ignatenkobrain commented Aug 11, 2018

Do not ever touch dead distutils :) nothing in this world works without setuptools

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Aug 11, 2018

I have no idea why we try to support both distutils and setuptools. The commit message which added setuptools doesn't say:

commit 2e42427d4ac17e3fce819c7d3095c354c4c3c555
Author: Jussi Pakkanen <jpakkane@gmail.com>
Date:   Sat Jan 16 20:09:47 2016 +0200

    Support both setuptools and distutils.

and the initial setup.py used distutils.

@jpakkane

This comment has been minimized.

Copy link
Member

jpakkane commented Aug 11, 2018

Setuptools is not in the Python standard library, only distutils is so our requirement for not depending on anything outside of the standard library comes into play here.

Also, setuptools produced broken files with sdist back when I last tried it. There were a bunch of files missing at random without any reason or pattern.

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Aug 11, 2018

Setuptools is not in the Python standard library, only distutils is so our requirement for not depending on anything outside of the standard library comes into play here.

That requirement is for running meson, though. For instance, we depend on hotdoc for our documentation.

Also, setuptools produced broken files with sdist back when I last tried it. There were a bunch of files missing at random without any reason or pattern.

We have tests for this now, although we don't check the complete files list in it yet.

@lazka

This comment has been minimized.

Copy link
Contributor

lazka commented Aug 11, 2018

That requirement is for running meson, though. For instance, we depend on hotdoc for our documentation.

Afair the generated entry point scripts depend on pkg_resources

@@ -19,6 +19,7 @@
import unittest
import subprocess
import zipapp
from glob import glob

This comment has been minimized.

@ignatenkobrain

ignatenkobrain Aug 11, 2018

Member

[Flake8]

[F401] 'glob.glob' imported but unused

@nirbheek nirbheek force-pushed the nirbheek/console-entrypoint branch 2 times, most recently from b225f25 to f6836f2 Aug 11, 2018

self.assertTrue(bindir.is_dir())
self.assertTrue(pylibdir.is_dir())
from setup import packages

This comment has been minimized.

@ignatenkobrain

ignatenkobrain Aug 11, 2018

Member

[Flake8]

[E271] multiple spaces after keyword

setup: Add tests for the installed files list
Ensure that the installed files list matches what we expect, to avoid
surprises at release time.

@nirbheek nirbheek force-pushed the nirbheek/console-entrypoint branch from f6836f2 to c0413f5 Aug 11, 2018

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Aug 11, 2018

I've added tests that verify the files list. Looks fine. Can you run it on Debian to test?

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Aug 11, 2018

Afair the generated entry point scripts depend on pkg_resources

That module is shipped with setuptools, right?

@jpakkane

This comment has been minimized.

Copy link
Member

jpakkane commented Aug 11, 2018

I tested this branch with Debian Sid's setuptools and the result was working just fine. Whatever the issue was it seems to be gone now.

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Aug 11, 2018

I think we should merge this so we have good Windows support out-of-the-box. distutils was a horrible failure, and setuptools is expected to be used by anyone trying to build + install python packages. It also does not change the "run from git" workflow at all.

@jpakkane jpakkane merged commit f335c8b into master Aug 11, 2018

3 checks passed

Sider No issues left; 2 issues fixed.
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jpakkane jpakkane deleted the nirbheek/console-entrypoint branch Aug 11, 2018

@anthrotype

This comment has been minimized.

Copy link

anthrotype commented Aug 31, 2018

When will this patch be released? I don't see it in the latest 0.47.2 as currently available from PyPI.
thanks

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Aug 31, 2018

This will be in the 0.48 release. You can find a full list of changes that went into 0.47.2 at https://github.com/mesonbuild/meson/milestone/29?closed=1.

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Aug 31, 2018

However, you can use it with git master by doing pip3 install git+https://github.com/mesonbuild/meson

@anthrotype

This comment has been minimized.

Copy link

anthrotype commented Aug 31, 2018

thanks!

@jbicha

This comment has been minimized.

Copy link

jbicha commented Sep 24, 2018

@jpakkane I guess this is where https://bugs.debian.org/909440 came from?

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Sep 24, 2018

Repeating what I said on IRC, pkg-resources is a part of setuptools, and we require setuptools now. No idea why Debian splits that out to its own package and adds it as a dependency to setuptools, but simply depending on setuptools in Debian should be enough.

@mbiebl

This comment has been minimized.

Copy link

mbiebl commented Sep 24, 2018

@nirbheek The comment in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=909440#10 says that meson is not supposed to depend on anything outside of python3. If python(3)-setuptools is required, then such a dependency would need to be added to the package.

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Sep 24, 2018

If python(3)-setuptools is required, then such a dependency would need to be added to the package.

See above, we discussed this requirement before committing this. I commented here to state that @jpakkane has forgotten and commented mistakenly on the Debian bug.

@mbiebl

This comment has been minimized.

Copy link

mbiebl commented Sep 24, 2018

Ah ok. Regarding your remark about "no idea why Debian splits that out to its own package", I only found:

python-setuptools (0.6c8-1) unstable; urgency=low

  * New upstream version. Closes: #467012.
  * Split out a python-pkg-resources package (to be used as a runtime
    dependency instead of python-setuptools).

 -- Matthias Klose <doko@debian.org>  Fri, 29 Feb 2008 01:20:15 +0100

Looking at python3-pkg-resources, it weighs 535K,
python3-setuptools(+dependencies) is 3975K

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Sep 24, 2018

Ah, so setuptools is supposed to be a build-time dependency and pkg-resources a runtime dependency. We don't need the runtime dependency in Meson though.

@mbiebl

This comment has been minimized.

Copy link

mbiebl commented Sep 24, 2018

I think it's the other way around: meson needs only pkg-resources as a runtime dependency, or am I completely confused?

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Sep 24, 2018

Meson doesn't really need the pkg-resources runtime dependency on Linux since we just need to call mesonmain.main(). It is, however, needed on Windows for exe files. I misread the Debian bug and thought the stacktrace was coming from setup.py.

We could quite easily remove the dependency by using entry_points= only on Windows. It would be nice to do that without reinstating the ugly install_scripts hack though.

@mbiebl

This comment has been minimized.

Copy link

mbiebl commented Sep 24, 2018

Well, there is

from pkg_resources import load_entry_point

in /usr/bin/meson, so I guess meson does need pkg-resources at runtime

@nirbheek

This comment has been minimized.

Copy link
Member Author

nirbheek commented Sep 24, 2018

Yes, and that dependency comes from our usage of setuptools entry_points=. Which can be conditional. Since we don't really need it on any platform except Windows.

@jbicha

This comment has been minimized.

Copy link

jbicha commented Sep 24, 2018

@nirbheek Yes, that sounds like my understanding of what @jpakkane wants here.

@albfan

This comment has been minimized.

Copy link

albfan commented Nov 15, 2018

@nirbheek this breaks for me in msys2 msys2/MINGW-packages#4659 @lazka any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.