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

nirbheek
Copy link
Member

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 Compare August 10, 2018 10:54
Copy link
Contributor

@MathieuDuponchelle MathieuDuponchelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
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.

Thanks to Rafael Rivera for the suggestion

Fixes #1877
This gives us a consistent experience and a simpler setup across all
operating systems. Setuptools is available everywhere these days.
@nirbheek
Copy link
Member Author

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
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
Copy link
Member

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

@nirbheek
Copy link
Member Author

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
Copy link
Member

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
Copy link
Member Author

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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

[F401] 'glob.glob' imported but unused

@nirbheek nirbheek force-pushed the nirbheek/console-entrypoint branch 2 times, most recently from b225f25 to f6836f2 Compare August 11, 2018 19:47
self.assertTrue(bindir.is_dir())
self.assertTrue(pylibdir.is_dir())
from setup import packages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

[E271] multiple spaces after keyword

Ensure that the installed files list matches what we expect, to avoid
surprises at release time.
@nirbheek
Copy link
Member Author

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

@nirbheek
Copy link
Member Author

Afair the generated entry point scripts depend on pkg_resources

That module is shipped with setuptools, right?

@jpakkane
Copy link
Member

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
Copy link
Member Author

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
@jpakkane jpakkane deleted the nirbheek/console-entrypoint branch August 11, 2018 21:44
@anthrotype
Copy link

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

@nirbheek
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
Copy link
Member Author

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

@anthrotype
Copy link

thanks!

@jbicha
Copy link

jbicha commented Sep 24, 2018

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

@nirbheek
Copy link
Member Author

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
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
Copy link
Member Author

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
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
Copy link
Member Author

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
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
Copy link
Member Author

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
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
Copy link
Member Author

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
Copy link

jbicha commented Sep 24, 2018

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

@albfan
Copy link
Contributor

albfan commented Nov 15, 2018

@nirbheek this breaks for me in msys2 https://github.com/Alexpux/MINGW-packages/issues/4659 @lazka any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants