repo
stringclasses
32 values
instance_id
stringlengths
13
37
base_commit
stringlengths
40
40
patch
stringlengths
1
1.89M
test_patch
stringclasses
1 value
problem_statement
stringlengths
304
69k
hints_text
stringlengths
0
246k
created_at
stringlengths
20
20
version
stringclasses
1 value
FAIL_TO_PASS
stringclasses
1 value
PASS_TO_PASS
stringclasses
1 value
environment_setup_commit
stringclasses
1 value
traceback
stringlengths
64
23.4k
__index_level_0__
int64
29
19k
ipython/ipython
ipython__ipython-5105
1b14e0b2e7b3991f805351df9b303f79d2bdc5b8
diff --git a/IPython/html/base/handlers.py b/IPython/html/base/handlers.py --- a/IPython/html/base/handlers.py +++ b/IPython/html/base/handlers.py @@ -122,7 +122,7 @@ def get_current_user(self): @property def cookie_name(self): - default_cookie_name = non_alphanum.sub('-', 'username-{}'.format( + default_cookie_name = non_alphanum.sub('-', 'username-{0}'.format( self.request.host )) return self.settings.get('cookie_name', default_cookie_name)
IPython 1.2.0: notebook fail with "500 Internal Server Error" Hi there! I had huge issues after upgrading from IPython 1.1.0 to 1.2.0. I start my notebook-server as follows: ``` $ ipython notebook --pylab --no-browser $APPDIR/lib64/python2.6/site-packages/IPython/frontend.py:30: UserWarning: The top-level `frontend` package has been deprecated. All its subpackages have been moved to the top `IPython` level. warn("The top-level `frontend` package has been deprecated. " 2014-02-12 09:49:04.887 [NotebookApp] Using existing profile dir: u'$MYDIR/.config/ipython/profile_default' 2014-02-12 09:49:04.895 [NotebookApp] Using MathJax from CDN: http://cdn.mathjax.org/mathjax/latest/MathJax.js 2014-02-12 09:49:04.905 [NotebookApp] Serving notebooks from local directory: $MYDIR/notebooks 2014-02-12 09:49:04.905 [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/ 2014-02-12 09:49:04.905 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). ``` (Note that i changed server-specifi paths to $APPDIR and $MYDIR manually in the above output) So far so good. However, after the 1.2.0 upgrade, once I browse to 127.0.0.1:8888, all I see in the browser window is "500: Internal Server Error", while the ipython-process outputs: ``` 127.0.0.1:8888 2014-02-12 09:49:06.172 [tornado.application] ERROR | Uncaught exception GET / (127.0.0.1) HTTPRequest(protocol='http', host='127.0.0.1:8888', method='GET', uri='/', version='HTTP/1.1', remote_ip='127.0.0.1', headers={'Accept-Language': 'en-US,en;q=0.8', 'Accept-Encoding': 'gzip,deflate,sdch', 'Host': '127.0.0.1:8888', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'Connection': 'keep-alive', 'Cache-Control': 'max-age=0'}) Traceback (most recent call last): File "$APPDIR/lib64/python2.6/site-packages/tornado-3.2-py2.6-linux-x86_64.egg/tornado/web.py", line 1218, in _when_complete callback() File "$APPDIR/lib64/python2.6/site-packages/tornado-3.2-py2.6-linux-x86_64.egg/tornado/web.py", line 1239, in _execute_method self._when_complete(method(*self.path_args, **self.path_kwargs), File "$APPDIR/lib64/python2.6/site-packages/tornado-3.2-py2.6-linux-x86_64.egg/tornado/web.py", line 2382, in wrapper if not self.current_user: File "$APPDIR/lib64/python2.6/site-packages/tornado-3.2-py2.6-linux-x86_64.egg/tornado/web.py", line 983, in current_user self._current_user = self.get_current_user() File "$APPDIR/lib64/python2.6/site-packages/IPython/html/base/handlers.py", line 112, in get_current_user user_id = self.get_secure_cookie(self.cookie_name) File "$APPDIR/lib64/python2.6/site-packages/IPython/html/base/handlers.py", line 127, in cookie_name self.request.host ValueError: zero length field name in format 2014-02-12 09:49:06.174 [tornado.access] ERROR | 500 GET / (127.0.0.1) 2.42ms 2014-02-12 09:49:06.187 [tornado.access] WARNING | 404 GET /favicon.ico (127.0.0.1) 0.84ms ``` I tried deleting my ~/.config/ipython dir and upgrading dependency packages. But nothing helped get over this issue. Once I reverted to IPython 1.1.0 everything worked as expected. (This server runs Python 2.6, tornado 3.2 and zmq 4.0.3)
> $APPDIR/lib64/python2.6/site-packages/IPython/frontend.py:30: UserWarning: The top-level `frontend` package has been deprecated. This suggests there's some clash and leftovers from an older IPython are still around. IPython itself no longer references the frontend.py package. Can you make sure that the IPython directory destination is clean before installing into it, so there are no stale .py and .pyc files there. When you install 1.2, can you verify that the terminal version works (just `ipython`). If it does, then see if `ipython console` works - this will test the two-process kernel and frontend decoupling, without bringing the webserver complexities into the mix. This will help us diagnose where the problem is, and please include the output of `import IPython; print IPython.sys_info();` OK, looks like the patch you need is in #5104 - we just need to put it in the 1.x branch
2014-02-12T17:21:22Z
[]
[]
Traceback (most recent call last): File "$APPDIR/lib64/python2.6/site-packages/tornado-3.2-py2.6-linux-x86_64.egg/tornado/web.py", line 1218, in _when_complete callback()
8,201
ipython/ipython
ipython__ipython-525
60e44390599733e4f61846e07fa47fb49ea12dad
diff --git a/IPython/utils/rlineimpl.py b/IPython/utils/rlineimpl.py --- a/IPython/utils/rlineimpl.py +++ b/IPython/utils/rlineimpl.py @@ -9,6 +9,7 @@ boolean and _outputfile variable used in IPython.utils. """ +import os import re import sys import time @@ -44,7 +45,7 @@ def add_history(line): try: _outputfile=_rl.GetOutputFile() except AttributeError: - print "Failed GetOutputFile" + warnings.warn("Failed GetOutputFile") have_readline = False # Test to see if libedit is being used instead of GNU readline. @@ -56,21 +57,36 @@ def add_history(line): # seems to make this better behaved in environments such as PyQt and gdb dt = 1e-3 while dt < 1: - p = Popen(['otool', '-L', _rl.__file__], stdout=PIPE, stderr=PIPE) - otool,err = p.communicate() + try: + p = Popen(['otool', '-L', _rl.__file__], stdout=PIPE, stderr=PIPE) + except OSError: + try: + # otool not available (no XCode), use lsof instead. + # This *could* have a false positive + # if another package that uses libedit explicitly + # has been imported prior to this test. + p = Popen(['lsof', '-p', str(os.getpid())], stdout=PIPE, stderr=PIPE) + except OSError: + # This is highly unlikely, but let's be sure + # we don't crash IPython just because we can't find lsof + p = out = err = None + warnings.warn("libedit detection failed") + break + + out,err = p.communicate() if p.returncode == 4: # EINTR time.sleep(dt) dt *= 2 continue - elif p.returncode: + elif p is None or p.returncode: warnings.warn("libedit detection failed: %s"%err) break else: break - if p.returncode == 0 and re.search(r'/libedit[\.\d+]*\.dylib\s', otool): + if p is not None and p.returncode == 0 and re.search(br'/libedit[\.\d+]*\.dylib\s', out): # we are bound to libedit - new in Leopard _rl.parse_and_bind("bind ^I rl_complete") warnings.warn("Leopard libedit detected - readline will not be well behaved " @@ -79,7 +95,8 @@ def add_history(line): "which is easy_installable with: 'easy_install readline'", RuntimeWarning) uses_libedit = True - + # cleanup names + del dt,p,out,err # the clear_history() function was only introduced in Python 2.4 and is # actually optional in the readline API, so we must explicitly check for its
otool should not be unconditionally called on osx On OSX systems without XCode installed, IPython won't run, crashing with: <pre> Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.2/bin/ipython3", line 10, in <module> launch_new_instance() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/frontend/terminal/ipapp.py", line 662, in launch_new_instance app.start() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/core/application.py", line 219, in start self.initialize() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/core/application.py", line 211, in initialize self.construct() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/frontend/terminal/ipapp.py", line 478, in construct self.shell = TerminalInteractiveShell.instance(config=self.master_config) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/config/configurable.py", line 203, in instance inst = cls(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/frontend/terminal/interactiveshell.py", line 86, in __init__ user_global_ns=user_global_ns, custom_exceptions=custom_exceptions File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/core/interactiveshell.py", line 400, in __init__ self.init_readline() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/core/interactiveshell.py", line 1542, in init_readline import IPython.utils.rlineimpl as readline File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/utils/rlineimpl.py", line 59, in <module> p = Popen(['otool', '-L', _rl.__file__], stdout=PIPE, stderr=PIPE) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 736, in __init__ restore_signals, start_new_session) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 1330, in _execute_child raise child_exception_type(errno_num, err_msg) OSError: [Errno 2] No such file or directory: 'otool' </pre> We need to make the otool call conditional, since XCode is a fairly large dependency that we don't want to require of all our users.
I can detect libedt with lsof, which isn't part of xcode: `'lsof -p %i'%os.getpid()` and check for libedit.*.dylib Note that this doesn't check the readline.so object _directly_, so if another module has linked to libedit and is imported prior to IPython, there will be a false positive.
2011-06-18T23:41:21Z
[]
[]
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.2/bin/ipython3", line 10, in <module> launch_new_instance() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/frontend/terminal/ipapp.py", line 662, in launch_new_instance app.start() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/core/application.py", line 219, in start self.initialize() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/core/application.py", line 211, in initialize self.construct() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/frontend/terminal/ipapp.py", line 478, in construct self.shell = TerminalInteractiveShell.instance(config=self.master_config) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/config/configurable.py", line 203, in instance inst = cls(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/frontend/terminal/interactiveshell.py", line 86, in __init__ user_global_ns=user_global_ns, custom_exceptions=custom_exceptions File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/core/interactiveshell.py", line 400, in __init__ self.init_readline() File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/core/interactiveshell.py", line 1542, in init_readline import IPython.utils.rlineimpl as readline File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/IPython/utils/rlineimpl.py", line 59, in <module> p = Popen(['otool', '-L', _rl.__file__], stdout=PIPE, stderr=PIPE) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 736, in __init__ restore_signals, start_new_session) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 1330, in _execute_child raise child_exception_type(errno_num, err_msg) OSError: [Errno 2] No such file or directory: 'otool'
8,209
ipython/ipython
ipython__ipython-5712
2444facf06f1f2584ac5b6d7d21efde1cfff8463
diff --git a/IPython/core/ultratb.py b/IPython/core/ultratb.py --- a/IPython/core/ultratb.py +++ b/IPython/core/ultratb.py @@ -220,8 +220,17 @@ def findsource(object): return lines, lnum raise IOError('could not find code object') -# Monkeypatch inspect to apply our bugfix. This code only works with Python >= 2.5 -inspect.findsource = findsource +# Monkeypatch inspect to apply our bugfix. +def with_patch_inspect(f): + """decorator for monkeypatching inspect.findsource""" + def wrapped(*args, **kwargs): + save_findsource = inspect.findsource + inspect.findsource = findsource + try: + return f(*args, **kwargs) + finally: + inspect.findsource = save_findsource + return wrapped def fix_frame_records_filenames(records): """Try to fix the filenames in each record from inspect.getinnerframes(). @@ -243,6 +252,7 @@ def fix_frame_records_filenames(records): return fixed_records +@with_patch_inspect def _fixed_getinnerframes(etb, context=1,tb_offset=0): LNUM_POS, LINES_POS, INDEX_POS = 2, 4, 5
inspect.findsource monkeypatch raises wrong exception for C extensions In the following examples, `_yaml` is just a convenient way to specify a C extension that is already in the stdlib. ``` $ python -c 'import inspect, _yaml; print(inspect.findsource(_yaml))' Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/python3.4/inspect.py", line 658, in findsource raise OSError('source code not available') OSError: source code not available $ python -c 'import inspect, IPython, _yaml; print(inspect.findsource(_yaml))' <... traceback omitted ...> SyntaxError: invalid or missing encoding declaration for '/usr/lib/python3.4/site-packages/_yaml.cpython-34m.so' ``` Why is this important? There are now some packages (e.g. astropy) that unconditionally import IPython when they are themselves imported. So, now, if I have my own package which imports astropy (or just IPython, in fact), and also contains some C extension (say `mypackage/foo.so`), then trying to run pydoc on another module in my package that uses the C extension (`pydoc mypackage.bar`, where `bar` imports `foo`) crashes with the uncaught SyntaxError, as (I guess) pydoc only catches an OSError but no SyntaxError when calling `findsource`.
2014-04-23T19:19:23Z
[]
[]
Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/python3.4/inspect.py", line 658, in findsource raise OSError('source code not available') OSError: source code not available
8,236
ipython/ipython
ipython__ipython-5965
781830f225fad7c3186445c86c459f76793e8e4a
diff --git a/IPython/qt/console/frontend_widget.py b/IPython/qt/console/frontend_widget.py --- a/IPython/qt/console/frontend_widget.py +++ b/IPython/qt/console/frontend_widget.py @@ -716,7 +716,7 @@ def _call_tip(self): """ Shows a call tip, if appropriate, at the current cursor location. """ # Decide if it makes sense to show a call tip - if not self.enable_calltips: + if not self.enable_calltips or not self.kernel_client.shell_channel.is_alive(): return False cursor_pos = self._get_input_buffer_cursor_pos() code = self.input_buffer
Traceback on Qt console exit Start the Qt console, and then type `exit` to exit it (closing it from the frontend doesn't exhibit the bug). I see this message, repeated twice: ``` Traceback (most recent call last): File "/home/takluyver/.local/lib/python3.4/site-packages/IPython/qt/console/frontend_widget.py", line 812, in _document_contents_change self._call_tip() File "/home/takluyver/.local/lib/python3.4/site-packages/IPython/qt/console/frontend_widget.py", line 724, in _call_tip msg_id = self.kernel_client.inspect(code, cursor_pos) File "/home/takluyver/.local/lib/python3.4/site-packages/IPython/kernel/channels.py", line 326, in inspect self._queue_send(msg) File "/home/takluyver/.local/lib/python3.4/site-packages/IPython/kernel/channels.py", line 171, in _queue_send self.ioloop.add_callback(thread_send) File "/usr/lib/python3/dist-packages/tornado/ioloop.py", line 732, in add_callback raise RuntimeError("IOLoop is closing") RuntimeError: IOLoop is closing If you suspect this is an IPython bug, please report it at: https://github.com/ipython/ipython/issues or send an email to the mailing list at [email protected] You can print a more detailed traceback right now with "%tb", or use "%debug" to interactively debug it. Extra-detailed tracebacks for bug-reporting purposes can be enabled via: c.Application.verbose_crash=True ```
2014-06-09T22:33:30Z
[]
[]
Traceback (most recent call last): File "/home/takluyver/.local/lib/python3.4/site-packages/IPython/qt/console/frontend_widget.py", line 812, in _document_contents_change self._call_tip() File "/home/takluyver/.local/lib/python3.4/site-packages/IPython/qt/console/frontend_widget.py", line 724, in _call_tip msg_id = self.kernel_client.inspect(code, cursor_pos) File "/home/takluyver/.local/lib/python3.4/site-packages/IPython/kernel/channels.py", line 326, in inspect self._queue_send(msg) File "/home/takluyver/.local/lib/python3.4/site-packages/IPython/kernel/channels.py", line 171, in _queue_send self.ioloop.add_callback(thread_send) File "/usr/lib/python3/dist-packages/tornado/ioloop.py", line 732, in add_callback raise RuntimeError("IOLoop is closing") RuntimeError: IOLoop is closing
8,257
ipython/ipython
ipython__ipython-6302
a68d1d4d494e35d620ff724f8224f02496a6507a
diff --git a/IPython/html/base/zmqhandlers.py b/IPython/html/base/zmqhandlers.py --- a/IPython/html/base/zmqhandlers.py +++ b/IPython/html/base/zmqhandlers.py @@ -109,6 +109,25 @@ def allow_draft76(self): class AuthenticatedZMQStreamHandler(ZMQStreamHandler, IPythonHandler): ping_callback = None + last_pong = 0 + + @property + def ping_interval(self): + """The interval for websocket keep-alive pings. + + Set ws_ping_interval = 0 to disable pings. + """ + return self.settings.get('ws_ping_interval', WS_PING_INTERVAL) + + @property + def ping_timeout(self): + """If no ping is received in this many milliseconds, + close the websocket connection (VPNs, etc. can fail to cleanly close ws connections). + Default is max of 3 pings or 30 seconds. + """ + return self.settings.get('ws_ping_timeout', + max(3 * self.ping_interval, WS_PING_INTERVAL) + ) def set_default_headers(self): """Undo the set_default_headers in IPythonHandler @@ -129,16 +148,30 @@ def open(self, kernel_id): self.session = Session(config=self.config) self.save_on_message = self.on_message self.on_message = self.on_first_message - self.ping_callback = ioloop.PeriodicCallback(self.send_ping, WS_PING_INTERVAL) - self.ping_callback.start() + + # start the pinging + if self.ping_interval > 0: + self.last_pong = ioloop.IOLoop.instance().time() + self.ping_callback = ioloop.PeriodicCallback(self.send_ping, self.ping_interval) + self.ping_callback.start() def send_ping(self): """send a ping to keep the websocket alive""" if self.stream.closed() and self.ping_callback is not None: self.ping_callback.stop() return + + # check for timeout on pong + since_last_pong = 1e3 * (ioloop.IOLoop.instance().time() - self.last_pong) + if since_last_pong > self.ping_timeout: + self.log.warn("WebSocket ping timeout after %i ms.", since_last_pong) + self.close() + return self.ping(b'') + + def on_pong(self, data): + self.last_pong = ioloop.IOLoop.instance().time() def _inject_cookie_message(self, msg): """Inject the first message, which is the document cookie,
Leaking client connections It looks like connections are leaking somehow. I am not using IPython's cluster functionality. ``` ERROR:tornado.application:Exception in callback (<socket._socketobject object at 0x39fcb40>, <function null_wrapper at 0x3a1a848>) Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 833, in start File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 189, in accept_handler File "/usr/lib/python2.7/socket.py", line 202, in accept error: [Errno 24] Too many open files ``` and from `lsof`: ``` python 10008 10018 ubuntu 138u IPv4 174360 0t0 TCP localhost:52318->localhost:43388 (ESTABLISHED) python 10008 10018 ubuntu 139u IPv4 114055 0t0 TCP 10.0.6.245:8888->192.168.200.48:49754 (ESTABLISHED) python 10008 10018 ubuntu 140u 0000 0,9 0 7413 anon_inode python 10008 10018 ubuntu 141u 0000 0,9 0 7413 anon_inode python 10008 10018 ubuntu 142u IPv4 174361 0t0 TCP localhost:35954->localhost:46184 (ESTABLISHED) python 10008 10018 ubuntu 143u IPv4 117290 0t0 TCP 10.0.6.245:8888->192.168.200.48:56788 (ESTABLISHED) python 10008 10018 ubuntu 144u 0000 0,9 0 7413 anon_inode python 10008 10018 ubuntu 145u IPv4 174362 0t0 TCP localhost:38554->localhost:58600 (ESTABLISHED) python 10008 10018 ubuntu 146u IPv4 113877 0t0 TCP 10.0.6.245:8888->192.168.200.48:56793 (ESTABLISHED) python 10008 10018 ubuntu 147u 0000 0,9 0 7413 anon_inode python 10008 10018 ubuntu 148u IPv4 174363 0t0 TCP localhost:34926->localhost:40676 (ESTABLISHED) python 10008 10018 ubuntu 149u IPv4 114072 0t0 TCP 10.0.6.245:8888->192.168.200.48:54334 (ESTABLISHED) python 10008 10018 ubuntu 150u 0000 0,9 0 7413 anon_inode python 10008 10018 ubuntu 151u 0000 0,9 0 7413 anon_inode ```
Not sure if this is helpful, but I am seeing this on Chrome developer console: ``` Kernel started: 288687fd-68c5-4ece-bec6-a0faec14eda82 Starting WebSockets: ws://IP:8888/api/kernels/288687fd-68c5-4ece-bec6-a0faec14eda82 Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state. IP:8888/static/services/kernels/js/kernel.js?v=4f7e3edf038579ed584b87f5c10a24ad:239 WebSocket connection to 'ws://IP:8888/api/kernels/288687fd-68c5-4ece-bec6-a0faec14eda8/iopub' failed: WebSocket is closed before the connection is established. IP:8888/notebooks/git/stuff/Python/stuff/src/Demo%20Segment.ipynb:1 WebSocket connection to 'ws://IP:8888/api/kernels/288687fd-68c5-4ece-bec6-a0faec14eda8/stdin' failed: WebSocket is closed before the connection is established. IP:8888/notebooks/git/stuff/Python/stuff/src/Demo%20Segment.ipynb:1 Starting WebSockets: ws://IP:8888/api/kernels/288687fd-68c5-4ece-bec6-a0faec14eda8 Failed to load resource: net::ERR_CONNECTION_TIMED_OUT http://IP:8888/api/notebooks/git/stuff/Python/stuff/src/Demo%20Segment.ipynb Failed to load resource: net::ERR_NETWORK_CHANGED http://IP:8888/api/notebooks/git/stuff/Python/stuff/src/Demo%20Segment.ipynb Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state. IP:8888/static/services/kernels/js/kernel.js?v=4f7e3edf038579ed584b87f5c10a24ad:239 WebSocket connection to 'ws://IP:8888/api/kernels/288687fd-68c5-4ece-bec6-a0faec14eda8/iopub' failed: WebSocket is closed before the connection is established. IP:8888/notebooks/git/stuff/Python/stuff/src/Demo%20Segment.ipynb:1 WebSocket connection to 'ws://IP:8888/api/kernels/288687fd-68c5-4ece-bec6-a0faec14eda8/stdin' failed: WebSocket is closed before the connection is established. IP:8888/notebooks/git/stuff/Python/stuff/src/Demo%20Segment.ipynb:1 Starting WebSockets: ws://IP:8888/api/kernels/288687fd-68c5-4ece-bec6-a0faec14eda8 ``` Can you describe your usage a bit more (long-lived server, long running notebooks, many open at once, refreshing the page often, etc.)? Also please include `IPython.sys_info()`. `{'commit_hash': 'd87a8cd', 'commit_source': 'installation', 'default_encoding': 'UTF-8', 'ipython_path': '/usr/local/lib/python2.7/dist-packages/IPython', 'ipython_version': '2.2.0', 'os_name': 'posix', 'platform': 'Linux-3.11.0-15-generic-x86_64-with-Ubuntu-13.10-saucy', 'sys_executable': '/usr/bin/python', 'sys_platform': 'linux2', 'sys_version': '2.7.5+ (default, Feb 27 2014, 19:37:08) \n[GCC 4.8.1]'}` It is a long running server and long running notebook. I do refresh the page occasionally when the following happens: https://github.com/ipython/ipython/issues/6186 I am connecting over VPN. This might be related to the VPN connection going down every hour or so. Ah, I bet it is that VPN, then, with the connection never closing cleanly. I think we might be able to handle this with the websocket heartbeat, closing the connection when no heartbeat is received after some timeout.
2014-08-13T18:33:48Z
[]
[]
Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 833, in start File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 189, in accept_handler File "/usr/lib/python2.7/socket.py", line 202, in accept error: [Errno 24] Too many open files
8,272
ipython/ipython
ipython__ipython-6394
53ec866d75bfee912bfb1b192c26bd20a1504c57
diff --git a/IPython/core/displayhook.py b/IPython/core/displayhook.py --- a/IPython/core/displayhook.py +++ b/IPython/core/displayhook.py @@ -2,25 +2,11 @@ """Displayhook for IPython. This defines a callable class that IPython uses for `sys.displayhook`. - -Authors: - -* Fernando Perez -* Brian Granger -* Robert Kern """ -#----------------------------------------------------------------------------- -# Copyright (C) 2008-2011 The IPython Development Team -# Copyright (C) 2001-2007 Fernando Perez <[email protected]> -# -# Distributed under the terms of the BSD License. The full license is in -# the file COPYING, distributed as part of this software. -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. + from __future__ import print_function import sys @@ -32,10 +18,6 @@ from IPython.utils.traitlets import Instance from IPython.utils.warn import warn -#----------------------------------------------------------------------------- -# Main displayhook class -#----------------------------------------------------------------------------- - # TODO: Move the various attributes (cache_size, [others now moved]). Some # of these are also attributes of InteractiveShell. They should be on ONE object # only and the other objects should ask that one object for their values. @@ -168,6 +150,9 @@ def write_format_data(self, format_dict, md_dict=None): md_dict : dict (optional) The metadata dict to be associated with the display data. """ + if 'text/plain' not in format_dict: + # nothing to do + return # We want to print because we want to always make sure we have a # newline, even if all the prompt separators are ''. This is the # standard IPython behavior. @@ -221,6 +206,9 @@ def update_user_ns(self, result): def log_output(self, format_dict): """Log the output.""" + if 'text/plain' not in format_dict: + # nothing to do + return if self.shell.logger.log_output: self.shell.logger.log_write(format_dict['text/plain'], 'output') self.shell.history_manager.output_hist_reprs[self.prompt_count] = \ diff --git a/IPython/core/formatters.py b/IPython/core/formatters.py --- a/IPython/core/formatters.py +++ b/IPython/core/formatters.py @@ -5,25 +5,11 @@ .. inheritance-diagram:: IPython.core.formatters :parts: 3 - -Authors: - -* Robert Kern -* Brian Granger """ -#----------------------------------------------------------------------------- -# Copyright (C) 2010-2011, IPython Development Team. -# -# Distributed under the terms of the Modified BSD License. -# -# The full license is in the file COPYING.txt, distributed with this software. -#----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. -# Stdlib imports import abc import inspect import sys @@ -32,8 +18,8 @@ from IPython.external.decorator import decorator -# Our own imports from IPython.config.configurable import Configurable +from IPython.core.getipython import get_ipython from IPython.lib import pretty from IPython.utils.traitlets import ( Bool, Dict, Integer, Unicode, CUnicode, ObjectName, List, @@ -223,6 +209,18 @@ def format_types(self): # Formatters for specific format types (text, html, svg, etc.) #----------------------------------------------------------------------------- + +def _safe_repr(obj): + """Try to return a repr of an object + + always returns a string, at least. + """ + try: + return repr(obj) + except Exception as e: + return "un-repr-able object (%r)" % e + + class FormatterWarning(UserWarning): """Warning class for errors in formatters""" @@ -234,10 +232,13 @@ def warn_format_error(method, self, *args, **kwargs): except NotImplementedError as e: # don't warn on NotImplementedErrors return None - except Exception as e: - warnings.warn("Exception in %s formatter: %s" % (self.format_type, e), - FormatterWarning, - ) + except Exception: + exc_info = sys.exc_info() + ip = get_ipython() + if ip is not None: + ip.showtraceback(exc_info) + else: + traceback.print_exception(*exc_info) return None if r is None or isinstance(r, self._return_type) or \ (isinstance(r, tuple) and r and isinstance(r[0], self._return_type)): @@ -245,7 +246,7 @@ def warn_format_error(method, self, *args, **kwargs): else: warnings.warn( "%s formatter returned invalid type %s (expected %s) for object: %s" % \ - (self.format_type, type(r), self._return_type, pretty._safe_repr(args[0])), + (self.format_type, type(r), self._return_type, _safe_repr(args[0])), FormatterWarning ) @@ -672,7 +673,7 @@ def _deferred_printers_default(self): def __call__(self, obj): """Compute the pretty representation of the object.""" if not self.pprint: - return pretty._safe_repr(obj) + return repr(obj) else: # This uses use StringIO, as cStringIO doesn't handle unicode. stream = StringIO() diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py --- a/IPython/lib/pretty.py +++ b/IPython/lib/pretty.py @@ -125,49 +125,6 @@ def _repr_pretty_(self, p, cycle): _re_pattern_type = type(re.compile('')) -def _failed_repr(obj, e): - """Render a failed repr, including the exception. - - Tries to get exception and type info - """ - # get exception name - if e.__class__.__module__ in ('exceptions', 'builtins'): - ename = e.__class__.__name__ - else: - ename = '{}.{}'.format( - e.__class__.__module__, - e.__class__.__name__, - ) - # and exception string, which sometimes fails - # (usually due to unicode error message) - try: - estr = str(e) - except Exception: - estr = "unknown" - - # and class name - try: - klass = _safe_getattr(obj, '__class__', None) or type(obj) - mod = _safe_getattr(klass, '__module__', None) - if mod in (None, '__builtin__', 'builtins', 'exceptions'): - classname = klass.__name__ - else: - classname = mod + '.' + klass.__name__ - except Exception: - # this may be paranoid, but we already know repr is broken - classname = "unknown type" - - # the informative repr - return "<repr(<{} at 0x{:x}>) failed: {}: {}>".format( - classname, id(obj), ename, estr, - ) - -def _safe_repr(obj): - """Don't assume repr is not broken.""" - try: - return repr(obj) - except Exception as e: - return _failed_repr(obj, e) def _safe_getattr(obj, attr, default=None): """Safe version of getattr. @@ -560,7 +517,7 @@ def _default_pprint(obj, p, cycle): klass = _safe_getattr(obj, '__class__', None) or type(obj) if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs: # A user-provided repr. Find newlines and replace them with p.break_() - output = _safe_repr(obj) + output = repr(obj) for idx,output_line in enumerate(output.splitlines()): if idx: p.break_() @@ -736,7 +693,7 @@ def _type_pprint(obj, p, cycle): def _repr_pprint(obj, p, cycle): """A pprint that just redirects to the normal repr function.""" - p.text(_safe_repr(obj)) + p.text(repr(obj)) def _function_pprint(obj, p, cycle):
IPython swallows exceptions in repr ### IPython console behavior ``` Python In [1]: class Foo(object): ...: def __repr__(self): ...: raise Exception() ...: In [2]: Foo() Out[2]: <repr(<__main__.Foo at 0x7f50f6bb69d0>) failed: Exception: > ``` ### Normal Python repl behavior ``` Python >>> class Foo(object): ... def __repr__(self): ... raise Exception() ... >>> Foo() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in __repr__ Exception ``` In some cases (particularly the case that I'm dealing with), it'd be nice for IPython to allow this exception to bubble up to the user, rather than just printing it out.
Yeah, it would be much nicer. I didn't notice this strange behavior before, but was able to reproduce it in IPython 3. I did some work in exception formatting code in ipython and I think that I can fix this issue too. Is there anyone thinking that this particular behavior should stay as it is now? I think this is actually a recent fix for protecting IPython from objects that are severely broken. If you call `repr(Foo())`, the exception will just raise. It's just a question of what the IPython display for an object that has no working `__repr__` should be. That code can be changed to include the traceback, but I'm not sure it can be changed to allow the exception to just raise. Printing out the traceback seems like a better visual cue that an error has occured than the current solution. Some users visually parse the current output as the standard output for objects without defined `__repr__`.
2014-09-01T21:47:08Z
[]
[]
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in __repr__ Exception
8,279
ipython/ipython
ipython__ipython-7129
acb3b5751efdacadb994e3b04837b92bf64c9d3f
diff --git a/IPython/kernel/channels.py b/IPython/kernel/channels.py --- a/IPython/kernel/channels.py +++ b/IPython/kernel/channels.py @@ -47,7 +47,7 @@ class HBChannel(Thread): _pause = None _beating = None - def __init__(self, context, session, address): + def __init__(self, context=None, session=None, address=None): """Create the heartbeat monitor thread. Parameters diff --git a/IPython/qt/console/ipython_widget.py b/IPython/qt/console/ipython_widget.py --- a/IPython/qt/console/ipython_widget.py +++ b/IPython/qt/console/ipython_widget.py @@ -280,7 +280,7 @@ def _handle_kernel_info_reply(self, rep): """Handle kernel info replies.""" content = rep['content'] if not self._guiref_loaded: - if content.get('language') == 'python': + if content.get('implementation') == 'ipython': self._load_guiref_magic() self._guiref_loaded = True diff --git a/IPython/qt/console/magic_helper.py b/IPython/qt/console/magic_helper.py --- a/IPython/qt/console/magic_helper.py +++ b/IPython/qt/console/magic_helper.py @@ -95,7 +95,7 @@ def sizeHint(self): self.search_line.textChanged[str].connect( self.search_changed ) - self.search_list.itemDoubleClicked[QtGui.QListWidgetItem].connect( + self.search_list.itemDoubleClicked.connect( self.paste_requested ) self.paste_button.clicked[bool].connect(
PyQt5 qtconsole gives TypeError: __init__() takes exactly 4 arguments (1 given) As reported by @jenshnielsen on the merged pull-request here: https://github.com/ipython/ipython/pull/5458 qtconsole gives an error on PyQt5. ``` QT_API=pyqt5 ipython qtconsole Traceback (most recent call last): File "/Users/jhn/Envs/ipython_master/bin/ipython", line 9, in <module> load_entry_point('ipython==3.0.0-dev', 'console_scripts', 'ipython')() File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 548, in launch_instance app.initialize(argv) File "<string>", line 2, in initialize File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 319, in initialize super(TerminalIPythonApp, self).initialize(argv) File "<string>", line 2, in initialize File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/core/application.py", line 378, in initialize self.parse_command_line(argv) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 314, in parse_command_line return super(TerminalIPythonApp, self).parse_command_line(argv) File "<string>", line 2, in parse_command_line File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 460, in parse_command_line return self.initialize_subcommand(subc, subargv) File "<string>", line 2, in initialize_subcommand File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 398, in initialize_subcommand self.subapp.initialize(argv) File "<string>", line 2, in initialize File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/qt/console/qtconsoleapp.py", line 344, in initialize IPythonConsoleApp.initialize(self,argv) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/consoleapp.py", line 352, in initialize self.init_kernel_client() File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/consoleapp.py", line 339, in init_kernel_client self.kernel_client.start_channels() File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/qt/kernel_mixins.py", line 208, in start_channels super(QtKernelClientMixin, self).start_channels(*args, **kw) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/kernel/client.py", line 109, in start_channels self.shell_channel.start() File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/kernel/client.py", line 153, in shell_channel self.context, self.session, url File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/qt/util.py", line 67, in __new__ QtCore.QObject.__init__(inst) TypeError: __init__() takes exactly 4 arguments (1 given) ``` Having attempted to look into this, it appears the `TypeError` is triggered only by the Qt channel objects: ``` IPython.qt.client.QtIOPubChannel IPython.qt.client.QtShellChannel IPython.qt.client.QtStdInChannel IPython.qt.client.QtHBChannel ``` The behaviour of SuperQObject is a bit beyond me at present. However, wrapping the init that throws the TypeError in a try/except clause (i.e. allowing it to fail) results in it working fine.
As I wrote in #5458, PyQt5 now automatically calls the default init() methods (with no arguments) of all Mixin classes. Some classes are currently not default constructable. I added default inits for the classes required to launch the embedded console, but apparently there are others that need to be adapted for running qtconsole. So at the moment, the PyQt5.QtCore.QObject constructor first calls **init** of Mixin classes with no arguments (which fails if there are additional arguments without default values). Then the SuperQObject continues by calling the **init** methods again and provides the required arguments for proper initialization. Thanks for the clarification @pwuertz I hadn't understood what you meant the first time. I've added default values to the channel **init** e.g. in IPython/kernel/channels.py ``` class HBChannel(ZMQSocketChannel): def __init__(self, context=None, session=None, address=None): ``` ...(repeated for each channel constructor) and this resolves the bug. Is this what you had in mind? I'm happy to do the pull-request if so. Thanks! Yes exactly. We (or the IPython core developers) have to keep in mind though that for PyQt5 the init methods are called two times. This isn't a problem if init just initializes object members. Wait, `__init__` is called twice? I'd rather avoid that if it's practical - even if it works now, it could cause very hard to understand bugs later if someone adds code that doesn't allow that. Yes, because QObject in PyQt5 basically includes the functionality of SuperQObject from IPython. At the time it wasn't clear to me how SuperQObject worked, neither the implicit init calls that originated from PyQt5-QObject. I guess in order to avoid double inits one would have to exclude the init calls within SuperQObject based on the loaded QtApi, and if so, provide **kwargs to QObject.**init** directly since it now handles additional args.. OK, I'm inclined to say that we should actually do that - have a different code path for PyQt5 from the other PyQt APIs. It might be a bit ugly, but I think it's better to record that difference in the code now than try to rediscover it when something breaks further down the line. Do you have time to make a PR? I gave that idea a try but I'm getting really confusing errors. Since I never worked with Python Meta-Classes, the complexity of the Meta-Class, Mixin, Multi-Inheritance structure puzzles me. In order to get to the bottom of this I'm letting SuperQObject print any `__new__` and `__init__` calls. This is what happens: ``` New <class 'IPython.qt.manager.QtKernelManager'> New <class 'IPython.qt.manager.QtKernelRestarter'> New <class 'IPython.qt.client.QtKernelClient'> New <class 'IPython.qt.client.QtShellChannel'> Init <class 'IPython.qt.client.QtShellChannel'> New <class 'IPython.qt.client.QtIOPubChannel'> Init <class 'IPython.qt.client.QtIOPubChannel'> New <class 'IPython.qt.client.QtStdInChannel'> Init <class 'IPython.qt.client.QtStdInChannel'> New <class 'IPython.qt.client.QtHBChannel'> Init <class 'IPython.qt.client.QtHBChannel'> ``` Then the application crashes because the QtKernelClient object is used before calling its `__init__` method. As far as I can see the objects that didn't initialize properly are based on the MetaQObjectHasTraits structure. Switching the order of SuperQObject and HasTraits in MetaQObjectHasTraits seems to get me one step further, but then the Trait-framework raises critical errors.
2014-12-07T23:03:26Z
[]
[]
Traceback (most recent call last): File "/Users/jhn/Envs/ipython_master/bin/ipython", line 9, in <module> load_entry_point('ipython==3.0.0-dev', 'console_scripts', 'ipython')() File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 548, in launch_instance app.initialize(argv) File "<string>", line 2, in initialize File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 319, in initialize super(TerminalIPythonApp, self).initialize(argv) File "<string>", line 2, in initialize File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/core/application.py", line 378, in initialize self.parse_command_line(argv) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 314, in parse_command_line return super(TerminalIPythonApp, self).parse_command_line(argv) File "<string>", line 2, in parse_command_line File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 460, in parse_command_line return self.initialize_subcommand(subc, subargv) File "<string>", line 2, in initialize_subcommand File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 398, in initialize_subcommand self.subapp.initialize(argv) File "<string>", line 2, in initialize File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/config/application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/qt/console/qtconsoleapp.py", line 344, in initialize IPythonConsoleApp.initialize(self,argv) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/consoleapp.py", line 352, in initialize self.init_kernel_client() File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/consoleapp.py", line 339, in init_kernel_client self.kernel_client.start_channels() File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/qt/kernel_mixins.py", line 208, in start_channels super(QtKernelClientMixin, self).start_channels(*args, **kw) File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/kernel/client.py", line 109, in start_channels self.shell_channel.start() File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/kernel/client.py", line 153, in shell_channel self.context, self.session, url File "/Users/jhn/Envs/ipython_master/lib/python2.7/site-packages/IPython/qt/util.py", line 67, in __new__ QtCore.QObject.__init__(inst) TypeError: __init__() takes exactly 4 arguments (1 given)
8,326
ipython/ipython
ipython__ipython-7777
1c1b6d74c98c7e93f7bba64f01acafe81dcc5d57
diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -410,6 +410,20 @@ def _log_format_default(self): ip = Unicode('localhost', config=True, help="The IP address the notebook server will listen on." ) + def _ip_default(self): + """Return localhost if available, 127.0.0.1 otherwise. + + On some (horribly broken) systems, localhost cannot be bound. + """ + s = socket.socket() + try: + s.bind(('localhost', 0)) + except socket.error as e: + self.log.warn("Cannot bind to localhost, using 127.0.0.1 as default ip\n%s", e) + return '127.0.0.1' + else: + s.close() + return 'localhost' def _ip_changed(self, name, old, new): if new == u'*': self.ip = u''
notebook crashes on startup I am using Python 2.7.6 and Ipython 2.2.0 on another computer, I am using IPython 2.1.0 and notebooks work fine when starting up a notebook I get ``` chianti/test> npython 2014-08-25 15:31:43.321 [NotebookApp] Using existing profile dir: u'/home/ken/.ipython/profile_notebook' 2014-08-25 15:31:43.331 [NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js Traceback (most recent call last): File "/usr/bin/ipython", line 5, in <module> start_ipython() File "/usr/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 563, in launch_instance app.initialize(argv) File "<string>", line 2, in initialize File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 320, in initialize super(TerminalIPythonApp, self).initialize(argv) File "<string>", line 2, in initialize File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/core/application.py", line 381, in initialize self.parse_command_line(argv) File "/usr/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 315, in parse_command_line return super(TerminalIPythonApp, self).parse_command_line(argv) File "<string>", line 2, in parse_command_line File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 475, in parse_command_line return self.initialize_subcommand(subc, subargv) File "<string>", line 2, in initialize_subcommand File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 413, in initialize_subcommand self.subapp.initialize(argv) File "<string>", line 2, in initialize File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/html/notebookapp.py", line 771, in initialize self.init_webapp() File "/usr/lib/python2.7/site-packages/IPython/html/notebookapp.py", line 658, in init_webapp self.http_server.listen(port, self.ip) File "/usr/lib/python2.7/site-packages/tornado/tcpserver.py", line 116, in listen sockets = bind_sockets(port, address=address) File "/usr/lib/python2.7/site-packages/tornado/netutil.py", line 89, in bind_sockets sock.bind(sockaddr) File "/usr/lib64/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) error: [Errno 99] Cannot assign requested address ```
Does it work if you do `ipython notebook --ip=127.0.0.1`? this is my email reply to minrk yesterday Yes, it does. Should I always include --ip=127.0.0.1? Did not have to in the past thanks, Le 27 août 2014 à 15:30, kdere [email protected] a écrit : > this is my email reply to minrk yesterday > > Yes, it does. Should I always include --ip=127.0.0.1? Did not have to in the past > > thanks, You can set `c.NotebookApp.ip` in your profile. It might be due to change in logic that allow notebook to work on windows w/ sophos antivirus. The logic to have work « out of the box » is complex, and there a re always incompatible scenario. I guess you fall in one of them where you have to be explicit. Do you have any firewall/antvirus software/proxy ? > — > Reply to this email directly or view it on GitHub. On Wednesday, August 27, 2014 07:39:35 AM Matthias Bussonnier wrote: > Le 27 août 2014 à 15:30, kdere [email protected] a écrit : > > > this is my email reply to minrk yesterday > > > > Yes, it does. Should I always include --ip=127.0.0.1? Did not have to in > > the past > > > > thanks, > > You can set `c.NotebookApp.ip` in your profile. > > It might be due to change in logic that allow notebook to work on windows w/ > sophos antivirus. > > The logic to have work « out of the box » is complex, and there a re always > incompatible scenario. I guess you fall in one of them where you have to be > explicit. > > Do you have any firewall/antvirus software/proxy ? > > > — > > Reply to this email directly or view it on GitHub. > > --- > > Reply to this email directly or view it on GitHub: > https://github.com/ipython/ipython/issues/6355#issuecomment-53581936 My firewall is on my router. IPython 2.1.0 notebooks use: "The IPython Notebook is running at: http://localhost:8888/" Ken @kdere did you get this figured out? with IPython 2.1 I don't have to specify an ip address with IPython 2.2 and 2.3 I need to specify --ip=127.0.0.1 @kdere what do you get if you try: ``` python import socket s = socket.socket() s.bind(('localhost', 0)) ``` running IPython 2.3.0 if I have already set --ip=127.0.0.0 those commands work - well, they don't throw off error messages if not, I get the message that port 8888 is already in use, try another random port
2015-02-13T18:55:44Z
[]
[]
Traceback (most recent call last): File "/usr/bin/ipython", line 5, in <module> start_ipython() File "/usr/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 563, in launch_instance app.initialize(argv) File "<string>", line 2, in initialize File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 320, in initialize super(TerminalIPythonApp, self).initialize(argv) File "<string>", line 2, in initialize File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/core/application.py", line 381, in initialize self.parse_command_line(argv) File "/usr/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 315, in parse_command_line return super(TerminalIPythonApp, self).parse_command_line(argv) File "<string>", line 2, in parse_command_line File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 475, in parse_command_line return self.initialize_subcommand(subc, subargv) File "<string>", line 2, in initialize_subcommand File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 413, in initialize_subcommand self.subapp.initialize(argv) File "<string>", line 2, in initialize File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python2.7/site-packages/IPython/html/notebookapp.py", line 771, in initialize self.init_webapp() File "/usr/lib/python2.7/site-packages/IPython/html/notebookapp.py", line 658, in init_webapp self.http_server.listen(port, self.ip) File "/usr/lib/python2.7/site-packages/tornado/tcpserver.py", line 116, in listen sockets = bind_sockets(port, address=address) File "/usr/lib/python2.7/site-packages/tornado/netutil.py", line 89, in bind_sockets sock.bind(sockaddr) File "/usr/lib64/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) error: [Errno 99] Cannot assign requested address
8,372
ipython/ipython
ipython__ipython-7836
02da130cb4fa7e545854b73e5afa6a4aec7476be
diff --git a/IPython/core/application.py b/IPython/core/application.py --- a/IPython/core/application.py +++ b/IPython/core/application.py @@ -170,9 +170,9 @@ def __init__(self, **kwargs): try: directory = py3compat.getcwd() except: - # raise exception + # exit if cwd doesn't exist self.log.error("Current working directory doesn't exist.") - raise + self.exit(1) #------------------------------------------------------------------------- # Various stages of Application creation
ipython exits with traceback when run in non-existing directory Description of problem: I tried to run ipython3 in a directory, which was already deleted. ipython ended with Traceback. Version-Release number of selected component (if applicable): python3-ipython-2.3.0-1.fc21.noarch How reproducible: always Steps to Reproduce: 1. run ipython3 in non-existing directory Actual results: ``` $ ipython3 [TerminalIPythonApp] ERROR | Current working directory doesn't exist. Traceback (most recent call last): File "/usr/bin/ipython3", line 5, in <module> start_ipython() File "/usr/lib/python3.4/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/usr/lib/python3.4/site-packages/IPython/config/application.py", line 562, in launch_instance app = cls.instance(**kwargs) File "/usr/lib/python3.4/site-packages/IPython/config/configurable.py", line 354, in instance inst = cls(*args, **kwargs) File "<string>", line 2, in __init__ File "/usr/lib/python3.4/site-packages/IPython/config/application.py", line 92, in catch_config_error return method(app, *args, **kwargs) File "/usr/lib/python3.4/site-packages/IPython/core/application.py", line 183, in __init__ directory = py3compat.getcwd() FileNotFoundError: [Errno 2] No such file or directory ``` Expected results: Error message, but no Traceback Forwarded from https://bugzilla.redhat.com/show_bug.cgi?id=1195181.
2015-02-23T14:37:36Z
[]
[]
Traceback (most recent call last): File "/usr/bin/ipython3", line 5, in <module> start_ipython() File "/usr/lib/python3.4/site-packages/IPython/__init__.py", line 120, in start_ipython
8,375
ipython/ipython
ipython__ipython-8008
02c3714e3a369bbd77befa9be1c4a23a25a5e50e
diff --git a/IPython/kernel/multikernelmanager.py b/IPython/kernel/multikernelmanager.py --- a/IPython/kernel/multikernelmanager.py +++ b/IPython/kernel/multikernelmanager.py @@ -161,6 +161,7 @@ def shutdown_all(self, now=False): for kid in kids: self.finish_shutdown(kid) self.cleanup(kid) + self.remove_kernel(kid) @kernel_method def interrupt_kernel(self, kernel_id):
MultiKernelManager.shutdown_all() can't be called twice Currently you can't call `MultiKernelManager.shutdown_all()` twice as the the method does not remove the kernels from the internal `self._kernels` list (or checks that they are still active) and in the second call tries to redo the shutdown for the first round of kernels. Example: ``` python try: from queue import Empty # Py 3 except ImportError: from Queue import Empty # Py 2 from IPython.kernel.multikernelmanager import MultiKernelManager km = MultiKernelManager() km.list_kernel_ids() # -> empty list ret = km.start_kernel() km.list_kernel_ids() # -> has one kernel inside km.shutdown_all() km.list_kernel_ids() # -> has still the kernel inside km.shutdown_all() # raises, as it tries to shutdown the kernel again, but no open soccets are found ``` Error message: ``` Traceback (most recent call last): File "c:\data\external\knitpy\knitpy\knitpyapp.py", line 207, in convert_documents outfilenames = kp.render(document_filename, output=self.export_format) File "c:\data\external\knitpy\knitpy\knitpy.py", line 523, in render self.convert(parsed, md_temp) File "c:\data\external\knitpy\knitpy\knitpy.py", line 195, in convert self._km.shutdown_all() File "C:\portabel\miniconda\envs\ipython\lib\site-packages\IPython\kernel\multikernelmanager.py", line 160, in shutdown_all self.request_shutdown(kid) File "C:\portabel\miniconda\envs\ipython\lib\site-packages\IPython\kernel\multikernelmanager.py", line 33, in wrapped r = method(*args, **kwargs) File "C:\portabel\miniconda\envs\ipython\lib\site-packages\IPython\kernel\manager.py", line 252, in request_shutdown self.session.send(self._control_socket, msg) File "C:\portabel\miniconda\envs\ipython\lib\site-packages\IPython\kernel\zmq\session.py", line 660, in send stream.send_multipart(to_send, copy=copy) AttributeError: 'NoneType' object has no attribute 'send_multipart' ``` Not sure whats the problem is here, but I suspect that either should `cleanup` call `remove_kernel` or that should happen in the loop.
2015-03-09T23:00:28Z
[]
[]
Traceback (most recent call last): File "c:\data\external\knitpy\knitpy\knitpyapp.py", line 207, in convert_documents outfilenames = kp.render(document_filename, output=self.export_format) File "c:\data\external\knitpy\knitpy\knitpy.py", line 523, in render self.convert(parsed, md_temp) File "c:\data\external\knitpy\knitpy\knitpy.py", line 195, in convert self._km.shutdown_all() File "C:\portabel\miniconda\envs\ipython\lib\site-packages\IPython\kernel\multikernelmanager.py", line 160, in shutdown_all self.request_shutdown(kid) File "C:\portabel\miniconda\envs\ipython\lib\site-packages\IPython\kernel\multikernelmanager.py", line 33, in wrapped r = method(*args, **kwargs) File "C:\portabel\miniconda\envs\ipython\lib\site-packages\IPython\kernel\manager.py", line 252, in request_shutdown self.session.send(self._control_socket, msg) File "C:\portabel\miniconda\envs\ipython\lib\site-packages\IPython\kernel\zmq\session.py", line 660, in send stream.send_multipart(to_send, copy=copy) AttributeError: 'NoneType' object has no attribute 'send_multipart'
8,387
ipython/ipython
ipython__ipython-8046
263b743e2d246e934972d912896395e0f092115f
diff --git a/IPython/config/loader.py b/IPython/config/loader.py --- a/IPython/config/loader.py +++ b/IPython/config/loader.py @@ -233,13 +233,26 @@ def _has_section(self, key): def copy(self): return type(self)(dict.copy(self)) + # copy nested config objects + for k, v in self.items(): + if isinstance(v, Config): + new_config[k] = v.copy() + return new_config def __copy__(self): return self.copy() def __deepcopy__(self, memo): - import copy - return type(self)(copy.deepcopy(list(self.items()))) + new_config = type(self)() + for key, value in self.items(): + if isinstance(value, (Config, LazyConfigValue)): + # deep copy config objects + value = copy.deepcopy(value, memo) + elif type(value) in {dict, list, set, tuple}: + # shallow copy plain container traits + value = copy.copy(value) + new_config[key] = value + return new_config def __getitem__(self, key): try:
`Config.__deepcopy__` barfs if it holds a `logging.Logger` that was acquired with `getLogger`. Minimal repro config file for ipython_config.py: ``` c = get_config() # noqa import logging c.Test.arglebargle = logging.getLogger('test') ``` This results in the following stack trace for me on Ubuntu 14.04, IPython 3.0, Python 2.7.6: ``` Traceback (most recent call last): File "/home/ssanderson/.virtualenvs/test/bin/ipython", line 11, in <module> sys.exit(start_ipython()) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 573, in launch_instance app.initialize(argv) File "<string>", line 2, in initialize File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error return method(app, *args, **kwargs) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 321, in initialize super(TerminalIPythonApp, self).initialize(argv) File "<string>", line 2, in initialize File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error return method(app, *args, **kwargs) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/core/application.py", line 377, in initialize self.load_config_file() File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/core/application.py", line 241, in load_config_file path=self.config_file_paths File "<string>", line 2, in load_config_file File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error return method(app, *args, **kwargs) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 542, in load_config_file self.update_config(config) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 391, in update_config newconfig.merge(config) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/loader.py", line 186, in merge to_update[k] = copy.deepcopy(v) File "/usr/lib/python2.7/copy.py", line 174, in deepcopy y = copier(memo) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/loader.py", line 241, in __deepcopy__ return type(self)(copy.deepcopy(list(self.items()))) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 230, in _deepcopy_list y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 237, in _deepcopy_tuple y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 230, in _deepcopy_list y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 19 # noqa # noqa 0, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 329, in _reconstruct y = callable(*args) File "/home/ssanderson/.virtualenvs/test/lib/python2.7/copy_reg.py", line 93, in __newobj__ return cls.__new__(cls, *args) TypeError: object.__new__(thread.lock) is not safe, use thread.lock.__new__() ``` Interestingly, it doesn't barf on the following config file: ``` c = get_config() import logging c.Test.arglebargle = logging.Logger('test') ```
Also notable: this fails differently on Python 3.4. ``` (jupyterhub)[~/quantopian/qexec]@(error_messages:77e951ab70)$ ipython --profile test Traceback (most recent call last): File "/home/ssanderson/.virtualenvs/jupyterhub/bin/ipython", line 11, in <module> sys.exit(start_ipython()) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/config/application.py", line 573, in launch_instance app.initialize(argv) File "<string>", line 2, in initialize File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/config/application.py", line 75, in catch_config_error return method(app, *args, **kwargs) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/terminal/ipapp.py", line 321, in initialize super(TerminalIPythonApp, self).initialize(argv) File "<string>", line 2, in initialize File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/config/application.py", line 75, in catch_config_error return method(app, *args, **kwargs) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/core/application.py", line 377, in initialize self.load_config_file() File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/core/application.py", line 241, in load_config_file path=self.config_file_paths File "<string>", line 2, in load_config_file File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/config/application.py", line 75, in catch_config_error return method(app, *args, **kwargs) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/config/application.py", line 542, in load_config_file self.update_config(config) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/config/application.py", line 391, in update_config newconfig.merge(config) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/config/loader.py", line 186, in merge to_update[k] = copy.deepcopy(v) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 166, in deepcopy y = copier(memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/site-packages/IPython/config/loader.py", line 241, in __deepcopy__ return type(self)(copy.deepcopy(list(self.items()))) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 155, in deepcopy y = copier(x, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 219, in _deepcopy_list y.append(deepcopy(a, memo)) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 155, in deepcopy y = copier(x, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 226, in _deepcopy_tuple y.append(deepcopy(a, memo)) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 300, in _reconstruct state = deepcopy(state, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 155, in deepcopy y = copier(x, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 246, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 300, in _reconstruct state = deepcopy(state, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 155, in deepcopy y = copier(x, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 246, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 155, in deepcopy y = copier(x, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 246, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 300, in _reconstruct state = deepcopy(state, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 155, in deepcopy y = copier(x, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 246, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 155, in deepcopy y = copier(x, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 219, in _deepcopy_list y.append(deepcopy(a, memo)) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 300, in _reconstruct state = deepcopy(state, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 155, in deepcopy y = copier(x, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 246, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/home/ssanderson/.virtualenvs/jupyterhub/lib/python3.4/copy.py", line 174, in deepcopy rv = reductor(2) TypeError: cannot serialize '_io.TextIOWrapper' object ```
2015-03-13T20:43:10Z
[]
[]
Traceback (most recent call last): File "/home/ssanderson/.virtualenvs/test/bin/ipython", line 11, in <module> sys.exit(start_ipython()) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 573, in launch_instance app.initialize(argv) File "<string>", line 2, in initialize File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error return method(app, *args, **kwargs) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 321, in initialize super(TerminalIPythonApp, self).initialize(argv) File "<string>", line 2, in initialize File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error return method(app, *args, **kwargs) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/core/application.py", line 377, in initialize self.load_config_file() File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/core/application.py", line 241, in load_config_file path=self.config_file_paths File "<string>", line 2, in load_config_file File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error return method(app, *args, **kwargs) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 542, in load_config_file self.update_config(config) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/application.py", line 391, in update_config newconfig.merge(config) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/loader.py", line 186, in merge to_update[k] = copy.deepcopy(v) File "/usr/lib/python2.7/copy.py", line 174, in deepcopy y = copier(memo) File "/home/ssanderson/.virtualenvs/test/local/lib/python2.7/site-packages/IPython/config/loader.py", line 241, in __deepcopy__ return type(self)(copy.deepcopy(list(self.items()))) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 230, in _deepcopy_list y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 237, in _deepcopy_tuple y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 230, in _deepcopy_list y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 19 # noqa # noqa 0, in deepcopy
8,390
ipython/ipython
ipython__ipython-8048
263b743e2d246e934972d912896395e0f092115f
diff --git a/IPython/qt/console/magic_helper.py b/IPython/qt/console/magic_helper.py --- a/IPython/qt/console/magic_helper.py +++ b/IPython/qt/console/magic_helper.py @@ -131,9 +131,7 @@ def populate_magic_helper(self, data): self.search_class.clear() self.search_list.clear() - self.data = json.loads( - data['data'].get('application/json', {}) - ) + self.data = data['data'].get('application/json', {}) self.search_class.addItem('All Magics', 'any') classes = set()
Non-string argument to json.loads in the magic menu of the QtConsole I get the following error whenever I click on "Show Magics" in the Magic menu of the IPython QtConsole (IPython 3.1.0-dev on Python 2.7.6). <pre><code> Traceback (most recent call last): File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/base_frontend_mixin.py", line 138, in _dispatch handler(msg) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/ipython_widget.py", line 188, in _handle_execute_reply super(IPythonWidget, self)._handle_execute_reply(msg) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/frontend_widget.py", line 452, in _handle_execute_reply self._handle_exec_callback(msg) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/frontend_widget.py", line 417, in _handle_exec_callback self._callback_dict.pop(expression)(user_exp[expression]) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/mainwindow.py", line 741, in _handle_data self.magic_helper.populate_magic_helper(data) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/magic_helper.py", line 135, in populate_magic_helper data['data'].get('application/json', {}) File "/Users/rosborn/Applications/Canopy.app/appdata/canopy-1.5.2.2785.macosx-x86_64/Canopy.app/Contents/lib/python2.7/json/__init__.py", line 338, in loads return _default_decoder.decode(s) File "/Users/rosborn/Applications/Canopy.app/appdata/canopy-1.5.2.2785.macosx-x86_64/Canopy.app/Contents/lib/python2.7/json/decoder.py", line 365, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) TypeError: expected string or buffer </code></pre> According to the json documentation, `json.loads` is meant to have a string argument, but `mdict = json.loads(display_data['data'].get('application/json', {}))` passes a dictionary. Should there be a call to json.dumps first? I'm puzzled because I think this code has been in there for a while, but I only just started getting these errors.
2015-03-13T21:05:38Z
[]
[]
Traceback (most recent call last): File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/base_frontend_mixin.py", line 138, in _dispatch handler(msg) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/ipython_widget.py", line 188, in _handle_execute_reply super(IPythonWidget, self)._handle_execute_reply(msg) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/frontend_widget.py", line 452, in _handle_execute_reply self._handle_exec_callback(msg) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/frontend_widget.py", line 417, in _handle_exec_callback self._callback_dict.pop(expression)(user_exp[expression]) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/mainwindow.py", line 741, in _handle_data self.magic_helper.populate_magic_helper(data) File "/Users/rosborn/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/qt/console/magic_helper.py", line 135, in populate_magic_helper data['data'].get('application/json', {}) File "/Users/rosborn/Applications/Canopy.app/appdata/canopy-1.5.2.2785.macosx-x86_64/Canopy.app/Contents/lib/python2.7/json/__init__.py", line 338, in loads return _default_decoder.decode(s) File "/Users/rosborn/Applications/Canopy.app/appdata/canopy-1.5.2.2785.macosx-x86_64/Canopy.app/Contents/lib/python2.7/json/decoder.py", line 365, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) TypeError: expected string or buffer
8,391
ipython/ipython
ipython__ipython-9186
2bcf17f100da03eee4245e95ab080a31fd912b62
diff --git a/tools/gh_api.py b/tools/gh_api.py --- a/tools/gh_api.py +++ b/tools/gh_api.py @@ -64,6 +64,13 @@ def get_auth_token(): } response = requests.post('https://api.github.com/authorizations', auth=(user, pw), data=json.dumps(auth_request)) + if response.status_code == 401 and response.headers.get('X-GitHub-OTP') == 'required; sms': + print("Your login API resquest a SMS one time password") + sms_pw = getpass.getpass("SMS password: ") + response = requests.post('https://api.github.com/authorizations', + auth=(user, pw), + data=json.dumps(auth_request), + headers={'X-GitHub-OTP':sms_pw}) response.raise_for_status() token = json.loads(response.text)['token'] keyring.set_password('github', fake_username, token)
tools/github_stats fails on 2fa. ``` $ python tools/github_stats.py --milestone 4.1 --since-tag 4.0.0 no cache fetching GitHub stats since 2015-08-12 00:00:00 (tag: 4.0.0, milestone: 4.1) Please enter your github username and password. These are not stored, only used to get an oAuth token. You can revoke this at any time on Github. Username: ***** Password:***** Traceback (most recent call last): File "github_stats.py", line 165, in <module> auth=True) File "/Users/bussonniermatthias/dev/ipython/tools/gh_api.py", line 175, in get_milestone_id milestones = get_milestones(project, auth=auth, **params) File "/Users/bussonniermatthias/dev/ipython/tools/gh_api.py", line 168, in get_milestones headers = make_auth_header() File "/Users/bussonniermatthias/dev/ipython/tools/gh_api.py", line 73, in make_auth_header return {'Authorization': 'token ' + get_auth_token()} File "/Users/bussonniermatthias/dev/ipython/tools/gh_api.py", line 67, in get_auth_token response.raise_for_status() File "/Users/bussonniermatthias/anaconda3/lib/python3.5/site-packages/requests/models.py", line 840, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.github.com/authorizations ```
I will tackle this one in a couple of hours with @parleur.
2016-01-27T17:23:09Z
[]
[]
Traceback (most recent call last): File "github_stats.py", line 165, in <module> auth=True) File "/Users/bussonniermatthias/dev/ipython/tools/gh_api.py", line 175, in get_milestone_id milestones = get_milestones(project, auth=auth, **params) File "/Users/bussonniermatthias/dev/ipython/tools/gh_api.py", line 168, in get_milestones headers = make_auth_header() File "/Users/bussonniermatthias/dev/ipython/tools/gh_api.py", line 73, in make_auth_header return {'Authorization': 'token ' + get_auth_token()} File "/Users/bussonniermatthias/dev/ipython/tools/gh_api.py", line 67, in get_auth_token response.raise_for_status() File "/Users/bussonniermatthias/anaconda3/lib/python3.5/site-packages/requests/models.py", line 840, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.github.com/authorizations
8,439
ipython/ipython
ipython__ipython-9527
d675411b2d81fafe438dbcc14fdb9e5659fac839
diff --git a/IPython/terminal/ptshell.py b/IPython/terminal/ptshell.py --- a/IPython/terminal/ptshell.py +++ b/IPython/terminal/ptshell.py @@ -134,6 +134,7 @@ def init_term_title(self, change=None): toggle_set_term_title(False) def init_prompt_toolkit_cli(self): + self._app = None if self.simple_prompt: # Fall back to plain non-interactive output for tests. # This is very limited, and only accepts a single line. @@ -282,7 +283,8 @@ def _update_layout(self): Ask for a re computation of the application layout, if for example , some configuration options have changed. """ - self._app.layout = create_prompt_layout(**self._layout_options()) + if self._app: + self._app.layout = create_prompt_layout(**self._layout_options()) def prompt_for_code(self): document = self.pt_cli.run(
Cannot load IPython extension with --simple-prompt Mostly mean you cannot test IPython extensions like @asmeurer iterm2-tools, as as soon as you're not in a tty this fails. ``` $ ipython --ext=iterm2_tools.ipython --simple-prompt Python 3.5.1 |Anaconda custom (x86_64)| (default, Dec 7 2015, 11:24:55) Type "copyright", "credits" or "license" for more information. IPython 5.0.0.dev -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. [TerminalIPythonApp] WARNING | Error in loading extension: iterm2_tools.ipython Check your config files in /Users/bussonniermatthias/.ipython/profile_default Traceback (most recent call last): File "/Users/bussonniermatthias/dev/ipython/IPython/core/shellapp.py", line 246, in init_extensions self.shell.extension_manager.load_extension(ext) File "/Users/bussonniermatthias/dev/ipython/IPython/core/extensions.py", line 85, in load_extension if self._call_load_ipython_extension(mod): File "/Users/bussonniermatthias/dev/ipython/IPython/core/extensions.py", line 132, in _call_load_ipython_extension mod.load_ipython_extension(self.shell) File "/Users/bussonniermatthias/dev/iterm2-tools/iterm2_tools/ipython.py", line 108, in load_ipython_extension load_ipython_extension_prompt_toolkit(ipython) File "/Users/bussonniermatthias/dev/iterm2-tools/iterm2_tools/ipython.py", line 140, in load_ipython_extension_prompt_toolkit ipython.prompts = wrap_prompts_class(Prompts)(ipython) File "/Users/bussonniermatthias/dev/traitlets/traitlets/traitlets.py", line 567, in __set__ self.set(obj, value) File "/Users/bussonniermatthias/dev/traitlets/traitlets/traitlets.py", line 556, in set obj._notify_trait(self.name, old_value, new_value) File "/Users/bussonniermatthias/dev/traitlets/traitlets/traitlets.py", line 1102, in _notify_trait 'type': 'change', File "/Users/bussonniermatthias/dev/traitlets/traitlets/traitlets.py", line 1136, in notify_change c(change) File "/Users/bussonniermatthias/dev/ipython/IPython/terminal/ptshell.py", line 110, in _ self._update_layout() File "/Users/bussonniermatthias/dev/ipython/IPython/terminal/ptshell.py", line 285, in _update_layout self._app.layout = create_prompt_layout(**self._layout_options()) AttributeError: 'TerminalInteractiveShell' object has no attribute '_app' ```
It's not that loading extensions fails, it's that trying to manipulate the prompt toolkit stuff fails. Which is not really a surprise, given that simple-prompt disables that machinery.
2016-06-02T17:24:36Z
[]
[]
Traceback (most recent call last): File "/Users/bussonniermatthias/dev/ipython/IPython/core/shellapp.py", line 246, in init_extensions self.shell.extension_manager.load_extension(ext) File "/Users/bussonniermatthias/dev/ipython/IPython/core/extensions.py", line 85, in load_extension if self._call_load_ipython_extension(mod): File "/Users/bussonniermatthias/dev/ipython/IPython/core/extensions.py", line 132, in _call_load_ipython_extension mod.load_ipython_extension(self.shell) File "/Users/bussonniermatthias/dev/iterm2-tools/iterm2_tools/ipython.py", line 108, in load_ipython_extension load_ipython_extension_prompt_toolkit(ipython) File "/Users/bussonniermatthias/dev/iterm2-tools/iterm2_tools/ipython.py", line 140, in load_ipython_extension_prompt_toolkit ipython.prompts = wrap_prompts_class(Prompts)(ipython) File "/Users/bussonniermatthias/dev/traitlets/traitlets/traitlets.py", line 567, in __set__ self.set(obj, value) File "/Users/bussonniermatthias/dev/traitlets/traitlets/traitlets.py", line 556, in set obj._notify_trait(self.name, old_value, new_value) File "/Users/bussonniermatthias/dev/traitlets/traitlets/traitlets.py", line 1102, in _notify_trait 'type': 'change', File "/Users/bussonniermatthias/dev/traitlets/traitlets/traitlets.py", line 1136, in notify_change c(change) File "/Users/bussonniermatthias/dev/ipython/IPython/terminal/ptshell.py", line 110, in _ self._update_layout() File "/Users/bussonniermatthias/dev/ipython/IPython/terminal/ptshell.py", line 285, in _update_layout self._app.layout = create_prompt_layout(**self._layout_options()) AttributeError: 'TerminalInteractiveShell' object has no attribute '_app'
8,455
ipython/ipython
ipython__ipython-9833
99d29c2d556b9889b5040874e5e673ae2e5a032a
diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py --- a/IPython/terminal/interactiveshell.py +++ b/IPython/terminal/interactiveshell.py @@ -74,11 +74,17 @@ def get_default_editor(): else: return 'notepad' # same in Windows! - -if sys.stdin and sys.stdout and sys.stderr: - _is_tty = (sys.stdin.isatty()) and (sys.stdout.isatty()) and (sys.stderr.isatty()) +# conservatively check for tty +# overridden streams can result in things like: +# - sys.stdin = None +# - no isatty method +for _name in ('stdin', 'stdout', 'stderr'): + _stream = getattr(sys, _name) + if not _stream or not hasattr(_stream, 'isatty') or not _stream.isatty(): + _is_tty = False + break else: - _is_tty = False + _is_tty = True _use_simple_prompt = ('IPY_TEST_SIMPLE_PROMPT' in os.environ) or (not _is_tty)
AttributeError: 'StreamLogger' object has no attribute 'isatty' OS: macOS 10.11.6 Python version: Python 2.7.10 ipython version: IPython 5.0.0 Scrapy project with settings: `LOG_STDOUT = True` which redirects stdout to log ``` Traceback (most recent call last): File "/Library/Python/2.7/site-packages/scrapy/utils/defer.py", line 102, in iter_errback yield next(it) File "/Library/Python/2.7/site-packages/scrapy_splash/middleware.py", line 156, in process_spider_output for el in result: File "/Library/Python/2.7/site-packages/scrapy/spidermiddlewares/offsite.py", line 29, in process_spider_output for x in result: File "/Library/Python/2.7/site-packages/scrapy/spidermiddlewares/referer.py", line 22, in <genexpr> return (_set_referer(r) for r in result or ()) File "/Library/Python/2.7/site-packages/scrapy/spidermiddlewares/urllength.py", line 37, in <genexpr> return (r for r in result or () if _filter(r)) File "/Library/Python/2.7/site-packages/scrapy/spidermiddlewares/depth.py", line 58, in <genexpr> return (r for r in result or () if _filter(r)) File "/Users/mini/PycharmProjects/spider_demo/spider_demo/spiders/baidu_news.py", line 42, in parse inspect_response(response, self) File "/Library/Python/2.7/site-packages/scrapy/shell.py", line 157, in inspect_response Shell(spider.crawler).start(response=response) File "/Library/Python/2.7/site-packages/scrapy/shell.py", line 80, in start banner=self.vars.pop('banner', '')) File "/Library/Python/2.7/site-packages/scrapy/utils/console.py", line 75, in start_python_console shell = get_shell_embed_func(shells) File "/Library/Python/2.7/site-packages/scrapy/utils/console.py", line 63, in get_shell_embed_func return known_shells[shell]() File "/Library/Python/2.7/site-packages/scrapy/utils/console.py", line 7, in _embed_ipython_shell from IPython.terminal.embed import InteractiveShellEmbed File "/Library/Python/2.7/site-packages/IPython/__init__.py", line 49, in <module> from .terminal.embed import embed File "/Library/Python/2.7/site-packages/IPython/terminal/embed.py", line 17, in <module> from IPython.terminal.interactiveshell import TerminalInteractiveShell File "/Library/Python/2.7/site-packages/IPython/terminal/interactiveshell.py", line 77, in <module> _is_tty = (sys.stdin.isatty()) and (sys.stdout.isatty()) and (sys.stderr.isatty()) AttributeError: 'StreamLogger' object has no attribute 'isatty' ```
2016-08-03T09:36:07Z
[]
[]
Traceback (most recent call last): File "/Library/Python/2.7/site-packages/scrapy/utils/defer.py", line 102, in iter_errback yield next(it) File "/Library/Python/2.7/site-packages/scrapy_splash/middleware.py", line 156, in process_spider_output for el in result: File "/Library/Python/2.7/site-packages/scrapy/spidermiddlewares/offsite.py", line 29, in process_spider_output for x in result: File "/Library/Python/2.7/site-packages/scrapy/spidermiddlewares/referer.py", line 22, in <genexpr> return (_set_referer(r) for r in result or ()) File "/Library/Python/2.7/site-packages/scrapy/spidermiddlewares/urllength.py", line 37, in <genexpr> return (r for r in result or () if _filter(r)) File "/Library/Python/2.7/site-packages/scrapy/spidermiddlewares/depth.py", line 58, in <genexpr> return (r for r in result or () if _filter(r)) File "/Users/mini/PycharmProjects/spider_demo/spider_demo/spiders/baidu_news.py", line 42, in parse inspect_response(response, self) File "/Library/Python/2.7/site-packages/scrapy/shell.py", line 157, in inspect_response Shell(spider.crawler).start(response=response) File "/Library/Python/2.7/site-packages/scrapy/shell.py", line 80, in start banner=self.vars.pop('banner', '')) File "/Library/Python/2.7/site-packages/scrapy/utils/console.py", line 75, in start_python_console shell = get_shell_embed_func(shells) File "/Library/Python/2.7/site-packages/scrapy/utils/console.py", line 63, in get_shell_embed_func return known_shells[shell]() File "/Library/Python/2.7/site-packages/scrapy/utils/console.py", line 7, in _embed_ipython_shell from IPython.terminal.embed import InteractiveShellEmbed File "/Library/Python/2.7/site-packages/IPython/__init__.py", line 49, in <module> from .terminal.embed import embed File "/Library/Python/2.7/site-packages/IPython/terminal/embed.py", line 17, in <module> from IPython.terminal.interactiveshell import TerminalInteractiveShell File "/Library/Python/2.7/site-packages/IPython/terminal/interactiveshell.py", line 77, in <module> _is_tty = (sys.stdin.isatty()) and (sys.stdout.isatty()) and (sys.stderr.isatty()) AttributeError: 'StreamLogger' object has no attribute 'isatty'
8,480
ipython/ipython
ipython__ipython-9965
410b13bc1ff5c97f5a0ac160185b4f5ce480635c
diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -227,10 +227,14 @@ def __init__(self, color_scheme=None, completekey=None, self.shell = get_ipython() if self.shell is None: + save_main = sys.modules['__main__'] # No IPython instance running, we must create one from IPython.terminal.interactiveshell import \ TerminalInteractiveShell self.shell = TerminalInteractiveShell.instance() + # needed by any code which calls __import__("__main__") after + # the debugger was entered. See also #9941. + sys.modules['__main__'] = save_main if color_scheme is not None: warnings.warn(
Using the IPython debugger in a unittest fails to continue The new tab completion with IPython 5 is great! My congratulations, I really do not want to miss that again. Not even in the debugger --- where I discovered the following behaviour: To my understanding IPython 5.1.0 allows debugging with tab completion by inserting the following line `from IPython.terminal.debugger import TerminalPdb ;TerminalPdb().set_trace()` (see also #9940). However, when doing so in the script below and simply hitting `c` for continue, it will exit with an attribute error: ``` Traceback (most recent call last): File "../snippets/test_ipython_debugger_in_unittest.py", line 21, in <module> if __name__ == '__main__': File "/usr/lib/python3.4/unittest/main.py", line 92, in __init__ self.parseArgs(argv) File "/usr/lib/python3.4/unittest/main.py", line 139, in parseArgs self.createTests() File "/usr/lib/python3.4/unittest/main.py", line 146, in createTests self.module) File "/usr/lib/python3.4/unittest/loader.py", line 146, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python3.4/unittest/loader.py", line 146, in <listcomp> suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python3.4/unittest/loader.py", line 114, in loadTestsFromName parent, obj = obj, getattr(obj, part) AttributeError: 'module' object has no attribute 'suite' ``` Using `import pdb; pdb.set_trace()` (commented line in code below) in contrast continues as expected (without exception). --- ``` python import unittest class ATest(unittest.TestCase): def test_true(self): self.assertTrue(True) def suite(): return unittest.makeSuite(ATest, 'test_') from IPython.terminal.debugger import TerminalPdb; TerminalPdb().set_trace() #import pdb; pdb.set_trace() if __name__ == '__main__': unittest.main(defaultTest='suite') ```
Update: I looked into this again (and also slightly updated the description). The problem is triggered by line 62 of /usr/lib/python3.4/unittest/main.py: `self.module = __import__(module)`, with module = `"__main__"`. Now running the example (of the issue description) with pdb set_trace() I get at the debugger prompt: ``` (Pdb) __import__("__main__") <module '__main__' from '../snippets/test_ipython_debugger_in_unittest.py'> (Pdb) dir(__import__("__main__")) ['ATest', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'pdb', 'suite', 'unittest'] ``` This is actually what I would expect. Doing the same with the IPython set_trace, I get at the debugger prompt: ``` ipdb> __import__("__main__") <module '__main__'> ipdb> dir(__import__("__main__")) ['In', 'Out', '_', '__', '___', '__builtin__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '_dh', '_ih', '_oh', '_sh', 'exit', 'get_ipython', 'quit'] ``` That's interesting all imports the test class and suite is missing. That means `"__main__"` is something IPython specific. This is not rolled back, and so unittest will fail as described above. Actually I can locally workaround / fix this issue by the following command from the command prompt. ``` ipdb> import sys, os; sys.modules["__main__"] = __import__(os.path.basename(__file__.replace(".py",""))) ``` That is: For me it looks like, that the IPython `"__main__"` logic needs to be closed / rolled back / finished / teardowned as soon as the ipdb command prompt is hit. Does it work if you restore `__main__` like this after starting the debugger? ``` python save_main = sys.modules['__main__'] TerminalPdb().set_trace() sys.modules['__main__'] = save_main ``` Thank you for taking your time and looking into this issue! I tried your solution and yes, this works also. I did the same experiment with `IPython.core.debugger.Pdb` and it shows exactly the same behaviour and it is also resolved by this solution. Does it make sense to do save_main at the very beginning of the `IPython.core.debugger.Pdb` class and restore it just before `Pdb.set_trace`? Possibly [this branch](https://github.com/ipython/ipython/blob/3ad65eb369cd8aa05c17a85e761fe8ab54558295/IPython/core/debugger.py#L229), which it takes when IPython is not running, should save `__main__` and restore it just after creating the TerminalInteractiveShell instance. It would be better if it could initialise as much of IPython as it needs without IPython modifying `sys.modules`, but I suspect that making that work cleanly would take a bit more time and effort.
2016-09-22T19:27:09Z
[]
[]
Traceback (most recent call last): File "../snippets/test_ipython_debugger_in_unittest.py", line 21, in <module> if __name__ == '__main__': File "/usr/lib/python3.4/unittest/main.py", line 92, in __init__ self.parseArgs(argv) File "/usr/lib/python3.4/unittest/main.py", line 139, in parseArgs self.createTests() File "/usr/lib/python3.4/unittest/main.py", line 146, in createTests self.module) File "/usr/lib/python3.4/unittest/loader.py", line 146, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python3.4/unittest/loader.py", line 146, in <listcomp> suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python3.4/unittest/loader.py", line 114, in loadTestsFromName parent, obj = obj, getattr(obj, part) AttributeError: 'module' object has no attribute 'suite'
8,485
jupyterlab/jupyterlab
jupyterlab__jupyterlab-14482
19050c7b816bb4dd412a4bed94aee7a34050e5f4
diff --git a/jupyterlab/upgrade_extension.py b/jupyterlab/upgrade_extension.py --- a/jupyterlab/upgrade_extension.py +++ b/jupyterlab/upgrade_extension.py @@ -7,6 +7,7 @@ import shutil import subprocess import sys +from typing import Optional try: import tomllib @@ -25,9 +26,6 @@ msg = "Please install copier and jinja2-time" raise RuntimeError(msg) from None - -DEFAULT_COPIER_TAG = "v4.0.0" - # List of files recommended to be overridden RECOMMENDED_TO_OVERRIDE = [ ".github/workflows/binder-on-pr.yml", @@ -59,13 +57,13 @@ def update_extension( # noqa - target: str, vcs_ref: str = DEFAULT_COPIER_TAG, interactive: bool = True + target: str, vcs_ref: Optional[str] = None, interactive: bool = True ) -> None: """Update an extension to the current JupyterLab target: str Path to the extension directory containing the extension - vcs_ref: str [default: DEFAULT_COPIER_TAG] + vcs_ref: str [default: None] Template vcs_ref to checkout interactive: bool [default: true] Whether to ask before overwriting content @@ -261,6 +259,8 @@ def update_extension( # noqa requirements_raw.splitlines(), ) ) + else: + requirements = [] pyproject["project"]["dependencies"] = ( pyproject["project"].get("dependencies", []) + requirements @@ -301,9 +301,7 @@ def update_extension( # noqa parser.add_argument("path", action="store", type=str, help="the target path") - parser.add_argument( - "--vcs-ref", help="the template hash to checkout", default=DEFAULT_COPIER_TAG - ) + parser.add_argument("--vcs-ref", help="the template hash to checkout", default=None) args = parser.parse_args()
upgrade_extension breaks if setup.cfg has no requirements ## Description If `python -m jupyterlab.upgrade_extension .` is called in an extension directory that has a `setup.cfg` that has no `install_requires` entry (e.g. if `setup.py` has the dependencies instead), and the user chooses to overwrite `pyproject.toml`, the script fails with the following error: ```bash $ python -m jupyterlab.upgrade_extension . ...a few lines omitted... Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/home/pdmurray/.pyenv/versions/ksmm/lib/python3.11/site-packages/jupyterlab/upgrade_extension.py", line 324, in <module> update_extension(args.path, args.branch, args.no_input is False) File "/home/pdmurray/.pyenv/versions/ksmm/lib/python3.11/site-packages/jupyterlab/upgrade_extension.py", line 280, in update_extension pyproject["project"].get("dependencies", []) + requirements ^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'requirements' where it is not associated with a value ``` ## Reproduce To reproduce, try running `python -m jupyterlab.upgrade_extension .` inside [this](https://github.com/deshaw/ksmm) repo. ## Expected behavior The upgrade completes without failing. ## Context <!--Complete the following for context, and add any other relevant context--> Python 3.11.2. ``` Selected Jupyter core packages... IPython : 8.12.0 ipykernel : 6.22.0 ipywidgets : not installed jupyter_client : 8.2.0 jupyter_core : 5.3.0 jupyter_server : 2.5.0 jupyterlab : 4.0.0b2 nbclient : 0.7.4 nbconvert : 7.3.1 nbformat : 5.8.0 notebook : not installed qtconsole : not installed traitlets : 5.9.0 ``` ## Fix The fix for this should be straightforward: the `requirements` variable is not allocated when it is used here: https://github.com/jupyterlab/jupyterlab/blob/ec07704ef0196e4298692d347c8e32124bc33dfa/jupyterlab/upgrade_extension.py#L264. The fix might be easy, but in this case I'm not sure what the best thing to do is. We can either leave the requirements blank, or go check `setup.py` for the requirements.
2023-05-03T07:42:23Z
[]
[]
Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/home/pdmurray/.pyenv/versions/ksmm/lib/python3.11/site-packages/jupyterlab/upgrade_extension.py", line 324, in <module> update_extension(args.path, args.branch, args.no_input is False) File "/home/pdmurray/.pyenv/versions/ksmm/lib/python3.11/site-packages/jupyterlab/upgrade_extension.py", line 280, in update_extension pyproject["project"].get("dependencies", []) + requirements ^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'requirements' where it is not associated with a value
8,523
jupyterlab/jupyterlab
jupyterlab__jupyterlab-2324
b09273f6039ae6f58f2b73eb994ca07ac9a55f67
diff --git a/jupyterlab/commands.py b/jupyterlab/commands.py --- a/jupyterlab/commands.py +++ b/jupyterlab/commands.py @@ -65,21 +65,28 @@ def install_extension(extension, app_dir=None): raise ValueError('Cannot install extensions in core app') extension = _normalize_path(extension) _ensure_package(app_dir) - target = pjoin(app_dir, 'extensions') + target = pjoin(app_dir, 'extensions', 'temp') + if os.path.exists(target): + shutil.rmtree(target) + os.makedirs(target) + # npm pack the extension - output = run(['npm', 'pack', extension], cwd=target) + run(['npm', 'pack', extension], cwd=target) - name = output.decode('utf8').splitlines()[-1] - data = _read_package(pjoin(target, name)) + fname = os.path.basename(glob.glob(pjoin(target, '*.*'))[0]) + data = _read_package(pjoin(target, fname)) # Remove the tarball if the package is not an extension. if not _is_extension(data): - os.remove(pjoin(target, name)) + shutil.rmtree(target) msg = '%s is not a valid JupyterLab extension' % extension raise ValueError(msg) + shutil.move(pjoin(target, fname), pjoin(app_dir, 'extensions')) + shutil.rmtree(target) + staging = pjoin(app_dir, 'staging') - run(['npm', 'install', pjoin(target, name)], cwd=staging) + run(['npm', 'install', pjoin(app_dir, 'extensions', fname)], cwd=staging) def link_package(path, app_dir=None):
Extension install is brittle to changes in NPM version These lines use the stdout of an npm command as an API. This is brittle to changes in npm version: https://github.com/jupyterlab/jupyterlab/blob/master/jupyterlab/commands.py#L70-L73 As seen by @tkinz27: ``` root@c2d56f6eec3a:/juno# jupyter labextension install @jupyterlab/nbwidgets > npm pack @jupyterlab/nbwidgets Traceback (most recent call last): File "/usr/local/bin/jupyter-labextension", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance app.start() File "/usr/local/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 135, in start super(LabExtensionApp, self).start() File "/usr/local/lib/python3.6/site-packages/jupyter_core/application.py", line 256, in start self.subapp.start() File "/usr/local/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 49, in start [install_extension(arg, self.app_dir) for arg in self.extra_args] File "/usr/local/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 49, in <listcomp> [install_extension(arg, self.app_dir) for arg in self.extra_args] File "/usr/local/lib/python3.6/site-packages/jupyterlab/commands.py", line 71, in install_extension data = _read_package(pjoin(target, name)) File "/usr/local/lib/python3.6/site-packages/jupyterlab/commands.py", line 365, in _read_package tar = tarfile.open(target, "r:gz") File "/usr/local/lib/python3.6/tarfile.py", line 1586, in open return func(name, filemode, fileobj, **kwargs) File "/usr/local/lib/python3.6/tarfile.py", line 1633, in gzopen fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj) File "/usr/local/lib/python3.6/gzip.py", line 163, in __init__ fileobj = self.myfileobj = builtins.open(filename, mode or 'rb') FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/share/jupyter/lab/extensions/npm info ok ' ```
2017-05-30T18:18:32Z
[]
[]
Traceback (most recent call last): File "/usr/local/bin/jupyter-labextension", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance app.start() File "/usr/local/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 135, in start super(LabExtensionApp, self).start() File "/usr/local/lib/python3.6/site-packages/jupyter_core/application.py", line 256, in start self.subapp.start() File "/usr/local/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 49, in start [install_extension(arg, self.app_dir) for arg in self.extra_args] File "/usr/local/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 49, in <listcomp> [install_extension(arg, self.app_dir) for arg in self.extra_args] File "/usr/local/lib/python3.6/site-packages/jupyterlab/commands.py", line 71, in install_extension data = _read_package(pjoin(target, name)) File "/usr/local/lib/python3.6/site-packages/jupyterlab/commands.py", line 365, in _read_package tar = tarfile.open(target, "r:gz") File "/usr/local/lib/python3.6/tarfile.py", line 1586, in open return func(name, filemode, fileobj, **kwargs) File "/usr/local/lib/python3.6/tarfile.py", line 1633, in gzopen fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj) File "/usr/local/lib/python3.6/gzip.py", line 163, in __init__ fileobj = self.myfileobj = builtins.open(filename, mode or 'rb') FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/share/jupyter/lab/extensions/npm info ok '
8,548
jupyterlab/jupyterlab
jupyterlab__jupyterlab-2836
004429c983e3623d1e738fc2db87fac8236a2302
diff --git a/jupyterlab/commands.py b/jupyterlab/commands.py --- a/jupyterlab/commands.py +++ b/jupyterlab/commands.py @@ -720,12 +720,27 @@ def noop(x, y, z): def _format_compatibility_errors(name, version, errors): """Format a message for compatibility errors. """ + msgs = [] + l0 = 10 + l1 = 10 + for error in errors: + pkg, jlab, ext = error + jlab = str(Range(jlab, True)) + ext = str(Range(ext, True)) + msgs.append((pkg, jlab, ext)) + l0 = max(l0, len(pkg) + 1) + l1 = max(l1, len(jlab) + 1) + msg = '\n"%s@%s" is not compatible with the current JupyterLab' msg = msg % (name, version) - msg += '\nConflicting Dependencies:' - msg += '\nRequired\tActual\tPackage' - for error in errors: - msg += '\n%s \t%s\t%s' % (error[1], error[2], error[0]) + msg += '\nConflicting Dependencies:\n' + msg += 'JupyterLab'.ljust(l0) + msg += 'Extension'.ljust(l1) + msg += 'Package\n' + + for (pkg, jlab, ext) in msgs: + msg += jlab.ljust(l0) + ext.ljust(l1) + pkg + '\n' + return msg
Installing Labextensions - Dependency Checking Bug While trying to install the jupyterlab-hub extension, I think a may have found a couple bugs related to dependency checking. Command: `jupyter labextension install jupyterlab-hub` Output: ``` > npm pack jupyterlab-hub Traceback (most recent call last): File "/Users/pdwyer200/.virtualenvs/Jupyter3/bin/jupyter-labextension", line 11, in <module> sys.exit(main()) File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance app.start() File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 167, in start super(LabExtensionApp, self).start() File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyter_core/application.py", line 256, in start self.subapp.start() File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 57, in start for arg in self.extra_args] File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 57, in <listcomp> for arg in self.extra_args] File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyterlab/commands.py", line 127, in install_extension raise ValueError(msg) ValueError: "[email protected]" is not compatible with the current JupyterLab Conflicting Dependencies: Required Actual Package ^0.9.0 ^0.7.0 @jupyterlab/application ^0.9.0 ^0.7.0 @jupyterlab/apputils ^0.9.0 ^0.7.0 @jupyterlab/coreutils ``` I'm running the following versions: ``` jupyter lab --version 0.26.5 jupyter --version 4.3.0 ``` I think there are two issues here: 1. The package version ^0.7.0 is specified as a dependency by jupyterlab-hub (I checked this by running `npm pack jupyterlab-hub`, unpacking the tarball, and looking at the package.json) and version ^0.9.0 is the one I'm actually running. So I think the error message is printing those in the wrong order. 2. Since version 0.9.0 is greater than 0.7.0, I'd assume that jupyterlab-hub should successfully install. So there may be an issue in the code that's checking dependencies for compatibility.
Hi @patrickjdwyer, the `jupyterlab-hub` is in need of a new release. Npm version specifiers mean that `^0.7.0` is compatible with `0.7.0 - 0.7.x`. Ah did not realize that, thanks for the info! Still though, are the "Required" / "Actual" labels in the error message accidentally in the wrong order? It still seems pretty misleading to me. Perhaps if those were "JupyterLab / Extension"? That makes it somewhat more clear. Intuitively, I would think that "Required" is what the extension requires and "Actual" is what I actually have installed, but right now that's not the case and they're actually the opposite. So even just flipping them might be something to consider, unless I'm totally misinterpreting. They're both requirements, the first column right now are those of JupyterLab and the second are those of the extension. We are flagging the requirements that don't overlap (can't be deduplicated).
2017-08-15T18:56:43Z
[]
[]
Traceback (most recent call last): File "/Users/pdwyer200/.virtualenvs/Jupyter3/bin/jupyter-labextension", line 11, in <module> sys.exit(main()) File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance app.start() File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 167, in start super(LabExtensionApp, self).start() File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyter_core/application.py", line 256, in start self.subapp.start() File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 57, in start for arg in self.extra_args] File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 57, in <listcomp> for arg in self.extra_args] File "/Users/pdwyer200/.virtualenvs/Jupyter3/lib/python3.6/site-packages/jupyterlab/commands.py", line 127, in install_extension raise ValueError(msg) ValueError:
8,562
jupyterlab/jupyterlab
jupyterlab__jupyterlab-3127
c44e12d4fc71ed5fb8d322503b8a4e847f4a1105
diff --git a/jupyterlab/commands.py b/jupyterlab/commands.py --- a/jupyterlab/commands.py +++ b/jupyterlab/commands.py @@ -51,11 +51,12 @@ def get_app_dir(app_dir=None): # Use the default locations for data_files. # Check for a user level install. - if here.startswith(site.getuserbase()): + if hasattr(site, 'getuserbase') and here.startswith(site.getuserbase()): app_dir = pjoin(site.getuserbase(), 'share', 'jupyter', 'lab') - # Check for a Posix system level install. - elif sys.prefix == '/usr': + # Check for a system install in '/usr/local/share'. + elif (sys.prefix == '/usr' and + os.path.exists('/usr/local/share/jupyter/lab')): app_dir = '/usr/local/share/jupyter/lab' # Otherwise use the sys prefix.
module 'site' has no attribute 'getuserbase' Really simple flow, first i `virtualenv jupyterlab -p python3` Then, as documentation says: `pip install jupyterlab` `jupyter serverextension enable --py jupyterlab --sys-prefix` Then I tried launching using `jupyter lab` and I get the following: `[W 21:56:35.947 LabApp] JupyterLab server extension not enabled, manually loading... [I 21:56:35.947 LabApp] JupyterLab alpha preview extension loaded from /home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/jupyterlab Traceback (most recent call last): File "/home/elior/VirtualEnvs/jupyterlab/bin/jupyter-lab", line 11, in <module> sys.exit(main()) File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance app.initialize(argv) File "<decorator-gen-7>", line 2, in initialize File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error return method(app, *args, **kwargs) File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/notebook/notebookapp.py", line 1371, in initialize self.init_server_extensions() File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/jupyterlab/labapp.py", line 176, in init_server_extensions load_jupyter_server_extension(self) File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/jupyterlab/extension.py", line 48, in load_jupyter_server_extension app_dir = get_app_dir() File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/jupyterlab/commands.py", line 54, in get_app_dir if here.startswith(site.getuserbase()): AttributeError: module 'site' has no attribute 'getuserbase' ` I'm on Fedora 26, Python 3.6
That's odd, it should be part of the standard lib: https://docs.python.org/3/library/site.html#site.getuserbase. I'll add a guard around it.
2017-10-19T19:41:04Z
[]
[]
Traceback (most recent call last): File "/home/elior/VirtualEnvs/jupyterlab/bin/jupyter-lab", line 11, in <module> sys.exit(main()) File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance app.initialize(argv) File "<decorator-gen-7>", line 2, in initialize File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error return method(app, *args, **kwargs) File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/notebook/notebookapp.py", line 1371, in initialize self.init_server_extensions() File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/jupyterlab/labapp.py", line 176, in init_server_extensions load_jupyter_server_extension(self) File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/jupyterlab/extension.py", line 48, in load_jupyter_server_extension app_dir = get_app_dir() File "/home/elior/VirtualEnvs/jupyterlab/lib/python3.6/site-packages/jupyterlab/commands.py", line 54, in get_app_dir if here.startswith(site.getuserbase()): AttributeError: module 'site' has no attribute 'getuserbase'
8,570
jupyterlab/jupyterlab
jupyterlab__jupyterlab-3270
c98657e132fa88f622435ab74e9da7cff662dd18
diff --git a/clean.py b/clean.py new file mode 100644 --- /dev/null +++ b/clean.py @@ -0,0 +1,16 @@ +import os +import subprocess + +here = os.path.abspath(os.path.dirname(__file__)) + + +# Workaround for https://github.com/git-for-windows/git/issues/607 +if os.name == 'nt': + for (root, dnames, files) in os.walk(here): + if 'node_modules' in dnames: + subprocess.check_call(['rmdir', '/s', '/q', 'node_modules'], + cwd=root, shell=True) + dnames.remove('node_modules') + + +subprocess.check_call(['git', 'clean', '-dfx'], cwd=here) diff --git a/jupyterlab/commands.py b/jupyterlab/commands.py --- a/jupyterlab/commands.py +++ b/jupyterlab/commands.py @@ -13,7 +13,6 @@ import logging import os import os.path as osp -from os.path import join as pjoin import re import shutil import site @@ -34,6 +33,15 @@ # The regex for expecting the webpack output. WEBPACK_EXPECT = re.compile(r'.*/index.out.js') +# The dev mode directory. +DEV_DIR = osp.realpath(os.path.join(HERE, '..', 'dev_mode')) + + +def pjoin(*args): + """Join paths to create a real path. + """ + return osp.realpath(osp.join(*args)) + def get_user_settings_dir(): """Get the configured JupyterLab app directory. @@ -72,13 +80,26 @@ def get_app_dir(): return osp.realpath(app_dir) -def watch_dev(cwd, logger=None): +def ensure_dev(logger=None): + """Ensure that the dev assets are available. + """ + parent = pjoin(HERE, '..') + + if not osp.exists(pjoin(parent, 'node_modules')): + yarn_proc = Process(['node', YARN_PATH], cwd=parent, logger=logger) + yarn_proc.wait() + + if not osp.exists(pjoin(parent, 'dev_mode', 'build')): + yarn_proc = Process(['node', YARN_PATH, 'build'], cwd=parent, + logger=logger) + yarn_proc.wait() + + +def watch_dev(logger=None): """Run watch mode in a given directory. Parameters ---------- - cwd: string - The current working directory. logger: :class:`~logger.Logger`, optional The logger instance. @@ -86,6 +107,12 @@ def watch_dev(cwd, logger=None): ------- A list of `WatchHelper` objects. """ + parent = pjoin(HERE, '..') + + if not osp.exists(pjoin(parent, 'node_modules')): + yarn_proc = Process(['node', YARN_PATH], cwd=parent, logger=logger) + yarn_proc.wait() + logger = logger or logging.getLogger('jupyterlab') ts_dir = osp.realpath(osp.join(HERE, '..', 'packages', 'metapackage')) @@ -101,7 +128,8 @@ def watch_dev(cwd, logger=None): # Run webpack watch and wait for compilation. wp_proc = WatchHelper(['node', YARN_PATH, 'run', 'watch'], - cwd=HERE, logger=logger, startup_regex=WEBPACK_EXPECT) + cwd=DEV_DIR, logger=logger, + startup_regex=WEBPACK_EXPECT) return [ts_proc, tsf_proc, wp_proc] @@ -143,7 +171,9 @@ def uninstall_extension(name, app_dir=None, logger=None): def clean(app_dir=None): """Clean the JupyterLab application directory.""" app_dir = app_dir or get_app_dir() - if app_dir == HERE: + if app_dir == pjoin(HERE, 'dev'): + raise ValueError('Cannot clean the dev app') + if app_dir == pjoin(HERE, 'core'): raise ValueError('Cannot clean the core app') for name in ['static', 'staging']: target = pjoin(app_dir, name) @@ -152,12 +182,12 @@ def clean(app_dir=None): def build(app_dir=None, name=None, version=None, logger=None, - updating=False, command='build:prod', kill_event=None, + command='build:prod', kill_event=None, clean_staging=False): """Build the JupyterLab application. """ handler = _AppHandler(app_dir, logger, kill_event=kill_event) - handler.build(name=name, version=version, updating=updating, + handler.build(name=name, version=version, command=command, clean_staging=clean_staging) @@ -224,7 +254,7 @@ def get_app_version(): class _AppHandler(object): def __init__(self, app_dir, logger=None, kill_event=None): - if app_dir == HERE: + if app_dir and app_dir.startswith(HERE): raise ValueError('Cannot run lab extension commands in core app') self.app_dir = app_dir or get_app_dir() self.sys_dir = get_app_dir() @@ -272,15 +302,15 @@ def install_extension(self, extension, existing=None): if other['path'] != info['path'] and other['location'] == 'app': os.remove(other['path']) - def build(self, name=None, version=None, updating=False, - command='build:prod', clean_staging=False): + def build(self, name=None, version=None, command='build:prod', + clean_staging=False): """Build the application. """ # Set up the build directory. app_dir = self.app_dir self._populate_staging( - name=name, version=version, updating=updating, clean=clean_staging + name=name, version=version, clean=clean_staging ) staging = pjoin(app_dir, 'staging') @@ -381,7 +411,7 @@ def build_check(self, fast=False): return [msg % (static_version, core_version)] # Look for mismatched extensions. - new_package = self._get_package_template() + new_package = self._get_package_template(silent=fast) new_jlab = new_package['jupyterlab'] new_deps = new_package.get('dependencies', dict()) @@ -462,15 +492,22 @@ def uninstall_extension(self, name): def link_package(self, path): """Link a package at the given path. """ + path = _normalize_path(path) if not osp.exists(path) or not osp.isdir(path): - raise ValueError('Can only link local directories') + msg = 'Can install "%s" only link local directories' + raise ValueError(msg % path) with TemporaryDirectory() as tempdir: info = self._extract_package(path, tempdir) - if _is_extension(info['data']): + messages = _validate_extension(info['data']) + if not messages: return self.install_extension(path) + # Warn that it is a linked package. + self.logger.warn('Installing %s as a linked package:', path) + [self.logger.warn(m) for m in messages] + # Add to metadata. config = self._read_build_config() linked = config.setdefault('linked_packages', dict()) @@ -480,6 +517,7 @@ def link_package(self, path): def unlink_package(self, path): """Link a package by name or at the given path. """ + path = _normalize_path(path) config = self._read_build_config() linked = config.setdefault('linked_packages', dict()) @@ -551,8 +589,7 @@ def _get_app_info(self): info['disabled_core'] = disabled_core return info - def _populate_staging(self, name=None, version=None, updating=False, - clean=False): + def _populate_staging(self, name=None, version=None, clean=False): """Set up the assets in the staging directory. """ app_dir = self.app_dir @@ -567,7 +604,7 @@ def _populate_staging(self, name=None, version=None, updating=False, # Look for mismatched version. pkg_path = pjoin(staging, 'package.json') - overwrite_lock = not updating + overwrite_lock = False if osp.exists(pkg_path): with open(pkg_path) as fid: @@ -578,39 +615,35 @@ def _populate_staging(self, name=None, version=None, updating=False, else: overwrite_lock = False - for fname in ['index.app.js', 'webpack.config.js', - 'yarn.app.lock', '.yarnrc', 'yarn.js']: - if fname == 'yarn.app.lock' and not overwrite_lock: + for fname in ['index.js', 'webpack.config.js', + 'yarn.lock', '.yarnrc', 'yarn.js']: + if fname == 'yarn.lock' and not overwrite_lock: continue - dest = pjoin(staging, fname.replace('.app', '')) - shutil.copy(pjoin(HERE, fname), dest) + shutil.copy(pjoin(HERE, 'staging', fname), pjoin(staging, fname)) - # Ensure a clean linked packes directory. + # Ensure a clean linked packages directory. linked_dir = pjoin(staging, 'linked_packages') if osp.exists(linked_dir): shutil.rmtree(linked_dir) os.makedirs(linked_dir) # Template the package.json file. - if updating: - data = self.info['core_data'] - else: - # Update the local extensions. - extensions = self.info['extensions'] - for (key, source) in self.info['local_extensions'].items(): - dname = pjoin(app_dir, 'extensions') - self._update_local(key, source, dname, extensions[key], - 'local_extensions') - - # Update the linked packages. - linked = self.info['linked_packages'] - for (key, item) in linked.items(): - dname = pjoin(staging, 'linked_packages') - self._update_local(key, item['source'], dname, item, - 'linked_packages') - - # Then get the package template. - data = self._get_package_template() + # Update the local extensions. + extensions = self.info['extensions'] + for (key, source) in self.info['local_extensions'].items(): + dname = pjoin(app_dir, 'extensions') + self._update_local(key, source, dname, extensions[key], + 'local_extensions') + + # Update the linked packages. + linked = self.info['linked_packages'] + for (key, item) in linked.items(): + dname = pjoin(staging, 'linked_packages') + self._update_local(key, item['source'], dname, item, + 'linked_packages') + + # Then get the package template. + data = self._get_package_template() if version: data['jupyterlab']['version'] = version @@ -622,7 +655,7 @@ def _populate_staging(self, name=None, version=None, updating=False, with open(pkg_path, 'w') as fid: json.dump(data, fid, indent=4) - def _get_package_template(self): + def _get_package_template(self, silent=False): """Get the template the for staging package.json file. """ logger = self.logger @@ -648,7 +681,8 @@ def format_path(path): msg = _format_compatibility_errors( key, value['version'], errors ) - logger.warn(msg + '\n') + if not silent: + logger.warn(msg + '\n') continue data['dependencies'][key] = format_path(value['path']) @@ -915,8 +949,10 @@ def _install_extension(self, extension, tempdir): data = info['data'] # Verify that the package is an extension. - if not _is_extension(data): - raise ValueError('Not a valid extension') + messages = _validate_extension(data) + if messages: + msg = '"%s" is not a valid extension:\n%s' + raise ValueError(msg % (extension, '\n'.join(messages))) # Verify package compatibility. core_data = _get_core_data() @@ -946,13 +982,12 @@ def _extract_package(self, source, tempdir): info = dict(source=source, is_dir=is_dir) - self._run([which('npm'), 'pack', source], cwd=tempdir) - - paths = glob.glob(pjoin(tempdir, '*.tgz')) - if not paths: - raise ValueError('Extension failed to pack') + ret = self._run([which('npm'), 'pack', source], cwd=tempdir) + if ret != 0: + msg = '"%s" is not a valid npm package' + raise ValueError(msg % source) - path = paths[0] + path = glob.glob(pjoin(tempdir, '*.tgz'))[0] info['data'] = _read_package(path) if is_dir: info['sha'] = sha = _tarsum(path) @@ -970,6 +1005,8 @@ def _extract_package(self, source, tempdir): def _run(self, cmd, **kwargs): """Run the command using our logger and abort callback. + + Returns the exit code. """ if self.kill_event.is_set(): raise ValueError('Command was killed') @@ -977,7 +1014,7 @@ def _run(self, cmd, **kwargs): kwargs['logger'] = self.logger kwargs['kill_event'] = self.kill_event proc = Process(cmd, **kwargs) - proc.wait() + return proc.wait() def _normalize_path(extension): @@ -995,20 +1032,58 @@ def _read_package(target): tar = tarfile.open(target, "r:gz") f = tar.extractfile('package/package.json') data = json.loads(f.read().decode('utf8')) + data['jupyterlab_extracted_files'] = [ + f.path[len('package/'):] for f in tar.getmembers() + ] tar.close() return data -def _is_extension(data): +def _validate_extension(data): """Detect if a package is an extension using its metadata. + + Returns any problems it finds. """ - if 'jupyterlab' not in data: - return False - if not isinstance(data['jupyterlab'], dict): - return False - is_extension = data['jupyterlab'].get('extension', False) - is_mime_extension = data['jupyterlab'].get('mimeExtension', False) - return is_extension or is_mime_extension + jlab = data.get('jupyterlab', None) + if jlab is None: + return ['No `jupyterlab` key'] + if not isinstance(jlab, dict): + return ['The `jupyterlab` key must be a JSON object'] + extension = jlab.get('extension', False) + mime_extension = jlab.get('mimeExtension', False) + themeDir = jlab.get('themeDir', '') + schemaDir = jlab.get('schemaDir', '') + + messages = [] + if not extension and not mime_extension: + messages.append('No `extension` or `mimeExtension` key present') + + if extension == mime_extension: + msg = '`mimeExtension` and `extension` must point to different modules' + messages.append(msg) + + files = data['jupyterlab_extracted_files'] + main = data.get('main', 'index.js') + + if extension is True: + if main not in files: + messages.append('Missing extension module "%s"' % main) + elif extension and extension not in files: + messages.append('Missing extension module "%s"' % extension) + + if mime_extension is True: + if main not in files: + messages.append('Missing mimeExtension module "%s"' % main) + elif mime_extension and mime_extension not in files: + messages.append('Missing mimeExtension module "%s"' % mime_extension) + + if themeDir and not any(f.startswith(themeDir) for f in files): + messages.append('themeDir is empty: "%s"' % themeDir) + + if schemaDir and not any(f.startswith(schemaDir) for f in files): + messages.append('schemaDir is empty: "%s"' % schemaDir) + + return messages def _tarsum(input_file): @@ -1033,7 +1108,7 @@ def _tarsum(input_file): def _get_core_data(): """Get the data for the app template. """ - with open(pjoin(HERE, 'package.app.json')) as fid: + with open(pjoin(HERE, 'staging', 'package.json')) as fid: return json.load(fid) diff --git a/jupyterlab/extension.py b/jupyterlab/extension.py --- a/jupyterlab/extension.py +++ b/jupyterlab/extension.py @@ -7,11 +7,12 @@ #----------------------------------------------------------------------------- # Module globals #----------------------------------------------------------------------------- +import os -DEV_NOTE_NPM = """You're running JupyterLab from source. +DEV_NOTE = """You're running JupyterLab from source. If you're working on the TypeScript sources of JupyterLab, try running - jlpm run --dev-mode watch + jupyter lab --dev-mode --watch to have the system incrementally watch and build JupyterLab for you, as you @@ -28,94 +29,106 @@ def load_jupyter_server_extension(nbapp): """Load the JupyterLab server extension. """ # Delay imports to speed up jlpmapp - import os from jupyterlab_launcher import add_handlers, LabConfig from notebook.utils import url_path_join as ujoin from tornado.ioloop import IOLoop from .build_handler import build_path, Builder, BuildHandler from .commands import ( - get_app_dir, get_user_settings_dir, watch, watch_dev + get_app_dir, get_user_settings_dir, watch, ensure_dev, watch_dev, + pjoin, DEV_DIR, HERE, get_app_version ) from ._version import __version__ - # Print messages. - here = os.path.dirname(__file__) - nbapp.log.info('JupyterLab alpha preview extension loaded from %s' % here) - - if hasattr(nbapp, 'app_dir'): - app_dir = nbapp.app_dir or get_app_dir() - else: - app_dir = get_app_dir() - web_app = nbapp.web_app + logger = nbapp.log config = LabConfig() + app_dir = getattr(nbapp, 'app_dir', get_app_dir()) + + # Print messages. + logger.info('JupyterLab alpha preview extension loaded from %s' % HERE) + logger.info('JupyterLab application directory is %s' % app_dir) config.name = 'JupyterLab' - config.assets_dir = os.path.join(app_dir, 'static') - config.settings_dir = os.path.join(app_dir, 'settings') config.page_title = 'JupyterLab Alpha Preview' config.page_url = '/lab' - config.dev_mode = False # Check for core mode. - core_mode = '' - if hasattr(nbapp, 'core_mode'): - core_mode = nbapp.core_mode + core_mode = False + if getattr(nbapp, 'core_mode', False) or app_dir.startswith(HERE): + core_mode = True + logger.info('Running JupyterLab in core mode') + + # Check for dev mode. + dev_mode = False + if getattr(nbapp, 'dev_mode', False) or app_dir.startswith(DEV_DIR): + dev_mode = True + logger.info('Running JupyterLab in dev mode') # Check for watch. - watch_mode = False - if hasattr(nbapp, 'watch'): - watch_mode = nbapp.watch + watch_mode = getattr(nbapp, 'watch', False) - # Check for an app dir that is local. - if app_dir == here or app_dir == os.path.join(here, 'build'): - core_mode = True - config.settings_dir = '' + if watch_mode and core_mode: + logger.warn('Cannot watch in core mode, did you mean --dev-mode?') + watch_mode = False + + if core_mode and dev_mode: + logger.warn('Conflicting modes, choosing dev_mode over core_mode') + core_mode = False page_config = web_app.settings.setdefault('page_config_data', dict()) - page_config['buildAvailable'] = not core_mode - page_config['buildCheck'] = not core_mode + page_config['buildAvailable'] = not core_mode and not dev_mode + page_config['buildCheck'] = not core_mode and not dev_mode page_config['token'] = nbapp.token if core_mode: - config.assets_dir = os.path.join(here, 'build') - config.version = __version__ - if not os.path.exists(config.assets_dir) and not watch_mode: + config.assets_dir = pjoin(HERE, 'static') + config.schemas_dir = pjoin(HERE, 'schemas') + config.settings_dir = '' + config.themes_dir = pjoin(HERE, 'themes') + config.version = get_app_version() + + logger.info(CORE_NOTE.strip()) + if not os.path.exists(config.assets_dir): msg = 'Static assets not built, please see CONTRIBUTING.md' - nbapp.log.error(msg) - else: - sentinel = os.path.join(here, 'build', 'release_data.json') - config.dev_mode = not os.path.exists(sentinel) + logger.error(msg) - if config.dev_mode and not watch_mode: - nbapp.log.info(DEV_NOTE_NPM) - elif core_mode: - nbapp.log.info(CORE_NOTE.strip()) + elif dev_mode: + config.assets_dir = pjoin(DEV_DIR, 'build') + config.schemas_dir = pjoin(DEV_DIR, 'schemas') + config.settings_dir = '' + config.themes_dir = pjoin(DEV_DIR, 'themes') + config.version = __version__ + + ensure_dev(logger) + if not watch_mode: + logger.info(DEV_NOTE) - if core_mode: - schemas_dir = os.path.join(here, 'schemas') - config.themes_dir = os.path.join(here, 'themes') else: - schemas_dir = os.path.join(app_dir, 'schemas') - config.themes_dir = os.path.join(app_dir, 'themes') + config.assets_dir = pjoin(app_dir, 'static') + config.schemas_dir = pjoin(app_dir, 'schemas') + config.settings_dir = pjoin(app_dir, 'settings') + config.themes_dir = pjoin(app_dir, 'themes') + config.version = get_app_version() - config.schemas_dir = schemas_dir + config.dev_mode = dev_mode config.user_settings_dir = get_user_settings_dir() if watch_mode: + logger.info('Starting JupyterLab watch mode...') + # Set the ioloop in case the watch fails. nbapp.ioloop = IOLoop.current() if config.dev_mode: - watch_dev(nbapp.log) + watch_dev(logger) else: - watch(app_dir, nbapp.log) + watch(app_dir, logger) page_config['buildAvailable'] = False add_handlers(web_app, config) base_url = web_app.settings['base_url'] build_url = ujoin(base_url, build_path) - builder = Builder(nbapp.log, core_mode, app_dir) + builder = Builder(logger, core_mode, app_dir) build_handler = (build_url, BuildHandler, {'builder': builder}) web_app.add_handlers(".*$", [build_handler]) diff --git a/jupyterlab/jlpmapp.py b/jupyterlab/jlpmapp.py --- a/jupyterlab/jlpmapp.py +++ b/jupyterlab/jlpmapp.py @@ -14,7 +14,7 @@ import subprocess HERE = os.path.dirname(os.path.abspath(__file__)) -YARN_PATH = os.path.join(HERE, 'yarn.js') +YARN_PATH = os.path.join(HERE, 'staging', 'yarn.js') def execvp(cmd, argv): diff --git a/jupyterlab/labapp.py b/jupyterlab/labapp.py --- a/jupyterlab/labapp.py +++ b/jupyterlab/labapp.py @@ -12,7 +12,8 @@ from ._version import __version__ from .extension import load_jupyter_server_extension from .commands import ( - build, clean, get_app_dir, get_user_settings_dir, get_app_version + build, clean, get_app_dir, get_user_settings_dir, get_app_version, + ensure_dev ) @@ -98,7 +99,7 @@ def start(self): "Start the app in core mode." ) lab_flags['dev-mode'] = ( - {'LabApp': {'core_mode': True}}, + {'LabApp': {'dev_mode': True}}, "Start the app in dev mode for running from source." ) lab_flags['watch'] = ( @@ -122,9 +123,9 @@ class LabApp(NotebookApp): assets contained in the installed `jupyterlab` Python package. In core mode, no extensions are enabled. This is the default in a stable JupyterLab release if you have no extensions installed. - * Dev mode (`--dev-mode`): like core mode, but when the `jupyterlab` Python package - is installed from source and installed using `pip install -e .`. In this case - JupyterLab will show a red stripe at the top of the page. + * Dev mode (`--dev-mode`): uses the unpublished local JavaScript packages + in the `dev_mode` folder. In this case JupyterLab will show a red stripe at the top of the page. It can only be used if JupyterLab + is installed as `pip install -e .`. * App mode: JupyterLab allows multiple JupyterLab "applications" to be created by the user with different combinations of extensions. The `--app-dir` can be used to set a directory for different applications. The default application @@ -152,7 +153,7 @@ class LabApp(NotebookApp): default_url = Unicode('/lab', config=True, help="The default URL to redirect to from `/`") - app_dir = Unicode('', config=True, + app_dir = Unicode(get_app_dir(), config=True, help="The app directory to launch JupyterLab from.") core_mode = Bool(False, config=True, @@ -163,6 +164,12 @@ class LabApp(NotebookApp): itself is installed in development mode (`pip install -e .`). """) + dev_mode = Bool(False, config=True, + help="""Whether to start the app in dev mode. Uses the unpublished local JavaScript packages + in the `dev_mode` folder. In this case JupyterLab will show a red stripe at the top of the page. It can only be used if JupyterLab + is installed as `pip install -e .`. + """) + watch = Bool(False, config=True, help="Whether to serve the app in watch mode") diff --git a/jupyterlab/labextensions.py b/jupyterlab/labextensions.py --- a/jupyterlab/labextensions.py +++ b/jupyterlab/labextensions.py @@ -5,9 +5,9 @@ # Distributed under the terms of the Modified BSD License. from __future__ import print_function -import json import os import sys +import traceback from jupyter_core.application import JupyterApp, base_flags, base_aliases @@ -16,7 +16,7 @@ from .commands import ( install_extension, uninstall_extension, list_extensions, enable_extension, disable_extension, - link_package, unlink_package, build + link_package, unlink_package, build, get_app_version ) @@ -33,11 +33,7 @@ aliases = dict(base_aliases) aliases['app-dir'] = 'BaseExtensionApp.app_dir' - -here = os.path.dirname(__file__) -with open(os.path.join(here, 'package.app.json')) as fid: - data = json.load(fid) -VERSION = data['jupyterlab']['version'] +VERSION = get_app_version() class BaseExtensionApp(JupyterApp): @@ -54,6 +50,20 @@ class BaseExtensionApp(JupyterApp): should_clean = Bool(False, config=True, help="Whether temporary files should be cleaned up after building jupyterlab") + def start(self): + try: + self.run_task() + except Exception as ex: + ex_traceback = ex.__traceback__ + msg = traceback.format_exception(ex.__class__, ex, ex_traceback) + for line in msg: + self.log.debug(line) + self.log.error(str(ex)) + sys.exit(1) + + def run_task(self): + pass + def _log_format_default(self): """A default format for messages""" return "%(message)s" @@ -64,17 +74,14 @@ class InstallLabExtensionApp(BaseExtensionApp): should_build = Bool(True, config=True, help="Whether to build the app after the action") - def start(self): + def run_task(self): self.extra_args = self.extra_args or [os.getcwd()] - [install_extension(arg, self.app_dir, logger=self.log) - for arg in self.extra_args] + [install_extension(arg, self.app_dir, logger=self.log) for + arg in self.extra_args] + if self.should_build: - try: - build(self.app_dir, clean_staging=self.should_clean, logger=self.log) - except Exception as e: - for arg in self.extra_args: - uninstall_extension(arg, self.app_dir, logger=self.log) - raise e + build(self.app_dir, clean_staging=self.should_clean, + logger=self.log) class LinkLabExtensionApp(BaseExtensionApp): @@ -88,17 +95,14 @@ class LinkLabExtensionApp(BaseExtensionApp): should_build = Bool(True, config=True, help="Whether to build the app after the action") - def start(self): + def run_task(self): self.extra_args = self.extra_args or [os.getcwd()] [link_package(arg, self.app_dir, logger=self.log) for arg in self.extra_args] + if self.should_build: - try: - build(self.app_dir, clean_staging=self.should_clean, logger=self.log) - except Exception as e: - for arg in self.extra_args: - unlink_package(arg, self.app_dir, logger=self.log) - raise e + build(self.app_dir, clean_staging=self.should_clean, + logger=self.log) class UnlinkLabExtensionApp(BaseExtensionApp): @@ -106,12 +110,13 @@ class UnlinkLabExtensionApp(BaseExtensionApp): should_build = Bool(True, config=True, help="Whether to build the app after the action") - def start(self): + def run_task(self): self.extra_args = self.extra_args or [os.getcwd()] ans = any([unlink_package(arg, self.app_dir, logger=self.log) for arg in self.extra_args]) if ans and self.should_build: - build(self.app_dir, clean_staging=self.should_clean, logger=self.log) + build(self.app_dir, clean_staging=self.should_clean, + logger=self.log) class UninstallLabExtensionApp(BaseExtensionApp): @@ -119,25 +124,26 @@ class UninstallLabExtensionApp(BaseExtensionApp): should_build = Bool(True, config=True, help="Whether to build the app after the action") - def start(self): + def run_task(self): self.extra_args = self.extra_args or [os.getcwd()] ans = any([uninstall_extension(arg, self.app_dir, logger=self.log) for arg in self.extra_args]) if ans and self.should_build: - build(self.app_dir, clean_staging=self.should_clean, logger=self.log) + build(self.app_dir, clean_staging=self.should_clean, + logger=self.log) class ListLabExtensionsApp(BaseExtensionApp): description = "List the installed labextensions" - def start(self): + def run_task(self): list_extensions(self.app_dir, logger=self.log) class EnableLabExtensionsApp(BaseExtensionApp): description = "Enable labextension(s) by name" - def start(self): + def run_task(self): [enable_extension(arg, self.app_dir, logger=self.log) for arg in self.extra_args] @@ -145,7 +151,7 @@ def start(self): class DisableLabExtensionsApp(BaseExtensionApp): description = "Disable labextension(s) by name" - def start(self): + def run_task(self): [disable_extension(arg, self.app_dir, logger=self.log) for arg in self.extra_args] diff --git a/jupyterlab/process.py b/jupyterlab/process.py --- a/jupyterlab/process.py +++ b/jupyterlab/process.py @@ -81,16 +81,11 @@ def terminate(self): # Kill the process. if proc.poll() is None: - try: - os.kill(proc.pid, signal.SIGTERM) - except Exception as e: - self.logger.error(str(e)) + os.kill(proc.pid, signal.SIGTERM) # Wait for the process to close. try: proc.wait() - except Exception as e: - self.logger.error(e) finally: Process._procs.remove(self) @@ -105,18 +100,11 @@ def wait(self): """ proc = self.proc kill_event = self._kill_event - try: - while proc.poll() is None: - if kill_event.is_set(): - self.terminate() - raise ValueError('Process Aborted') - time.sleep(1.) - except subprocess.CalledProcessError as error: - output = error.output.decode('utf-8') - self.logger.error(output) - self.terminate() - raise error - + while proc.poll() is None: + if kill_event.is_set(): + self.terminate() + raise ValueError('Process was aborted') + time.sleep(1.) return self.terminate() @gen.coroutine @@ -125,17 +113,11 @@ def wait_async(self): """ proc = self.proc kill_event = self._kill_event - try: - while proc.poll() is None: - if kill_event.is_set(): - self.terminate() - raise ValueError('Process Aborted') - yield gen.sleep(1.) - except subprocess.CalledProcessError as error: - output = error.output.decode('utf-8') - self.logger.error(output) - self.terminate() - raise error + while proc.poll() is None: + if kill_event.is_set(): + self.terminate() + raise ValueError('Process was aborted') + yield gen.sleep(1.) raise gen.Return(self.terminate()) @@ -149,14 +131,7 @@ def _create_process(self, **kwargs): kwargs['shell'] = True cmd[0] = which(cmd[0], kwargs.get('env')) - - try: - proc = subprocess.Popen(cmd, **kwargs) - except subprocess.CalledProcessError as error: - output = error.output.decode('utf-8') - self.logger.error(output) - raise error - + proc = subprocess.Popen(cmd, **kwargs) return proc @classmethod @@ -229,9 +204,6 @@ def terminate(self): # Wait for the process to close. try: proc.wait() - except Exception as e: - print('on close') - self.logger.error(e) finally: Process._procs.remove(self) diff --git a/jupyterlab/selenium_check.py b/jupyterlab/selenium_check.py --- a/jupyterlab/selenium_check.py +++ b/jupyterlab/selenium_check.py @@ -89,6 +89,10 @@ def ensure_geckodriver(log): {'SeleniumApp': {'core_mode': True}}, "Start the app in core mode." ) +test_flags['dev-mode'] = ( + {'SeleniumApp': {'dev_mode': True}}, + "Start the app in dev mode." +) test_aliases = dict(aliases) @@ -103,12 +107,6 @@ class SeleniumApp(LabApp): flags = test_flags aliases = test_aliases - core_mode = Bool(False, config=True, - help="Whether to start the app in core mode") - - app_dir = Unicode('', config=True, - help="The app directory to build in") - def start(self): web_app = self.web_app web_app.settings.setdefault('page_config_data', dict()) diff --git a/jupyterlab/update.py b/jupyterlab/update.py --- a/jupyterlab/update.py +++ b/jupyterlab/update.py @@ -1,15 +1,40 @@ # coding: utf-8 # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. +from os.path import join as pjoin +import json import os import shutil -from .commands import build, get_app_dir +HERE = os.path.dirname(__file__) -here = os.path.dirname(__file__) -app_dir = get_app_dir() -build(updating=True) +# Get the dev mode package.json file. +dev_path = os.path.realpath(pjoin(HERE, '..', 'dev_mode')) +with open(pjoin(dev_path, 'package.json')) as fid: + data = json.load(fid) + + +# Update the values that need to change and write to staging. +data['scripts']['build'] = 'webpack' +data['scripts']['watch'] = 'webpack --watch' +data['scripts']['build:prod'] = ( + "webpack --define process.env.NODE_ENV=\"'production'\"") +data['jupyterlab']['outputDir'] = '..' +data['jupyterlab']['staticDir'] = '../static' +data['jupyterlab']['linkedPackages'] = dict() + +staging = pjoin(HERE, 'staging') + +with open(pjoin(staging, 'package.json'), 'w') as fid: + json.dump(data, fid) + +# Update our index file and webpack file. +for fname in ['index.js', 'webpack.config.js']: + shutil.copy(pjoin(dev_path, fname), pjoin(staging, fname)) + + +# Get a new yarn lock file. target = os.path.join(app_dir, 'staging', 'yarn.lock') -shutil.copy(target, os.path.join(here, 'yarn.app.lock')) +shutil.copy(target, os.path.join(staging, 'yarn.lock')) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -3,82 +3,93 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. +from os.path import join as pjoin +import json +import os +import sys -from __future__ import print_function +# Our own imports +from setupbase import ( + create_cmdclass, ensure_python, find_packages, get_version, + command_for_func, combine_commands, install_npm, HERE, run +) -#----------------------------------------------------------------------------- -# Minimal Python version sanity check -#----------------------------------------------------------------------------- +from setuptools import setup -import sys -v = sys.version_info -if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)): - error = "ERROR: %s requires Python version 2.7 or 3.3 or above." % name - print(error, file=sys.stderr) - sys.exit(1) +NAME = 'jupyterlab' +DESCRIPTION = 'An alpha preview of the JupyterLab notebook server extension.' +LONG_DESCRIPTION = """ +This is an alpha preview of JupyterLab. It is not ready for general usage yet. +Development happens on https://github.com/jupyter/jupyterlab, with chat on +https://gitter.im/jupyter/jupyterlab. +""" + +ensure_python(['2.7', '>=3.3']) + +data_files_spec = [ + ('share/jupyter/lab/static', '%s/static' % NAME, '**'), + ('share/jupyter/lab/schemas', '%s/schemas' % NAME, '**'), + ('share/jupyter/lab/themes', '%s/themes' % NAME, '**') +] -PY3 = (sys.version_info[0] >= 3) +package_data_spec = dict() +package_data_spec[NAME] = [ + 'staging/*', 'static/**', 'tests/mock_packages/**', 'themes/**', + 'schemas/**' +] -#----------------------------------------------------------------------------- -# get on with it -#----------------------------------------------------------------------------- +staging = pjoin(HERE, NAME, 'staging') +npm = ['node', pjoin(staging, 'yarn.js')] +VERSION = get_version('%s/_version.py' % NAME) -from distutils import log -from hashlib import sha256 -import json -import os -from glob import glob -try: - from urllib2 import urlopen -except ImportError: - from urllib.request import urlopen +def check_assets(): + from distutils.version import LooseVersion + # Representative files that should exist after a successful build + targets = [ + 'static/package.json', + 'schemas/@jupyterlab/shortcuts-extension/plugin.json', + 'themes/@jupyterlab/theme-light-extension/images/jupyterlab.svg' + ] -# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly -# update it when the contents of directories change. -if os.path.exists('MANIFEST'): os.remove('MANIFEST') + for t in targets: + if not os.path.exists(pjoin(HERE, NAME, t)): + msg = ('Missing file: %s, `build:prod` script did not complete ' + 'successfully' % t) + raise ValueError(msg) -from distutils.command.build_ext import build_ext -from distutils.command.build_py import build_py -from setuptools.command.sdist import sdist -from setuptools import setup -from setuptools.command.bdist_egg import bdist_egg -from setuptools import setup + if 'develop' in sys.argv: + run(npm, cwd=HERE) + if 'sdist' not in sys.argv and 'bdist_wheel' not in sys.argv: + return -# Our own imports -from setupbase import ( - bdist_egg_disabled, - find_packages, - find_package_data, - find_data_files, - js_prerelease, - CheckAssets, - version_ns, - name, - custom_egg_info -) + target = pjoin(HERE, NAME, 'static', 'package.json') + with open(target) as fid: + version = json.load(fid)['jupyterlab']['version'] + if LooseVersion(version) != LooseVersion(VERSION): + raise ValueError('Version mismatch, please run `build:update`') -here = os.path.dirname(os.path.abspath(__file__)) -pjoin = os.path.join -DESCRIPTION = 'An alpha preview of the JupyterLab notebook server extension.' -LONG_DESCRIPTION = 'This is an alpha preview of JupyterLab. It is not ready for general usage yet. Development happens on https://github.com/jupyter/jupyterlab, with chat on https://gitter.im/jupyter/jupyterlab.' +cmdclass = create_cmdclass('jsdeps', data_files_spec=data_files_spec, + package_data_spec=package_data_spec) +cmdclass['jsdeps'] = combine_commands( + install_npm(build_cmd='build:prod', path=staging, source_dir=staging, + build_dir=pjoin(HERE, NAME, 'static'), npm=npm), + command_for_func(check_assets) +) setup_args = dict( - name = name, + name = NAME, description = DESCRIPTION, long_description = LONG_DESCRIPTION, - version = version_ns['__version__'], - scripts = glob(pjoin('scripts', '*')), + version = VERSION, packages = find_packages(), - package_data = find_package_data(), - data_files = find_data_files(), - include_package_data = True, + cmdclass = cmdclass, author = 'Jupyter Development Team', author_email = '[email protected]', url = 'http://jupyter.org', @@ -94,41 +105,22 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', ], ) -cmdclass = dict( - build_py = build_py, - build_ext = build_ext, - sdist = js_prerelease(sdist, strict=True), - bdist_egg = bdist_egg if 'bdist_egg' in sys.argv else bdist_egg_disabled, - jsdeps = CheckAssets, - egg_info = custom_egg_info -) -try: - from wheel.bdist_wheel import bdist_wheel - cmdclass['bdist_wheel'] = js_prerelease(bdist_wheel, strict=True) -except ImportError: - pass - - -setup_args['cmdclass'] = cmdclass - - -setuptools_args = {} -install_requires = setuptools_args['install_requires'] = [ +setup_args['install_requires'] = [ 'notebook>=4.3.1', - 'jupyterlab_launcher>=0.6.0', + 'jupyterlab_launcher>=0.6.0,<0.7.0', 'ipython_genutils', - "futures;python_version<'3.0'", - "subprocess32;python_version<'3.0'" + 'futures;python_version<"3.0"', + 'subprocess32;python_version<"3.0"' ] -extras_require = setuptools_args['extras_require'] = { +setup_args['extras_require'] = { 'test:python_version == "2.7"': ['mock'], 'test': ['pytest', 'requests', 'pytest-check-links', 'selenium'], 'docs': [ @@ -139,21 +131,20 @@ } -if 'setuptools' in sys.modules: - setup_args.update(setuptools_args) +# Because of this we do not need a MANIFEST.in +setup_args['include_package_data'] = True - # force entrypoints with setuptools (needed for Windows, unconditional because of wheels) - setup_args['entry_points'] = { - 'console_scripts': [ - 'jupyter-lab = jupyterlab.labapp:main', - 'jupyter-labextension = jupyterlab.labextensions:main', - 'jupyter-labhub = jupyterlab.labhubapp:main', - 'jlpm = jupyterlab.jlpmapp:main', - ] - } - setup_args.pop('scripts', None) +# Force entrypoints with setuptools (needed for Windows, unconditional +# because of wheels) +setup_args['entry_points'] = { + 'console_scripts': [ + 'jupyter-lab = jupyterlab.labapp:main', + 'jupyter-labextension = jupyterlab.labextensions:main', + 'jupyter-labhub = jupyterlab.labhubapp:main', + 'jlpm = jupyterlab.jlpmapp:main', + ] +} - setup_args.update(setuptools_args) if __name__ == '__main__': setup(**setup_args) diff --git a/setupbase.py b/setupbase.py --- a/setupbase.py +++ b/setupbase.py @@ -1,31 +1,43 @@ -# encoding: utf-8 -""" -This module defines the things that are used in setup.py for building JupyterLab -This includes: - * Functions for finding things like packages, package data, etc. - * A function for checking dependencies. -""" +#!/usr/bin/env python +# coding: utf-8 # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. +""" +This file originates from the 'jupyter-packaging' package, and +contains a set of useful utilities for including npm packages +within a Python package. +""" +from collections import defaultdict +from os.path import join as pjoin import io -import json import os +import functools import pipes +import re +import shlex +import subprocess import sys -import shutil -import tempfile -import os.path as osp -from os.path import join as pjoin -from distutils import log + +# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly +# update it when the contents of directories change. +if os.path.exists('MANIFEST'): os.remove('MANIFEST') + + from distutils.cmd import Command -from distutils.version import LooseVersion -from setuptools.command.egg_info import egg_info +from distutils.command.build_py import build_py +from distutils.command.sdist import sdist +from distutils import log + +from setuptools.command.develop import develop from setuptools.command.bdist_egg import bdist_egg -from subprocess import check_call +try: + from wheel.bdist_wheel import bdist_wheel +except ImportError: + bdist_wheel = None if sys.platform == 'win32': from subprocess import list2cmdline @@ -33,197 +45,659 @@ def list2cmdline(cmd_list): return ' '.join(map(pipes.quote, cmd_list)) -# the name of the project -name = 'jupyterlab' +__version__ = '0.2.0' -here = osp.dirname(osp.abspath(__file__)) -is_repo = osp.exists(pjoin(here, '.git')) +# --------------------------------------------------------------------------- +# Top Level Variables +# --------------------------------------------------------------------------- -version_ns = {} -with io.open(pjoin(here, name, '_version.py'), encoding="utf8") as f: - exec(f.read(), {}, version_ns) +HERE = os.path.abspath(os.path.dirname(__file__)) +is_repo = os.path.exists(pjoin(HERE, '.git')) +node_modules = pjoin(HERE, 'node_modules') +SEPARATORS = os.sep if os.altsep is None else os.sep + os.altsep + +npm_path = ':'.join([ + pjoin(HERE, 'node_modules', '.bin'), + os.environ.get('PATH', os.defpath), +]) + +if "--skip-npm" in sys.argv: + print("Skipping npm install as requested.") + skip_npm = True + sys.argv.remove("--skip-npm") +else: + skip_npm = False -def run(cmd, *args, **kwargs): - """Echo a command before running it""" - log.info('> ' + list2cmdline(cmd)) - kwargs['shell'] = (sys.platform == 'win32') - return check_call(cmd, *args, **kwargs) +# --------------------------------------------------------------------------- +# Public Functions +# --------------------------------------------------------------------------- + +def get_version(file, name='__version__'): + """Get the version of the package from the given file by + executing it and extracting the given `name`. + """ + path = os.path.realpath(file) + version_ns = {} + with io.open(path, encoding="utf8") as f: + exec(f.read(), {}, version_ns) + return version_ns[name] + + +def ensure_python(specs): + """Given a list of range specifiers for python, ensure compatibility. + """ + if not isinstance(specs, (list, tuple)): + specs = [specs] + v = sys.version_info + part = '%s.%s' % (v.major, v.minor) + for spec in specs: + if part == spec: + return + try: + if eval(part + spec): + return + except SyntaxError: + pass + raise ValueError('Python version %s unsupported' % part) -#--------------------------------------------------------------------------- -# Find packages -#--------------------------------------------------------------------------- -def find_packages(): +def find_packages(top=HERE): """ Find all of the packages. """ packages = [] - for dir, subdirs, files in os.walk('jupyterlab'): - if 'node_modules' in subdirs: - subdirs.remove('node_modules') - package = dir.replace(osp.sep, '.') - if '__init__.py' not in files: - # not a package - continue - packages.append(package) + for d, dirs, _ in os.walk(top, followlinks=True): + if os.path.exists(pjoin(d, '__init__.py')): + packages.append(os.path.relpath(d, top).replace(os.path.sep, '.')) + elif d != top: + # Do not look for packages in subfolders if current is not a package + dirs[:] = [] return packages -#--------------------------------------------------------------------------- -# Find package data -#--------------------------------------------------------------------------- +def update_package_data(distribution): + """update build_py options to get package_data changes""" + build_py = distribution.get_command_obj('build_py') + build_py.finalize_options() + -def find_package_data(): +class bdist_egg_disabled(bdist_egg): + """Disabled version of bdist_egg + + Prevents setup.py install performing setuptools' default easy_install, + which it should never ever do. """ - Find package_data. + def run(self): + sys.exit("Aborting implicit building of eggs. Use `pip install .` " + " to install from source.") + + +def create_cmdclass(prerelease_cmd=None, package_data_spec=None, + data_files_spec=None): + """Create a command class with the given optional prerelease class. + + Parameters + ---------- + prerelease_cmd: (name, Command) tuple, optional + The command to run before releasing. + package_data_spec: dict, optional + A dictionary whose keys are the dotted package names and + whose values are a list of glob patterns. + data_files_spec: list, optional + A list of (path, dname, pattern) tuples where the path is the + `data_files` install path, dname is the source directory, and the + pattern is a glob pattern. + + Notes + ----- + We use specs so that we can find the files *after* the build + command has run. + + The package data glob patterns should be relative paths from the package + folder containing the __init__.py file, which is given as the package + name. + e.g. `dict(foo=['./bar/*', './baz/**'])` + + The data files directories should be absolute paths or relative paths + from the root directory of the repository. Data files are specified + differently from `package_data` because we need a separate path entry + for each nested folder in `data_files`, and this makes it easier to + parse. + e.g. `('share/foo/bar', 'pkgname/bizz, '*')` """ - theme_dirs = [] - for dir, subdirs, files in os.walk(pjoin('jupyterlab', 'themes')): - slice_len = len('jupyterlab' + os.sep) - theme_dirs.append(pjoin(dir[slice_len:], '*')) + wrapped = [prerelease_cmd] if prerelease_cmd else [] + if package_data_spec or data_files_spec: + wrapped.append('handle_files') + wrapper = functools.partial(_wrap_command, wrapped) + handle_files = _get_file_handler(package_data_spec, data_files_spec) - schema_dirs = [] - for dir, subdirs, files in os.walk(pjoin('jupyterlab', 'schemas')): - slice_len = len('jupyterlab' + os.sep) - schema_dirs.append(pjoin(dir[slice_len:], '*')) + if 'bdist_egg' in sys.argv: + egg = wrapper(bdist_egg, strict=True) + else: + egg = bdist_egg_disabled - return { - 'jupyterlab': ['build/*', '*.js', 'package.app.json', - 'yarn.lock', 'yarn.app.lock', '.yarnrc' - ] + theme_dirs + schema_dirs - } + cmdclass = dict( + build_py=wrapper(build_py, strict=is_repo), + bdist_egg=egg, + sdist=wrapper(sdist, strict=True), + handle_files=handle_files, + ) + if bdist_wheel: + cmdclass['bdist_wheel'] = wrapper(bdist_wheel, strict=True) -def find_data_files(): - """ - Find data_files. + cmdclass['develop'] = wrapper(develop, strict=True) + return cmdclass + + +def command_for_func(func): + """Create a command that calls the given function.""" + + class FuncCommand(BaseCommand): + + def run(self): + func() + update_package_data(self.distribution) + + return FuncCommand + + +def run(cmd, **kwargs): + """Echo a command before running it. Defaults to repo as cwd""" + log.info('> ' + list2cmdline(cmd)) + kwargs.setdefault('cwd', HERE) + kwargs.setdefault('shell', os.name == 'nt') + if not isinstance(cmd, (list, tuple)) and os.name != 'nt': + cmd = shlex.split(cmd) + cmd[0] = which(cmd[0]) + return subprocess.check_call(cmd, **kwargs) + + +def is_stale(target, source): + """Test whether the target file/directory is stale based on the source + file/directory. """ - if not os.path.exists(pjoin('jupyterlab', 'build')): + if not os.path.exists(target): + return True + target_mtime = recursive_mtime(target) or 0 + return compare_recursive_mtime(source, cutoff=target_mtime) + + +class BaseCommand(Command): + """Empty command because Command needs subclasses to override too much""" + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def get_inputs(self): + return [] + + def get_outputs(self): return [] - files = [] - static_files = os.listdir(pjoin('jupyterlab', 'build')) - files.append(('share/jupyter/lab/static', - ['jupyterlab/build/%s' % f for f in static_files])) +def combine_commands(*commands): + """Return a Command that combines several commands.""" - for dir, subdirs, fnames in os.walk(pjoin('jupyterlab', 'schemas')): - dir = dir.replace(os.sep, '/') - schema_files = [] - for fname in fnames: - schema_files.append('%s/%s' % (dir, fname)) - slice_len = len('jupyterlab/') - files.append(('share/jupyter/lab/%s' % dir[slice_len:], schema_files)) + class CombinedCommand(Command): + user_options = [] - for dir, subdirs, fnames in os.walk(pjoin('jupyterlab', 'themes')): - dir = dir.replace(os.sep, '/') - themes_files = [] - for fname in fnames: - themes_files.append('%s/%s' % (dir, fname)) - slice_len = len('jupyterlab/') - files.append(('share/jupyter/lab/%s' % dir[slice_len:], themes_files)) + def initialize_options(self): + self.commands = [] + for C in commands: + self.commands.append(C(self.distribution)) + for c in self.commands: + c.initialize_options() - return files + def finalize_options(self): + for c in self.commands: + c.finalize_options() + + def run(self): + for c in self.commands: + c.run() + return CombinedCommand -def js_prerelease(command, strict=False): - """decorator for building minified js/css prior to another command""" - class DecoratedCommand(command): +def compare_recursive_mtime(path, cutoff, newest=True): + """Compare the newest/oldest mtime for all files in a directory. + + Cutoff should be another mtime to be compared against. If an mtime that is + newer/older than the cutoff is found it will return True. + E.g. if newest=True, and a file in path is newer than the cutoff, it will + return True. + """ + if os.path.isfile(path): + mt = mtime(path) + if newest: + if mt > cutoff: + return True + elif mt < cutoff: + return True + for dirname, _, filenames in os.walk(path, topdown=False): + for filename in filenames: + mt = mtime(pjoin(dirname, filename)) + if newest: # Put outside of loop? + if mt > cutoff: + return True + elif mt < cutoff: + return True + return False + + +def recursive_mtime(path, newest=True): + """Gets the newest/oldest mtime for all files in a directory.""" + if os.path.isfile(path): + return mtime(path) + current_extreme = None + for dirname, dirnames, filenames in os.walk(path, topdown=False): + for filename in filenames: + mt = mtime(pjoin(dirname, filename)) + if newest: # Put outside of loop? + if mt >= (current_extreme or mt): + current_extreme = mt + elif mt <= (current_extreme or mt): + current_extreme = mt + return current_extreme + + +def mtime(path): + """shorthand for mtime""" + return os.stat(path).st_mtime + + +def install_npm(path=None, build_dir=None, source_dir=None, build_cmd='build', force=False, npm=None): + """Return a Command for managing an npm installation. + + Note: The command is skipped if the `--skip-npm` flag is used. + + Parameters + ---------- + path: str, optional + The base path of the node package. Defaults to the repo root. + build_dir: str, optional + The target build directory. If this and source_dir are given, + the JavaScript will only be build if necessary. + source_dir: str, optional + The source code directory. + build_cmd: str, optional + The npm command to build assets to the build_dir. + npm: str or list, optional. + The npm executable name, or a tuple of ['node', executable]. + """ + + class NPM(BaseCommand): + description = 'install package.json dependencies using npm' def run(self): - jsdeps = self.distribution.get_command_obj('jsdeps') - if not is_repo and all(osp.exists(t) for t in jsdeps.targets): - # sdist, nothing to do - command.run(self) + if skip_npm: + log.info('Skipping npm-installation') return + node_package = path or HERE + node_modules = pjoin(node_package, 'node_modules') + is_yarn = os.path.exists(pjoin(node_package, 'yarn.lock')) + + npm_cmd = npm - try: - self.distribution.run_command('jsdeps') - except Exception as e: - missing = [t for t in jsdeps.targets if not osp.exists(t)] - if strict or missing: - log.warn('js check failed') - if missing: - log.error('missing files: %s' % missing) - raise e + if npm is None: + if is_yarn: + npm_cmd = ['yarn'] else: - log.warn('js check failed (not a problem)') - log.warn(str(e)) - command.run(self) - return DecoratedCommand + npm_cmd = ['npm'] + if not which(npm_cmd[0]): + log.error("`{0}` unavailable. If you're running this command " + "using sudo, make sure `{0}` is availble to sudo" + .format(npm_cmd[0])) + return -def update_package_data(distribution): - """update build_py options to get package_data changes""" - build_py = distribution.get_command_obj('build_py') - build_py.finalize_options() + if force or is_stale(node_modules, pjoin(node_package, 'package.json')): + log.info('Installing build dependencies with npm. This may ' + 'take a while...') + run(npm_cmd + ['install'], cwd=node_package) + if build_dir and source_dir and not force: + should_build = is_stale(build_dir, source_dir) + else: + should_build = True + if should_build: + run(npm_cmd + ['run', build_cmd], cwd=node_package) + return NPM -class CheckAssets(Command): - description = 'check for required assets' - user_options = [] +def ensure_targets(targets): + """Return a Command that checks that certain files exist. - # Representative files that should exist after a successful build - targets = [ - pjoin(here, 'jupyterlab', 'build', 'release_data.json'), - pjoin(here, 'jupyterlab', 'build', 'main.bundle.js'), - pjoin(here, 'jupyterlab', 'schemas', '@jupyterlab', - 'shortcuts-extension', 'plugin.json'), - pjoin(here, 'jupyterlab', 'themes', '@jupyterlab', - 'theme-light-extension', - 'images', 'jupyterlab.svg') - ] + Raises a ValueError if any of the files are missing. - def initialize_options(self): - pass + Note: The check is skipped if the `--skip-npm` flag is used. + """ - def finalize_options(self): - pass + class TargetsCheck(BaseCommand): + def run(self): + if skip_npm: + log.info('Skipping target checks') + return + missing = [t for t in targets if not os.path.exists(t)] + if missing: + raise ValueError(('missing files: %s' % missing)) - def run(self): - for t in self.targets: - if not osp.exists(t): - msg = 'Missing file: %s' % t - raise ValueError(msg) + return TargetsCheck - target = pjoin(here, 'jupyterlab', 'build', 'release_data.json') - with open(target) as fid: - data = json.load(fid) - if (LooseVersion(data['version']) != - LooseVersion(version_ns['__version__'])): - msg = 'Release assets version mismatch, please run npm publish' - raise ValueError(msg) +# `shutils.which` function copied verbatim from the Python-3.3 source. +def which(cmd, mode=os.F_OK | os.X_OK, path=None): + """Given a command, mode, and a PATH string, return the path which + conforms to the given mode on the PATH, or None if there is no such + file. + `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result + of os.environ.get("PATH"), or can be overridden with a custom search + path. + """ - # update package data in case this created new files - update_package_data(self.distribution) + # Check that a given file can be accessed with the correct mode. + # Additionally check that `file` is not a directory, as on Windows + # directories pass the os.access check. + def _access_check(fn, mode): + return (os.path.exists(fn) and os.access(fn, mode) and + not os.path.isdir(fn)) + + # Short circuit. If we're given a full path which matches the mode + # and it exists, we're done here. + if _access_check(cmd, mode): + return cmd + + path = (path or os.environ.get("PATH", os.defpath)).split(os.pathsep) + + if sys.platform == "win32": + # The current directory takes precedence on Windows. + if os.curdir not in path: + path.insert(0, os.curdir) + + # PATHEXT is necessary to check on Windows. + pathext = os.environ.get("PATHEXT", "").split(os.pathsep) + # See if the given file matches any of the expected path extensions. + # This will allow us to short circuit when given "python.exe". + matches = [cmd for ext in pathext if cmd.lower().endswith(ext.lower())] + # If it does match, only test that one, otherwise we have to try + # others. + files = [cmd] if matches else [cmd + ext.lower() for ext in pathext] + else: + # On other platforms you don't have things like PATHEXT to tell you + # what file suffixes are executable, so just pass on cmd as-is. + files = [cmd] + + seen = set() + for dir in path: + dir = os.path.normcase(dir) + if dir not in seen: + seen.add(dir) + for thefile in files: + name = os.path.join(dir, thefile) + if _access_check(name, mode): + return name + return None + + +# --------------------------------------------------------------------------- +# Private Functions +# --------------------------------------------------------------------------- + + +def _wrap_command(cmds, cls, strict=True): + """Wrap a setup command + + Parameters + ---------- + cmds: list(str) + The names of the other commands to run prior to the command. + strict: boolean, optional + Wether to raise errors when a pre-command fails. + """ + class WrappedCommand(cls): + def run(self): + if not getattr(self, 'uninstall', None): + try: + [self.run_command(cmd) for cmd in cmds] + except Exception: + if strict: + raise + else: + pass + # update package data + update_package_data(self.distribution) + + result = cls.run(self) + return result + return WrappedCommand + + +def _get_file_handler(package_data_spec, data_files_spec): + """Get a package_data and data_files handler command. + """ + class FileHandler(BaseCommand): -class bdist_egg_disabled(bdist_egg): - """Disabled version of bdist_egg - Prevents setup.py install performing setuptools' default easy_install, - which it should never ever do. + def run(self): + package_data = self.distribution.package_data + package_spec = package_data_spec or dict() + + for (key, patterns) in package_spec.items(): + package_data[key] = _get_package_data(key, patterns) + + self.distribution.data_files = _get_data_files( + data_files_spec, self.distribution.data_files + ) + + return FileHandler + + +def _get_data_files(data_specs, existing): + """Expand data file specs into valid data files metadata. + + Parameters + ---------- + data_specs: list of tuples + See [createcmdclass] for description. + existing: list of tuples + The existing distrubution data_files metadata. + + Returns + ------- + A valid list of data_files items. """ - def run(self): - sys.exit("Aborting implicit building of eggs. Use `pip install .` to install from source.") + # Extract the existing data files into a staging object. + file_data = defaultdict(list) + for (path, files) in existing or []: + file_data[path] = files + + # Extract the files and assign them to the proper data + # files path. + for (path, dname, pattern) in data_specs or []: + dname = dname.replace(os.sep, '/') + offset = len(dname) + 1 + + files = _get_files(pjoin(dname, pattern)) + for fname in files: + # Normalize the path. + root = os.path.dirname(fname) + full_path = '/'.join([path, root[offset:]]) + if full_path.endswith('/'): + full_path = full_path[:-1] + file_data[full_path].append(fname) + + # Construct the data files spec. + data_files = [] + for (path, files) in file_data.items(): + data_files.append((path, files)) + return data_files + + +def _get_files(file_patterns, top=HERE): + """Expand file patterns to a list of paths. + + Parameters + ----------- + file_patterns: list or str + A list of glob patterns for the data file locations. + The globs can be recursive if they include a `**`. + They should be relative paths from the top directory or + absolute paths. + top: str + the directory to consider for data files + + Note: + Files in `node_modules` are ignored. + """ + if not isinstance(file_patterns, (list, tuple)): + file_patterns = [file_patterns] + + for i, p in enumerate(file_patterns): + if os.path.isabs(p): + file_patterns[i] = os.path.relpath(p, top) + matchers = [_compile_pattern(p) for p in file_patterns] -class custom_egg_info(egg_info): - """Prune JavaScript folders from egg_info to avoid locking up pip. + files = set() + + for root, dirnames, filenames in os.walk(top): + # Don't recurse into node_modules + if 'node_modules' in dirnames: + dirnames.remove('node_modules') + for m in matchers: + for filename in filenames: + fn = os.path.relpath(pjoin(root, filename), top) + if m(fn): + files.add(fn.replace(os.sep, '/')) + + return list(files) + + +def _get_package_data(root, file_patterns=None): + """Expand file patterns to a list of `package_data` paths. + + Parameters + ----------- + root: str + The relative path to the package root from `HERE`. + file_patterns: list or str, optional + A list of glob patterns for the data file locations. + The globs can be recursive if they include a `**`. + They should be relative paths from the root or + absolute paths. If not given, all files will be used. + + Note: + Files in `node_modules` are ignored. """ + if file_patterns is None: + file_patterns = ['*'] + return _get_files(file_patterns, pjoin(HERE, root)) - def run(self): - folders = ['examples', 'packages', 'test', 'node_modules'] - folders = [f for f in folders if os.path.exists(pjoin(here, f))] - tempdir = tempfile.mkdtemp() - for folder in folders: - shutil.move(pjoin(here, folder), tempdir) - value = egg_info.run(self) - for folder in folders: - shutil.move(pjoin(tempdir, folder), here) - shutil.rmtree(tempdir) - return value + +def _compile_pattern(pat, ignore_case=True): + """Translate and compile a glob pattern to a regular expression matcher.""" + if isinstance(pat, bytes): + pat_str = pat.decode('ISO-8859-1') + res_str = _translate_glob(pat_str) + res = res_str.encode('ISO-8859-1') + else: + res = _translate_glob(pat) + flags = re.IGNORECASE if ignore_case else 0 + return re.compile(res, flags=flags).match + + +def _iexplode_path(path): + """Iterate over all the parts of a path. + + Splits path recursively with os.path.split(). + """ + (head, tail) = os.path.split(path) + if not head or (not tail and head == path): + if head: + yield head + if tail or not head: + yield tail + return + for p in _iexplode_path(head): + yield p + yield tail + + +def _translate_glob(pat): + """Translate a glob PATTERN to a regular expression.""" + translated_parts = [] + for part in _iexplode_path(pat): + translated_parts.append(_translate_glob_part(part)) + os_sep_class = '[%s]' % re.escape(SEPARATORS) + res = _join_translated(translated_parts, os_sep_class) + return '{res}\\Z(?ms)'.format(res=res) + + +def _join_translated(translated_parts, os_sep_class): + """Join translated glob pattern parts. + + This is different from a simple join, as care need to be taken + to allow ** to match ZERO or more directories. + """ + res = '' + for part in translated_parts[:-1]: + if part == '.*': + # drop separator, since it is optional + # (** matches ZERO or more dirs) + res += part + else: + res += part + os_sep_class + + if translated_parts[-1] == '.*': + # Final part is ** + res += '.+' + # Follow stdlib/git convention of matching all sub files/directories: + res += '({os_sep_class}?.*)?'.format(os_sep_class=os_sep_class) + else: + res += translated_parts[-1] + return res + + +def _translate_glob_part(pat): + """Translate a glob PATTERN PART to a regular expression.""" + # Code modified from Python 3 standard lib fnmatch: + if pat == '**': + return '.*' + i, n = 0, len(pat) + res = [] + while i < n: + c = pat[i] + i = i + 1 + if c == '*': + # Match anything but path separators: + res.append('[^%s]*' % SEPARATORS) + elif c == '?': + res.append('[^%s]?' % SEPARATORS) + elif c == '[': + j = i + if j < n and pat[j] == '!': + j = j + 1 + if j < n and pat[j] == ']': + j = j + 1 + while j < n and pat[j] != ']': + j = j + 1 + if j >= n: + res.append('\\[') + else: + stuff = pat[i:j].replace('\\', '\\\\') + i = j + 1 + if stuff[0] == '!': + stuff = '^' + stuff[1:] + elif stuff[0] == '^': + stuff = '\\' + stuff + res.append('[%s]' % stuff) + else: + res.append(re.escape(c)) + return ''.join(res)
Extension link failure I am getting an error on master when running `jupyter labextension link .`: ```bash > /home/ian/anaconda3/envs/jupyter/bin/jlpm pack . yarn pack v1.3.2 error Couldn't find a package.json file in "/tmp/tmp96ed_isl" info Visit https://yarnpkg.com/en/docs/cli/pack for documentation about this command. Traceback (most recent call last): File "/home/ian/anaconda3/envs/jupyter/bin/jupyter-labextension", line 11, in <module> load_entry_point('jupyterlab', 'console_scripts', 'jupyter-labextension')() File "/home/ian/anaconda3/envs/jupyter/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/home/ian/anaconda3/envs/jupyter/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance app.start() File "/home/ian/jupyter/jupyterlab/jupyterlab/labextensions.py", line 179, in start super(LabExtensionApp, self).start() File "/home/ian/anaconda3/envs/jupyter/lib/python3.6/site-packages/jupyter_core/application.py", line 255, in start self.subapp.start() File "/home/ian/jupyter/jupyterlab/jupyterlab/labextensions.py", line 94, in start for arg in self.extra_args] File "/home/ian/jupyter/jupyterlab/jupyterlab/labextensions.py", line 94, in <listcomp> for arg in self.extra_args] File "/home/ian/jupyter/jupyterlab/jupyterlab/commands.py", line 204, in link_package handler.link_package(path) File "/home/ian/jupyter/jupyterlab/jupyterlab/commands.py", line 469, in link_package info = self._extract_package(path, tempdir) File "/home/ian/jupyter/jupyterlab/jupyterlab/commands.py", line 953, in _extract_package raise ValueError('Extension failed to pack') ValueError: Extension failed to pack ``` labextension uninstall does not work on incompatible extensions I am trying to work on an extension, and after upgrading jupyterlab I've discovered that another extension [@jupyterlab/github](https://github.com/jupyterlab/jupyterlab-github) is now out of date and its dependencies do not resolve properly. I discovered that disabling this extension still doesn't allow jupyterlab to run. So, I attempted to uninstall it with ```bash jupyter labextension uninstall @jupyterlab/github ``` And that raised an error finishing with: ``` JupyterLab Extension Package >=0.12.0-0 <0.13.0-0 >=0.11.0-0 <0.12.0-0 @jupyterlab/application >=0.12.4-0 <0.13.0-0 >=0.11.0-0 <0.12.0-0 @jupyterlab/apputils >=0.12.0-0 <0.13.0-0 >=0.11.0-0 <0.12.0-0 @jupyterlab/coreutils >=0.12.0-0 <0.13.0-0 >=0.11.0-0 <0.12.0-0 @jupyterlab/docmanager >=0.12.0-0 <0.13.0-0 >=0.11.0-0 <0.12.0-0 @jupyterlab/filebrowser >=0.51.0-0 <0.52.0-0 >=0.50.0-0 <0.51.0-0 @jupyterlab/services ``` …the incompatibility of which is exactly why I wanted to uninstall the extension. Is there any way around this? @ian-r-rose happens to be awesome and has already released a version with upgraded dependencies. But it should be possible to get back to a state where you can have a working version of jupyterlab even if one of your extensions is out-of-date. I'm sure there's a way to do that, but I can't easily figure it out…
Hi @mpacer, sorry I lost the bubble on issues. You can manually remove the extension for now. The path can be found using `jupyter lab paths` and going to the `<app_dir>/extensions` directory.
2017-11-21T22:18:45Z
[]
[]
Traceback (most recent call last): File "/home/ian/anaconda3/envs/jupyter/bin/jupyter-labextension", line 11, in <module> load_entry_point('jupyterlab', 'console_scripts', 'jupyter-labextension')() File "/home/ian/anaconda3/envs/jupyter/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/home/ian/anaconda3/envs/jupyter/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance app.start() File "/home/ian/jupyter/jupyterlab/jupyterlab/labextensions.py", line 179, in start super(LabExtensionApp, self).start() File "/home/ian/anaconda3/envs/jupyter/lib/python3.6/site-packages/jupyter_core/application.py", line 255, in start self.subapp.start() File "/home/ian/jupyter/jupyterlab/jupyterlab/labextensions.py", line 94, in start for arg in self.extra_args] File "/home/ian/jupyter/jupyterlab/jupyterlab/labextensions.py", line 94, in <listcomp> for arg in self.extra_args] File "/home/ian/jupyter/jupyterlab/jupyterlab/commands.py", line 204, in link_package handler.link_package(path) File "/home/ian/jupyter/jupyterlab/jupyterlab/commands.py", line 469, in link_package info = self._extract_package(path, tempdir) File "/home/ian/jupyter/jupyterlab/jupyterlab/commands.py", line 953, in _extract_package raise ValueError('Extension failed to pack') ValueError: Extension failed to pack
8,575
jupyterlab/jupyterlab
jupyterlab__jupyterlab-5196
7a5a27103c7a03f33537862acd7e5d0c0640de4f
diff --git a/jupyterlab/commands.py b/jupyterlab/commands.py --- a/jupyterlab/commands.py +++ b/jupyterlab/commands.py @@ -972,28 +972,9 @@ def format_path(path): errors = compat_errors[key] if errors: if not silent: - msg = _format_compatibility_errors( - key, value['version'], errors + _log_single_compat_errors( + logger, key, value['version'], errors ) - name = value['name'] - # Add some helpful text for the benefit of the user: - try: - version = self._latest_compatible_package_version(name) - except URLError: - version = None - if version is not None: - msg = ( - '{0}\n\n' - 'A compatible version exists ({1}).\n' - 'Try running "jupyter lab update {2}".' - ).format(msg, version, name) - else: - conflicts = '\n'.join(msg.splitlines()[2:]) - msg = ''.join(( - self._format_no_compatible_package_version(name), - "\n\n", - conflicts)) - logger.warn(msg + '\n') continue data['dependencies'][key] = format_path(value['path']) @@ -1090,7 +1071,7 @@ def _get_extensions_in_dir(self, dname, core_data): # homepage, repository are optional if 'homepage' in data: url = data['homepage'] - elif 'repository' in data: + elif 'repository' in data and isinstance(data['repository'], dict): url = data['repository'].get('url', '') else: url = '' @@ -1173,9 +1154,10 @@ def _list_extensions(self, info, ext_type): dname = info['%s_dir' % ext_type] + error_accumulator = {} + logger.info(' %s dir: %s' % (ext_type, dname)) for name in sorted(names): - logger.info(name) data = info['extensions'][name] version = data['version'] errors = info['compat_errors'][name] @@ -1192,10 +1174,10 @@ def _list_extensions(self, info, ext_type): extra += '*' logger.info(' %s v%s%s' % (name, version, extra)) if errors: - msg = _format_compatibility_errors( - name, version, errors - ) - logger.warn(msg + '\n') + error_accumulator[name] = (version, errors) + + # Write all errors at end: + _log_multiple_compat_errors(logger, error_accumulator) def _read_build_config(self): """Get the build config data for the app dir. @@ -1720,6 +1702,67 @@ def _format_compatibility_errors(name, version, errors): return msg +def _log_multiple_compat_errors(logger, errors_map): + """Log compatability errors for multiple extensions at once""" + + outdated = [] + others = [] + + for name, (version, errors) in errors_map.items(): + age = _compat_error_age(errors) + if age > 0: + outdated.append(name) + else: + others.append(name) + + if outdated: + logger.warn('\n '.join( + ['\n The following extension are outdated:'] + + outdated + + ['\n Consider running "jupyter labextension update --all" ' + 'to check for updates.\n'] + )) + + for name in others: + version, errors = errors_map[name] + msg = _format_compatibility_errors(name, version, errors) + logger.warn(msg + '\n') + + +def _log_single_compat_errors(logger, name, version, errors): + """Log compatability errors for a single extension""" + + age = _compat_error_age(errors) + if age > 0: + logger.warn('The extension "%s" is outdated.\n', name) + else: + msg = _format_compatibility_errors(name, version, errors) + logger.warn(msg + '\n') + + +def _compat_error_age(errors): + """Compare all incompatabilites for an extension. + + Returns a number > 0 if all extensions are older than that supported by lab. + Returns a number < 0 if all extensions are newer than that supported by lab. + Returns 0 otherwise (i.e. a mix). + """ + # Do any extensions depend on too old lab packages? + any_older = False + # Do any extensions depend on too new lab packages? + any_newer = False + + for _, jlab, ext in errors: + c = _compare_ranges(ext, jlab) + any_newer = any_newer or c < 0 + any_older = any_older or c > 0 + if any_older and not any_newer: + return 1 + elif any_newer and not any_older: + return -1 + return 0 + + def _get_core_extensions(): """Get the core extensions. """
Upgrading JupyterLab to 0.34.1 causes crash on startup I tried to update the version of Jupyter Lab with conda, and after installing 0.34.1. the application does not start anymore, with the following error message appearing after any jupyter lab command: ``` >>> jupyter lab Traceback (most recent call last): File "/Users/vilimstich/anaconda3/bin/jupyter-lab", line 7, in <module> from jupyterlab.labapp import main File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/labapp.py", line 32, in <module> app_version = get_app_version() File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 343, in get_app_version handler = _AppHandler(app_dir) File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 381, in __init__ self.info = self._get_app_info() File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 804, in _get_app_info info['extensions'] = extensions = self._get_extensions(core_data) File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 1068, in _get_extensions extensions = self._get_extensions_in_dir(self.sys_dir, core_data) File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 1094, in _get_extensions_in_dir url = data['repository'].get('url', '') AttributeError: 'str' object has no attribute 'get' ``` Reverting to 0.33.8 fixes the problem. I am running OS X.
Yeah package.json is pretty wild west, it turns out. Some other extension causes a failure on retrieving `value["name"]`... In 0.34.0, it just warned and moved on... https://github.com/jupyterlab/jupyterlab/blob/b6c4d8f8b51f4a6938ad6acc6a6ff328948196d6/jupyterlab/commands.py#L978 I didn't know you could actually build a package without a name... Or if that's even what's happening there... Parsing the the name failed? At least we might wrap each of these loops in a try/except so it doesn't break the build. At the sprints, it may be worth exploring a nightly that tries to install all discoverable extensions and reports on its success a la cargo. Or a bot a la conda-forge's auto tick, that politely attempts to PR package.json changes with updated version pins... and linting! @bollwyvl That code was recently merged, and not extensively tested. I guess all uses of `name` should use `key` instead? Ref #5174 @vilim The error occurs because the code assumes that the "[repository](https://docs.npmjs.com/files/package.json#repository)" field is an object/dict. Is there an extension where this is not the case? I guess the code could be hardened to not fail completely if one extension is (partially) invalid though. Package.json is one of those formats that just... is... Here's a notional schema, but there are definitely installable, production-deployed packages that don't conform: http://json.schemastore.org/package I guess we plan on _at least_ that level of crazy, but we basically can't trust anything. When it actually hits the big registry in the sky, it is normalized, but let's _please_ not add any _more_ reliance on live servers for end users. We have ajv and Jsonschema just hanging around. If we're talking just labextensions, we could adopt/ship the above schema and add our own jupyter fields, and not install anything that doesn't conform such that you couldn't even _develop_ a non-conforming package, even if you could still ship it. As to key/name... Traveling, haven't been able to look into it!
2018-08-23T11:43:08Z
[]
[]
Traceback (most recent call last): File "/Users/vilimstich/anaconda3/bin/jupyter-lab", line 7, in <module> from jupyterlab.labapp import main File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/labapp.py", line 32, in <module> app_version = get_app_version() File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 343, in get_app_version handler = _AppHandler(app_dir) File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 381, in __init__ self.info = self._get_app_info() File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 804, in _get_app_info info['extensions'] = extensions = self._get_extensions(core_data) File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 1068, in _get_extensions extensions = self._get_extensions_in_dir(self.sys_dir, core_data) File "/Users/vilimstich/anaconda3/lib/python3.6/site-packages/jupyterlab/commands.py", line 1094, in _get_extensions_in_dir url = data['repository'].get('url', '') AttributeError: 'str' object has no attribute 'get'
8,595
jupyterlab/jupyterlab
jupyterlab__jupyterlab-5252
43a0a2caa136f0b8f68efdd341e8211b76fcc29d
diff --git a/jupyterlab/labapp.py b/jupyterlab/labapp.py --- a/jupyterlab/labapp.py +++ b/jupyterlab/labapp.py @@ -203,7 +203,13 @@ def init_webapp(self, *args, **kwargs): settings = self.web_app.settings if 'page_config_data' not in settings: settings['page_config_data'] = {} - settings['page_config_data']['quit_button'] = self.quit_button + + # Handle quit button with support for Notebook < 5.6 + if hasattr(self, 'quit_button'): + quit_button = self.quit_button + else: + quit_button = True + settings['page_config_data']['quit_button'] = quit_button def init_server_extensions(self): """Load any extensions specified by config.
labapp.py # AttributeError: 'LabApp' object has no attribute 'quit_button' update jupyterlab with pip - after that i get this error. After removing the line 206 - the app runs normaly ``` Traceback (most recent call last): File "/home/rened/anaconda3/bin/jupyter-lab", line 11, in <module> sys.exit(main()) File "/home/rened/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/home/rened/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance app.initialize(argv) File "<decorator-gen-7>", line 2, in initialize File "/home/rened/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error return method(app, *args, **kwargs) File "/home/rened/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1296, in initialize self.init_webapp() File "/home/rened/anaconda3/lib/python3.6/site-packages/jupyterlab/labapp.py", line 206, in init_webapp *settings['page_config_data']['quit_button'] = self.quit_button* AttributeError: 'LabApp' object has no attribute 'quit_button' ```
Having the exact same issue and same solution works. Ah, it looks like this property was renamed in Notebook 5.6. I'll update our minimum compatible version.
2018-08-31T11:35:07Z
[]
[]
Traceback (most recent call last): File "/home/rened/anaconda3/bin/jupyter-lab", line 11, in <module> sys.exit(main()) File "/home/rened/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/home/rened/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance app.initialize(argv) File "<decorator-gen-7>", line 2, in initialize File "/home/rened/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error return method(app, *args, **kwargs) File "/home/rened/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1296, in initialize self.init_webapp() File "/home/rened/anaconda3/lib/python3.6/site-packages/jupyterlab/labapp.py", line 206, in init_webapp *settings['page_config_data']['quit_button'] = self.quit_button* AttributeError: 'LabApp' object has no attribute 'quit_button'
8,596
jupyterlab/jupyterlab
jupyterlab__jupyterlab-5400
8a141cadf904150b01886f189a10a3143676a1eb
diff --git a/jupyterlab/commands.py b/jupyterlab/commands.py --- a/jupyterlab/commands.py +++ b/jupyterlab/commands.py @@ -246,9 +246,11 @@ def update_extension(name=None, all_=False, app_dir=None, logger=None): return handler.update_extension(name) -def clean(app_dir=None): +def clean(app_dir=None, logger=None): """Clean the JupyterLab application directory.""" + logger = _ensure_logger(logger) app_dir = app_dir or get_app_dir() + logger.info('Cleaning %s...', app_dir) if app_dir == pjoin(HERE, 'dev'): raise ValueError('Cannot clean the dev app') if app_dir == pjoin(HERE, 'core'): @@ -256,7 +258,8 @@ def clean(app_dir=None): for name in ['staging']: target = pjoin(app_dir, name) if osp.exists(target): - shutil.rmtree(target) + _rmtree(target, logger) + logger.info('Success!') def build(app_dir=None, name=None, version=None, public_url=None, @@ -845,7 +848,7 @@ def _populate_staging(self, name=None, version=None, public_url=None, staging = pjoin(app_dir, 'staging') if clean and osp.exists(staging): self.logger.info("Cleaning %s", staging) - shutil.rmtree(staging) + _rmtree(staging, self.logger) self._ensure_app_dirs() if not version: @@ -858,7 +861,7 @@ def _populate_staging(self, name=None, version=None, public_url=None, with open(pkg_path) as fid: data = json.load(fid) if data['jupyterlab'].get('version', '') != version: - shutil.rmtree(staging) + _rmtree(staging, self.logger) os.makedirs(staging) for fname in ['index.js', 'webpack.config.js', @@ -876,7 +879,7 @@ def _populate_staging(self, name=None, version=None, public_url=None, # Ensure a clean templates directory templates = pjoin(staging, 'templates') if osp.exists(templates): - shutil.rmtree(templates) + _rmtree(templates, self.logger) try: shutil.copytree(pjoin(HERE, 'staging', 'templates'), templates) @@ -892,7 +895,7 @@ def _populate_staging(self, name=None, version=None, public_url=None, # Ensure a clean linked packages directory. linked_dir = pjoin(staging, 'linked_packages') if osp.exists(linked_dir): - shutil.rmtree(linked_dir) + _rmtree(linked_dir, self.logger) os.makedirs(linked_dir) # Template the package.json file. @@ -1500,6 +1503,14 @@ def _normalize_path(extension): return extension +def _rmtree(path, logger): + """Remove a tree, logging errors""" + def onerror(*exc_info): + logger.debug('Error in rmtree', exc_info=exc_info) + + shutil.rmtree(path, onerror=onerror) + + def _validate_extension(data): """Detect if a package is an extension using its metadata. diff --git a/jupyterlab/labapp.py b/jupyterlab/labapp.py --- a/jupyterlab/labapp.py +++ b/jupyterlab/labapp.py @@ -95,7 +95,7 @@ class LabCleanApp(JupyterApp): app_dir = Unicode('', config=True, help='The app directory to clean') def start(self): - clean(self.app_dir) + clean(self.app_dir, logger=self.log) class LabPathApp(JupyterApp):
JupyterLab clean fails On installing a new release of jupyter lab, the clean command fails: ``` >>> jupyter lab clean ``` <details><summary>Command Line Output</summary> <pre> Traceback (most recent call last): File "C:\Users\vilim\anaconda3\Scripts\jupyter-lab-script.py", line 10, in <module> sys.exit(main()) File "C:\Users\vilim\anaconda3\lib\site-packages\jupyter_core\application.py", line 266, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "C:\Users\vilim\anaconda3\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance app.start() File "C:\Users\vilim\anaconda3\lib\site-packages\notebook\notebookapp.py", line 1605, in start super(NotebookApp, self).start() File "C:\Users\vilim\anaconda3\lib\site-packages\jupyter_core\application.py", line 255, in start self.subapp.start() File "C:\Users\vilim\anaconda3\lib\site-packages\jupyterlab\labapp.py", line 88, in start clean(self.app_dir) File "C:\Users\vilim\anaconda3\lib\site-packages\jupyterlab\commands.py", line 259, in clean shutil.rmtree(target) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 494, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) [Previous line repeated 5 more times] File "C:\Users\vilim\anaconda3\lib\shutil.py", line 389, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 387, in _rmtree_unsafe os.unlink(fullname) FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\vilim\\anaconda3\\share\\jupyter\\lab\\staging\\node_modules\\jupyter-matplotlib\\node_modules\\.cache\\uglifyjs-webpack-plugin\\content-v2\\sha512\\1b\\7f\\707b368483003ea3ed7d06267d3b1a046d0475617913b477c2852ba74d40e951e6eaf980d95d93160914c59bc9e3e8732d04f0339fbe7ea9348b943f2fc6' </pre> </details> I am running Windows 10, and I have the newest release of JupyterLab, 0.34.12 installed.
Thanks for the report, @vilim! We'll get this fixed for the upcoming release. Dev note: we just need to wrap `rmtree` in a try/except because it tends to throw spurious errors.
2018-09-28T10:40:24Z
[]
[]
Traceback (most recent call last): File "C:\Users\vilim\anaconda3\Scripts\jupyter-lab-script.py", line 10, in <module> sys.exit(main()) File "C:\Users\vilim\anaconda3\lib\site-packages\jupyter_core\application.py", line 266, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "C:\Users\vilim\anaconda3\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance app.start() File "C:\Users\vilim\anaconda3\lib\site-packages\notebook\notebookapp.py", line 1605, in start super(NotebookApp, self).start() File "C:\Users\vilim\anaconda3\lib\site-packages\jupyter_core\application.py", line 255, in start self.subapp.start() File "C:\Users\vilim\anaconda3\lib\site-packages\jupyterlab\labapp.py", line 88, in start clean(self.app_dir) File "C:\Users\vilim\anaconda3\lib\site-packages\jupyterlab\commands.py", line 259, in clean shutil.rmtree(target) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 494, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) [Previous line repeated 5 more times] File "C:\Users\vilim\anaconda3\lib\shutil.py", line 389, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File "C:\Users\vilim\anaconda3\lib\shutil.py", line 387, in _rmtree_unsafe os.unlink(fullname) FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\vilim\\anaconda3\\share\\jupyter\\lab\\staging\\node_modules\\jupyter-matplotlib\\node_modules\\.cache\\uglifyjs-webpack-plugin\\content-v2\\sha512\\1b\\7f\\707b368483003ea3ed7d06267d3b1a046d0475617913b477c2852ba74d40e951e6eaf980d95d93160914c59bc9e3e8732d04f0339fbe7ea9348b943f2fc6'
8,598
jupyterlab/jupyterlab
jupyterlab__jupyterlab-7125
e7d5441f745bc96741a168c187cd1b5508489a69
diff --git a/jupyterlab/commands.py b/jupyterlab/commands.py --- a/jupyterlab/commands.py +++ b/jupyterlab/commands.py @@ -554,7 +554,7 @@ def build(self, name=None, version=None, static_url=None, 'prod') command = ':'.join(parts) - self.logger.info(f'Building jupyterlab assets ({command})') + self.logger.info('Building jupyterlab assets (%s)'%command) # Set up the build directory. app_dir = self.app_dir
Jupyterlab 1.1.0 not compatible with Python 3.5 due to f-string usage? <!-- Welcome! Before creating a new issue: * Search for relevant issues * Follow the issue reporting guidelines: https://jupyterlab.readthedocs.io/en/latest/getting_started/issue.html --> ## Description Jupyterlab 1.1.0 hits a `SyntaxError` when run on Python 3.5.2 (Ubuntu 16.04 Python 3 via apt): ``` Traceback (most recent call last): File "/usr/local/bin/jupyter-lab", line 6, in <module> from jupyterlab.labapp import main File "/usr/local/lib/python3.5/dist-packages/jupyterlab/labapp.py", line 22, in <module> from .commands import ( File "/usr/local/lib/python3.5/dist-packages/jupyterlab/commands.py", line 557 self.logger.info(f'Building jupyterlab assets ({command})') ^ SyntaxError: invalid syntax ``` This appears to be due to the use of an f-string in one of the modules, which will only work in Python 3.6+: [commands.py](https://github.com/jupyterlab/jupyterlab/blame/v1.1.0/jupyterlab/commands.py#L557). According to the [changelog](https://jupyterlab.readthedocs.io/en/stable/getting_started/changelog.html#v1-1-0), JupyterLab v1.1.0 should still support 3.5+. ## Context - Operating System and version: Ubuntu 16.04 LTS - Browser and version: Firefox 68.0.2 - JupyterLab version: 1.1.0
Or even more directly, setup.py and the conda-forge package indicates python >=3.5: https://github.com/jupyterlab/jupyterlab/blob/master/setup.py#L28 https://github.com/conda-forge/jupyterlab-feedstock/blob/3d04ed845b32a57705d193278ea928771af41e44/recipe/meta.yaml#L30
2019-08-29T23:17:01Z
[]
[]
Traceback (most recent call last): File "/usr/local/bin/jupyter-lab", line 6, in <module> from jupyterlab.labapp import main File "/usr/local/lib/python3.5/dist-packages/jupyterlab/labapp.py", line 22, in <module> from .commands import ( File "/usr/local/lib/python3.5/dist-packages/jupyterlab/commands.py", line 557 self.logger.info(f'Building jupyterlab assets ({command})') ^ SyntaxError: invalid syntax
8,622
jupyterlab/jupyterlab
jupyterlab__jupyterlab-946
b6eb769eef85f8fa47d73946227ffbee7305f0b1
diff --git a/jupyterlab/labapp.py b/jupyterlab/labapp.py --- a/jupyterlab/labapp.py +++ b/jupyterlab/labapp.py @@ -31,6 +31,20 @@ def get_labextensions(parent=None): class LabApp(NotebookApp): + description = """ + JupyterLab - An extensible computational environment for Jupyter. + + This launches a Tornado based HTML Server that serves up an + HTML5/Javascript JupyterLab client. + """ + + examples = """ + jupyter lab # start JupyterLab + jupyter lab --certfile=mycert.pem # use SSL/TLS certificate + """ + + subcommands = dict() + default_url = Unicode('/lab', config=True, help="The default URL to redirect to from `/`" ) diff --git a/jupyterlab/labextensions.py b/jupyterlab/labextensions.py --- a/jupyterlab/labextensions.py +++ b/jupyterlab/labextensions.py @@ -584,7 +584,6 @@ def _log_format_default(self): aliases = { "prefix" : "InstallLabExtensionApp.prefix", "labextensions" : "InstallLabExtensionApp.labextensions_dir", - "destination" : "InstallLabExtensionApp.destination", } class InstallLabExtensionApp(BaseLabExtensionApp): @@ -593,7 +592,8 @@ class InstallLabExtensionApp(BaseLabExtensionApp): Usage - jupyter labextension install path|url [--user|--sys-prefix] + jupyter labextension install /path/to/myextension myextension [--user|--sys-prefix] + jupyter labextension install --py myextensionPyPackage [--user|--sys-prefix] This copies a file or a folder into the Jupyter labextensions directory. If a URL is given, it will be downloaded. @@ -603,8 +603,8 @@ class InstallLabExtensionApp(BaseLabExtensionApp): """ examples = """ - jupyter labextension install /path/to/myextension name - jupyter labextension install --py extensionPyPackage + jupyter labextension install /path/to/myextension myextension + jupyter labextension install --py myextensionPyPackage """ aliases = aliases flags = flags @@ -676,15 +676,15 @@ class UninstallLabExtensionApp(BaseLabExtensionApp): Usage - jupyter labextension uninstall name - jupyter labextension uninstall --py extensionPyPackage + jupyter labextension uninstall myextension + jupyter labextension uninstall --py myextensionPyPackage This uninstalls a labextension. """ examples = """ - jupyter labextension uninstall name - jupyter labextension uninstall --py extensionPyPackage + jupyter labextension uninstall myextension + jupyter labextension uninstall --py myextensionPyPackage """ aliases = { @@ -799,7 +799,7 @@ class EnableLabExtensionApp(ToggleLabExtensionApp): Enable a labextension in frontend configuration. Usage - jupyter labextension enable [--system|--sys-prefix] + jupyter labextension enable myextension [--system|--sys-prefix] """ _toggle_value = True @@ -811,7 +811,7 @@ class DisableLabExtensionApp(ToggleLabExtensionApp): Enable a labextension in frontend configuration. Usage - jupyter labextension disable [--system|--sys-prefix] + jupyter labextension disable myextension [--system|--sys-prefix] """ _toggle_value = None
Labextension CLI exception for help Running `jupyter labextension install --help` gives the following traceback after printing (parts of?) the normal help text. ``` python > jupyter labextension install --help Install JupyterLab extensions <snip normal output> --debug set log level to logging.DEBUG (maximize logging output) --sys-prefix Use sys.prefix as the prefix for installing labextensions (for environments, packaging) Traceback (most recent call last): File "C:\Miniconda3\Scripts\jupyter-labextension-script.py", line 9, in <module> load_entry_point('jupyterlab==0.3.0', 'console_scripts', 'jupyter-labextension')() File "c:\miniconda3\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 595, in launch_instance app.initialize(argv) File "<decorator-gen-6>", line 2, in initialize File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\jupyter_core\application.py", line 239, in initialize self.parse_command_line(argv) File "<decorator-gen-4>", line 2, in parse_command_line File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 488, in parse_command_line return self.initialize_subcommand(subc, subargv) File "<decorator-gen-3>", line 2, in initialize_subcommand File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 426, in initialize_subcommand self.subapp.initialize(argv) File "<decorator-gen-6>", line 2, in initialize File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\jupyter_core\application.py", line 239, in initialize self.parse_command_line(argv) File "<decorator-gen-4>", line 2, in parse_command_line File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 500, in parse_command_line self.print_help('--help-all' in interpreted_argv) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 360, in print_help self.print_options() File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 331, in print_options self.print_alias_help() File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 297, in print_alias_help trait = cls.class_traits(config=True)[traitname] KeyError: 'destination' ```
Partly related: Running `jupyter lab --help` still has a few left overs from copy-paste from notebook, e.g. the examples section.
2016-09-23T16:05:58Z
[]
[]
Traceback (most recent call last): File "C:\Miniconda3\Scripts\jupyter-labextension-script.py", line 9, in <module> load_entry_point('jupyterlab==0.3.0', 'console_scripts', 'jupyter-labextension')() File "c:\miniconda3\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 595, in launch_instance app.initialize(argv) File "<decorator-gen-6>", line 2, in initialize File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\jupyter_core\application.py", line 239, in initialize self.parse_command_line(argv) File "<decorator-gen-4>", line 2, in parse_command_line File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 488, in parse_command_line return self.initialize_subcommand(subc, subargv) File "<decorator-gen-3>", line 2, in initialize_subcommand File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 426, in initialize_subcommand self.subapp.initialize(argv) File "<decorator-gen-6>", line 2, in initialize File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\jupyter_core\application.py", line 239, in initialize self.parse_command_line(argv) File "<decorator-gen-4>", line 2, in parse_command_line File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 74, in catch_config_error return method(app, *args, **kwargs) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 500, in parse_command_line self.print_help('--help-all' in interpreted_argv) File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 360, in print_help self.print_options() File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 331, in print_options self.print_alias_help() File "c:\miniconda3\lib\site-packages\traitlets\config\application.py", line 297, in print_alias_help trait = cls.class_traits(config=True)[traitname] KeyError: 'destination'
8,675
jupyterlab/jupyterlab
jupyterlab__jupyterlab-9760
5340e7161b4c5b67cd3e8184a018e142af86b22c
diff --git a/jupyterlab/federated_labextensions.py b/jupyterlab/federated_labextensions.py --- a/jupyterlab/federated_labextensions.py +++ b/jupyterlab/federated_labextensions.py @@ -22,6 +22,7 @@ from jupyter_core.utils import ensure_dir_exists from ipython_genutils.py3compat import cast_unicode_py2 from jupyterlab_server.config import get_federated_extensions +from jupyter_server.extension.serverextension import ArgumentConflict from .commands import _test_overlap
`ArgumentConflict` is not defined <!-- Welcome! Before creating a new issue: * Search for relevant issues * Follow the issue reporting guidelines: https://jupyterlab.readthedocs.io/en/latest/getting_started/issue.html --> ## Description When I add ```python c.DevelopLabExtensionApp.labextensions_dir=<some_path> ``` to a custom configuration I get the error: ```traceback Traceback (most recent call last): File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/debuglog.py", line 47, in debug_logging yield File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/labextensions.py", line 127, in start ans = self.run_task() File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/labextensions.py", line 199, in run_task develop_labextension_py(arg, user=self.user, sys_prefix=self.sys_prefix, labextensions_dir=self.labextensions_dir, logger=self.log, overwrite=self.overwrite, File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/federated_labextensions.py", line 157, in develop_labextension_py full_dest = develop_labextension( File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/federated_labextensions.py", line 83, in develop_labextension labext = _get_labextension_dir(user=user, sys_prefix=sys_prefix, labextensions_dir=labextensions_dir) File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/federated_labextensions.py", line 332, in _get_labextension_dir raise ArgumentConflict( ``` It looks like this `ArgumentConflict` error isn't defined anywhere in jupyterlab. I can submit a PR to fix this later today by adding an `ArgumentConflict` class that subclasses from `traitlets.TraitError`. I'm open to other recomendations as well though. ## Reproduce <!--Describe step-by-step instructions to reproduce the behavior--> add ```python c.DevelopLabExtensionApp.labextensions_dir=<some_path> ``` to a `jupyter_config.py` from a jupyter lab extension repo and run: ```bash jupyter labextension develop . --config jupyter_config.py ``` <!--Describe how you diagnosed the issue. See the guidelines at https://jupyterlab.readthedocs.io/en/latest/getting_started/issue.html --> ## Expected behavior `ArgumentConflict` is properly raised ## Context - Operating System and version: Ubuntu 18.04.5 - Browser and version: N/A - JupyterLab version: 3.0.6 <details><summary>Command Line Output</summary> <pre> Installing /home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/jupyterlab_git/labextension -> @jupyterlab/git An error occured. NameError: name 'ArgumentConflict' is not defined </pre> </details> <details><summary>Browser Output</summary> <pre> N/A </pre> </details>
Yep, I think you're right that the def of `ArgumentConflict` is missing. Previously, it looks like the def was in [`notebook.extensions`](https://github.com/jupyter/notebook/blob/7f7ea8e85c9c90b264317a7c2f4995ab99fd8f60/notebook/extensions.py#L15), but now that we've switched over to [`jupyter_server`](https://github.com/jupyter-server/jupyter_server/blob/b2e089506baf0723fe63112cb9df7ef8b493d093/jupyter_server/extension/serverextension.py#L72) we'll have to add: ```python from jupyter_server.extension.serverextension import ArgumentConflict ``` @andrewfulton9 If you want the honors, could you please submit a PR that adds the above import right after the following lines: https://github.com/jupyterlab/jupyterlab/blob/5340e7161b4c5b67cd3e8184a018e142af86b22c/jupyterlab/federated_labextensions.py#L19-L24 Thanks for spotting this!
2021-02-08T21:46:18Z
[]
[]
Traceback (most recent call last): File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/debuglog.py", line 47, in debug_logging yield File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/labextensions.py", line 127, in start ans = self.run_task() File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/labextensions.py", line 199, in run_task develop_labextension_py(arg, user=self.user, sys_prefix=self.sys_prefix, labextensions_dir=self.labextensions_dir, logger=self.log, overwrite=self.overwrite, File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/federated_labextensions.py", line 157, in develop_labextension_py full_dest = develop_labextension( File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/federated_labextensions.py", line 83, in develop_labextension labext = _get_labextension_dir(user=user, sys_prefix=sys_prefix, labextensions_dir=labextensions_dir) File "/home/andrew/Dropbox/quansight/jupyter/jupyterlab-git/_build/pip_packages/lib/python3.8/site-packages/jupyterlab/federated_labextensions.py", line 332, in _get_labextension_dir raise ArgumentConflict( ``` It looks like this `ArgumentConflict` error isn't defined anywhere in jupyterlab.
8,686
kubeflow/pipelines
kubeflow__pipelines-1154
05609ce11eebd0098763742b3e44bce1ad9a168e
diff --git a/samples/resnet-cmle/resnet-train-pipeline.py b/samples/resnet-cmle/resnet-train-pipeline.py --- a/samples/resnet-cmle/resnet-train-pipeline.py +++ b/samples/resnet-cmle/resnet-train-pipeline.py @@ -124,7 +124,7 @@ def resnet_train( eval_batch_size, steps_per_eval, train_steps, num_train_images, num_eval_images, num_label_classes, tf_version).apply(gcp.use_gcp_secret()) train.after(preprocess) - export_output = os.path.join(str(train.outputs['job-dir']), 'export') + export_output = os.path.join(str(train.outputs['job_dir']), 'export') deploy = resnet_deploy_op(export_output, model, version, project_id, region, tf_version).apply(gcp.use_gcp_secret())
Backend Docker build fails with python error in resnet-train-pipeline.py Ran on master branch (`086d4763d9f163acdeb423bc2bc49ab470442a92`) with `--no-cache` arg and got the following the error: ``` Step 20/31 : RUN find . -maxdepth 2 -name '*.py' -type f | while read pipeline; do dsl-compile --py "$pipeline" --output "$pipeline.tar.gz"; done ---> Running in 3205bef0c5cb Traceback (most recent call last): File "/usr/local/bin/dsl-compile", line 10, in <module> sys.exit(main()) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/main.py", line 103, in main compile_pyfile(args.py, args.function, args.output, not args.disable_type_check) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/main.py", line 92, in compile_pyfile _compile_pipeline_function(function_name, output_path, type_check) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/main.py", line 72, in _compile_pipeline_function kfp.compiler.Compiler().compile(pipeline_func, output_path, type_check) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/compiler.py", line 644, in compile workflow = self._compile(pipeline_func) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/compiler.py", line 596, in _compile pipeline_func(*args_list) File "./resnet-cmle/resnet-train-pipeline.py", line 127, in resnet_train export_output = os.path.join(str(train.outputs['job-dir']), 'export') KeyError: 'job-dir' The command '/bin/sh -c find . -maxdepth 2 -name '*.py' -type f | while read pipeline; do dsl-compile --py "$pipeline" --output "$pipeline.tar.gz"; done' returned a non-zero code: 1
Replacing 'job_dir' with 'job-dir' in the resnet sample. This is a bug. I'll send a PR to fix it.
2019-04-12T18:26:57Z
[]
[]
Traceback (most recent call last): File "/usr/local/bin/dsl-compile", line 10, in <module> sys.exit(main()) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/main.py", line 103, in main compile_pyfile(args.py, args.function, args.output, not args.disable_type_check) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/main.py", line 92, in compile_pyfile _compile_pipeline_function(function_name, output_path, type_check) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/main.py", line 72, in _compile_pipeline_function kfp.compiler.Compiler().compile(pipeline_func, output_path, type_check) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/compiler.py", line 644, in compile workflow = self._compile(pipeline_func) File "/usr/local/lib/python3.5/site-packages/kfp/compiler/compiler.py", line 596, in _compile pipeline_func(*args_list) File "./resnet-cmle/resnet-train-pipeline.py", line 127, in resnet_train export_output = os.path.join(str(train.outputs['job-dir']), 'export') KeyError: 'job-dir'
8,689
kubeflow/pipelines
kubeflow__pipelines-1666
08ff76f5f1166092242ff4f3266950c03f5cf83e
diff --git a/sdk/python/setup.py b/sdk/python/setup.py --- a/sdk/python/setup.py +++ b/sdk/python/setup.py @@ -45,6 +45,7 @@ install_requires=REQUIRES, packages=[ 'kfp', + 'kfp.cli', 'kfp.compiler', 'kfp.components', 'kfp.components.structures',
`pip install kfp` does not install CLI **What happened:** ``` $ virtualenv .venv ... $ pip install kfp==0.1.23 ... $ kfp Traceback (most recent call last): File "/private/tmp/.venv/bin/kfp", line 6, in <module> from kfp.__main__ import main File "/private/tmp/.venv/lib/python3.7/site-packages/kfp/__main__.py", line 15, in <module> from .cli.cli import main ModuleNotFoundError: No module named 'kfp.cli' ``` **What did you expect to happen:** To run the CLI. **Anything else you would like to add:** I could be confused about what is expected to be available after installing the kfp package from pip - setup.py mentions an entrypoint named kfp in https://github.com/kubeflow/pipelines/blob/812ca7f8836c47039c3b1f3daf23e68fbcee1a92/sdk/python/setup.py#L74 but main.py imports a `kfp.cli` package https://github.com/kubeflow/pipelines/blob/812ca7f8836c47039c3b1f3daf23e68fbcee1a92/sdk/python/kfp/__main__.py#L15 which is not included in the distribution https://github.com/kubeflow/pipelines/blob/812ca7f8836c47039c3b1f3daf23e68fbcee1a92/sdk/python/setup.py#L46-L54
2019-07-24T19:42:10Z
[]
[]
Traceback (most recent call last): File "/private/tmp/.venv/bin/kfp", line 6, in <module> from kfp.__main__ import main File "/private/tmp/.venv/lib/python3.7/site-packages/kfp/__main__.py", line 15, in <module> from .cli.cli import main ModuleNotFoundError: No module named 'kfp.cli'
8,695
mesonbuild/meson
mesonbuild__meson-10050
530338782cce2f3380011c5f3e34050edf4e9243
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -43,6 +43,9 @@ KeyedOptionDictType = T.Union[T.Dict['OptionKey', 'UserOption[T.Any]'], OptionOverrideProxy] CompilerCheckCacheKey = T.Tuple[T.Tuple[str, ...], str, FileOrString, T.Tuple[str, ...], str] + # typeshed + StrOrBytesPath = T.Union[str, bytes, os.PathLike[str], os.PathLike[bytes]] + # Check major_versions_differ() if changing versioning scheme. # # Pip requires that RCs are named like this: '0.1.0.rc1' @@ -895,6 +898,9 @@ def __init__(self) -> None: # storing subproject options like "subproject:option=value" super().__init__(delimiters=['='], interpolation=None) + def read(self, filenames: T.Union['StrOrBytesPath', T.Iterable['StrOrBytesPath']], encoding: str ='utf-8') -> T.List[str]: + return super().read(filenames, encoding) + def optionxform(self, option: str) -> str: # Don't call str.lower() on keys return option diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -220,6 +220,11 @@ def run(original_args, mainfile): print('Please update your environment') return 1 + if sys.version_info >= (3, 10) and os.environ.get('MESON_RUNNING_IN_PROJECT_TESTS'): + # workaround for https://bugs.python.org/issue34624 + import warnings + warnings.filterwarnings('error', category=EncodingWarning, module='mesonbuild') + # Meson gets confused if stdout can't output Unicode, if the # locale isn't Unicode, just force stdout to accept it. This tries # to emulate enough of PEP 540 to work elsewhere. diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -121,7 +121,7 @@ def __init__(self, fname: str, subproject: str = ''): def parse_wrap(self) -> None: try: config = configparser.ConfigParser(interpolation=None) - config.read(self.filename) + config.read(self.filename, encoding='utf-8') except configparser.Error as e: raise WrapException(f'Failed to parse {self.basename}: {e!s}') self.parse_wrap_section(config) diff --git a/run_custom_lint.py b/run_custom_lint.py deleted file mode 100755 --- a/run_custom_lint.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python3 - -from pathlib import Path -import typing as T - -root = Path(__file__).absolute().parent -mesonbuild = root / 'mesonbuild' - -whitelist = ['mesonbuild/', 'run_', 'ci/', 'tools/', 'docs/'] - -def check_missing_encoding(lines: T.List[str], path: str) -> int: - errors = 0 - functions = ['read_text', 'write_text', 'open'] - for num, line in enumerate(lines): - for func in functions: - l = line - - # Skip ignored lines - if '[ignore encoding]' in l: - continue - - # Do we have a match? - loc = l.find(func + '(') - if loc < 0: - continue - if loc > 0 and ord(l[loc-1].lower()) in [*range(ord('a'), ord('z')), *range(ord('0'), ord('9')), '_']: - continue - loc += len(func) + 1 - # Some preprocessign to make parsing easier - l = l[loc:] - l = l.replace(' ', '') - l = l.replace('\t', '') - l = l.replace('\n', '') - l = l.replace('\'', '"') - - # Parameter begin - args = '' - b_open = 1 - while l: - c = l[0] - l = l[1:] - if c == ')': - b_open -= 1 - if b_open == 0: - break - elif b_open == 1: - args += c - if c == '(': - b_open += 1 - - binary_modes = ['rb', 'br', 'r+b', 'wb', 'bw', 'ab', 'ba'] - is_binary = any([f'"{x}"' in args for x in binary_modes]) - if 'encoding=' not in args and not (func == 'open' and is_binary): - location = f'\x1b[33;1m[\x1b[0;1m{path}:{num+1}\x1b[33m]\x1b[0m' - #print(f'{location:<64}: \x1b[31;1mERROR:\x1b[0m Missing `encoding=` parameter in "{line.strip()}"') - print(f'{location:<72}: \x1b[31;1mERROR:\x1b[0m Missing `encoding=` parameter in `{func}` call') - errors += 1 - return errors - -def main() -> int: - print('Scanning mesonbuild...') - errors = 0 - for i in sorted(root.glob('**/*.py')): - raw = i.read_text(encoding='utf-8') - lines = raw.splitlines() - filename = i.relative_to(root).as_posix() - - if not any([filename.startswith(x) for x in whitelist]): - continue - - errors += check_missing_encoding(lines, filename) - print(f'Found {errors} errors while scanning mesonbuild') - return 0 if errors == 0 else 1 - -if __name__ == '__main__': - raise SystemExit(main()) diff --git a/run_mypy.py b/run_mypy.py --- a/run_mypy.py +++ b/run_mypy.py @@ -56,7 +56,6 @@ 'mesonbuild/optinterpreter.py', 'mesonbuild/programs.py', - 'run_custom_lint.py', 'run_mypy.py', 'run_project_tests.py', 'run_single_test.py',
Change encoding to utf-8 for reading .ini files **Describe the bug** The code reading .ini files assumes the content to be ASCII, and fails if the files include utf-8 characters. ```console > meson setup --backend ninja --buildtype debug -D platform-name=native --native-file xpacks/micro-os-plus-build-helper/meson/toolchains/gcc.ini --native-file tests/platform-native/meson/native.ini build/native-meson-gcc11-debug tests Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/mesonbuild/mesonmain.py", line 228, in run return options.run_func(options) File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 281, in run app.generate() File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 177, in generate env = environment.Environment(self.source_dir, self.build_dir, self.options) File "/usr/local/lib/python3.6/dist-packages/mesonbuild/environment.py", line 522, in __init__ config = coredata.parse_machine_files(self.coredata.config_files) File "/usr/local/lib/python3.6/dist-packages/mesonbuild/coredata.py", line 934, in parse_machine_files parser = MachineFileParser(filenames) File "/usr/local/lib/python3.6/dist-packages/mesonbuild/coredata.py", line 880, in __init__ self.parser.read(filenames) File "/usr/lib/python3.6/configparser.py", line 697, in read self._read(fp, filename) File "/usr/lib/python3.6/configparser.py", line 1015, in _read for lineno, line in enumerate(fp, start=1): File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 29: ordinal not in range(128) ``` The culprit is a `µ` character used in the header comment present in the .ini files, like: ```ini # # This file is part of the µOS++ distribution. <--- utf-8 characters! # (https://github.com/micro-os-plus) # Copyright (c) 2022 Liviu Ionescu # # Permission to use, copy, modify, and/or distribute this software # for any purpose is hereby granted, under the terms of the MIT license. # # If a copy of the license was not distributed with this file, it can # be obtained from https://opensource.org/licenses/MIT/. # # ----------------------------------------------------------------------------- # https://mesonbuild.com/Machine-files.html [built-in options] warning_level = '0' werror = false layout = 'flat' # 'mirror' # ----------------------------------------------------------------------------- ``` **To Reproduce** Use a comment line with the **µ** character in the .ini files. **Expected behavior** The .ini files be parsed with utf-8 encodding, not ascii. **system parameters** * the build happens inside an Ubuntu 18.04 docker container, with minimal content * Python 3.6.9 * 0.59.4 I tried to inject the encoding via the environment `PYTHONIOENCODING=utf-8`, but did not help. Unfortunately my knowledge of Python is not good enough to find a solution and suggest a pull request. As a temporary workaround I removed the utf-8 characters from the .ini files, and the builds passed.
And a related issue from the same family: ``` Traceback (most recent call last): File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/mesonbuild/mesonmain.py", line 228, in run File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/mesonbuild/mtest.py", line 1998, in run File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/mesonbuild/mtest.py", line 1678, in doit File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/mesonbuild/mtest.py", line 1817, in run_tests File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/mesonbuild/mtest.py", line 1920, in _run_tests File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/mesonbuild/mtest.py", line 683, in finish File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/mesonbuild/mtest.py", line 588, in report_progress File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/mesonbuild/mtest.py", line 558, in emit_progress File "/Host/home/ilg/Work/meson-build-0.59.4-1/linux-arm/install/meson-build/lib/python3.9/mesonbuild/mtest.py", line 522, in print_progress UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f311' in position 8: ordinal not in range(128) ``` This time the issue is caused by the test output which is displayed as: ``` diag::trace test started Check trace::initialize \u2713 initial count \u2713 initial content x \u2713 count initialised \u2713 initial content cleared Check trace::putchar \u2713 count increased by 1 \u2713 buffer has c ``` The output should be: ``` diag::trace test started Check trace::initialize ✓ initial count ✓ initial content x ✓ count initialised ✓ initial content cleared Check trace::putchar ✓ count increased by 1 ✓ buffer has c ``` > The code reading .ini files assumes the content to be ASCII Not really true. The code reading .ini files doesn't assume the content at all, that is the entire problem. Rather what happens here is that it uses the default locale, which in your case is apparently not UTF-8. Also, you are using Python 3.6 (which Meson no longer supports in git master). > I tried to inject the encoding via the environment `PYTHONIOENCODING=utf-8`, but did not help. Regrettably, PYTHONIOENCODING (a highly python-specific variable) only affects standard input, standard output, and standard error. It doesn't affect any other kinds of data, such as files. The good news is that setting LC_CTYPE (a universal variable from the LC_ALL family of subset variables, that affects all programs) changes the locale for everything, including both stdin/stdout/stderr as well as reading/writing files or processing the data included in them. The other good news is https://www.python.org/dev/peps/pep-0538/ which specifies for Python 3.7 and onward that if your LC_CTYPE is not UTF-8 enabled, Python will generally insist on upgrading it, so this problem therefore goes away. I am not sure what to do about this issue. Meson dropped support for Python 3.6, so all supported versions of Python work fine. On the other hand, the most recent stable release of Meson still supports Python 3.6. On the other other hand, Python 3.6 is no longer supported by the Python Software Foundation (this is why we dropped support in Meson git master). And it's not really clear what to do to solve this problem anyway. The simplest solution is to simply guarantee that the locale is set. I'm not sure how to do a thorough vetting of Meson code and ensure that any function which opens a file or even passes a file to the stdlib to open it handles encodings, especially when this is only for maintenance releases and not git master. > ... Python 3.6 Not directly related. The issue is present with Python 3.9 too, just that the test that I showed you was on an older system. > And it's not really clear what to do to solve this problem anyway. The simplest solution is to simply guarantee that the locale is set. How do you guarantee this? If the environment variables are not present, can't you adjust the environment at run time to add them? Or set some Python process wide defaults to UTF-8? Breaking with a stack trace because an environment variable is not set is hardly an acceptable behaviour. > I'm not sure how to do a thorough vetting of Meson code and ensure that any function which opens a file or even passes a file to the stdlib to open it handles encodings, especially when this is only for maintenance releases and not git master. Unfortunately I don't have an answer to this. All I know is that I tried to run my tests on a minimalistic Ubuntu 20 container, and meson crashed. I identified the culprit, I removed the wide characters from the .ini files, then meson did not properly display the test output. At the same time, exactly the same tests, in the same environment, but built and run with CMake, were fine. Such a run is still available on GitHub, with the meson tests at the end: - <https://github.com/micro-os-plus/diag-trace-xpack/runs/5167376929> My projects have dual-build configurations, and I test them both with CMake and meson, so it is quite easy to compare the two. The CMake syntax may be unusual, but in the end it does the job fairly well. The meson syntax may seem easier to read, but the countless restrictions make things way more difficult, and it is not guaranteed that will result in a functional build. For my tests I spent some time to experiment with various docker images and I was finally able to find one with an environment that no longer breaks meson, but this is not how a professional tool is expected to behave. If you have no solution to this, feel free to close the issue at any time. There are a bunch of other places where we explicitly set the encoding to utf-8. The change would be to change `self.parser.read(filenames)` to `self.parser.read(filenames, encoding='utf'8')`. The only question is would this break something? Since the current implementation fails on anything non-ascii, probably not. Again, this works fine on python 3.10 on my machine. Because it's a locale issue and ever since python 3.7, python itself will force your locale from ASCII to utf-8. This is supposed to be an opportunity to celebrate and remove old hacks. I don't understand the report of it not working, this should be impossible. > ever since python 3.7, python itself will force your locale from ASCII to utf-8 I cannot confirm this, I first encountered this bug with the python 3.9 that I embedded in my distribution, but, in order to give you a reproducible case, and avoid giving you a reason to shift the blame to my distribution, I retested with the system python. Python may have its share of issues, but by defensive programming style guides, this is a bug in your application, it is not normal to crash with a stack trace. If you don't consider fixing it, at least catch the exception and display a civilised message informing the user how to properly set the locales to make it work.
2022-03-02T00:09:53Z
[]
[]
Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/mesonbuild/mesonmain.py", line 228, in run return options.run_func(options) File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 281, in run app.generate() File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 177, in generate env = environment.Environment(self.source_dir, self.build_dir, self.options) File "/usr/local/lib/python3.6/dist-packages/mesonbuild/environment.py", line 522, in __init__ config = coredata.parse_machine_files(self.coredata.config_files) File "/usr/local/lib/python3.6/dist-packages/mesonbuild/coredata.py", line 934, in parse_machine_files parser = MachineFileParser(filenames) File "/usr/local/lib/python3.6/dist-packages/mesonbuild/coredata.py", line 880, in __init__ self.parser.read(filenames) File "/usr/lib/python3.6/configparser.py", line 697, in read self._read(fp, filename) File "/usr/lib/python3.6/configparser.py", line 1015, in _read for lineno, line in enumerate(fp, start=1): File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 29: ordinal not in range(128)
8,707
mesonbuild/meson
mesonbuild__meson-10092
7cc4ca2cbb38360743f1d56a5a709bbd51b53ad6
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -1984,7 +1984,10 @@ def make_test(self, node: mparser.BaseNode, location=node) name = name.replace(':', '_') exe = args[1] - if isinstance(exe, mesonlib.File): + if isinstance(exe, ExternalProgram): + if not exe.found(): + raise InvalidArguments('Tried to use not-found external program as test exe') + elif isinstance(exe, mesonlib.File): exe = self.find_program_impl([exe]) env = self.unpack_env_kwarg(kwargs)
deja-dup 43.2 tests under xbps-src fail to run with a TypeError in meson **Describe the bug** Trying to run deja-dup 43.2 tests under xbps-src (Void Linux build system) results in an error: ``` [0/1] Running all tests. Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 149, in run return options.run_func(options) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 2017, in run return th.doit() File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1685, in doit runners.extend(self.get_test_runner(test) for test in tests) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1685, in <genexpr> runners.extend(self.get_test_runner(test) for test in tests) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1586, in get_test_runner return SingleTestRunner(test, env, name, options) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1308, in __init__ self.cmd = self._get_cmd() File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1374, in _get_cmd test_cmd = self._get_test_cmd() File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1352, in _get_test_cmd if self.options.no_rebuild and not os.path.isfile(testentry): File "/usr/lib/python3.10/genericpath.py", line 30, in isfile st = os.stat(path) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType ERROR: Unhandled python exception This is a Meson bug and should be reported! FAILED: meson-test /usr/bin/meson test --no-rebuild --print-errorlogs ninja: build stopped: subcommand failed. ``` **To Reproduce** This seems to only happen under xbps-src that runs builds in a limited chroot which might be why I can't reproduce this on my own computer. **Expected behavior** Tests should run and meson shouldn't exit with a TypeError. **system parameters** * native build * Void Linux * Python 3.10 * meson 0.61.99 (789f440f7c2bfda2e17f05ecdcb1a19245f892df), meson 0.61.2 and meson 0.60.3 * ninja 1.10.2
It seems odd that `_get_test_cmd` claims the test command is a NoneType. The specific code that's being hit here was added in c85f7a39a80ccbadb9ffb76102da30c05e3db66f but before that we checked `if self.test.fname[0].endswith('.jar')` and now we first check if `os.path.isfile(self.test.fname[0])`. We always assumed that a test has to have a test command, and I don't get how that would ever not be the case. I wonder what `meson-private/meson_test_setup.dat` contains in it... Okay, confirmed issue: ```python >>> ret = pickle.load(open('meson-private/meson_test_setup.dat', 'rb')) >>> for i in ret: ... print(f'{i.name=}, {i.fname=}') ... i.name='validate-gschema', i.fname=['/usr/bin/glib-compile-schemas'] i.name='validate-monitor-desktop', i.fname=[None] i.name='validate-desktop', i.fname=[None] i.name='validate-appstream', i.fname=[None] i.name='help-linguas', i.fname=['/builddir/deja-dup-43.2/help/./validate-linguas'] i.name='script-bad-hostname', i.fname=[None] i.name='script-bad-volume', i.fname=[None] i.name='script-cancel-noop', i.fname=[None] i.name='script-cancel', i.fname=[None] i.name='script-clean-cache-if-full', i.fname=[None] i.name='script-clean-cache', i.fname=[None] i.name='script-clean-incomplete', i.fname=[None] i.name='script-clean-tempdir', i.fname=[None] i.name='script-custom-tool-setup-bad', i.fname=[None] i.name='script-custom-tool-setup-fails', i.fname=[None] i.name='script-custom-tool-setup-teardown', i.fname=[None] i.name='script-custom-tool-wrapper', i.fname=[None] i.name='script-custom-tool-wrapper-bad', i.fname=[None] i.name='script-delete-just-right', i.fname=[None] i.name='script-delete-never', i.fname=[None] i.name='script-delete-too-few', i.fname=[None] i.name='script-delete-too-old', i.fname=[None] i.name='script-disk-full2', i.fname=[None] i.name='script-disk-full', i.fname=[None] i.name='script-disk-small', i.fname=[None] i.name='script-encrypt-ask', i.fname=[None] i.name='script-encrypt-detect', i.fname=[None] i.name='script-excludes', i.fname=[None] i.name='script-instance-error', i.fname=[None] i.name='script-mkdir', i.fname=[None] i.name='script-nag', i.fname=[None] i.name='script-no-space', i.fname=[None] i.name='script-old-version', i.fname=[None] i.name='script-permission', i.fname=[None] i.name='script-read-error', i.fname=[None] i.name='script-restore-full', i.fname=[None] i.name='script-restore-specific', i.fname=[None] i.name='script-special-chars', i.fname=[None] i.name='script-stop', i.fname=[None] i.name='script-symlink-direct', i.fname=[None] i.name='script-symlink-exclude2', i.fname=[None] i.name='script-symlink-exclude', i.fname=[None] i.name='script-symlink-follow2', i.fname=[None] i.name='script-symlink-follow', i.fname=[None] i.name='script-symlink-loop', i.fname=[None] i.name='script-symlink-recursive', i.fname=[None] i.name='script-symlink-subdir', i.fname=[None] i.name='script-symlink-trickshot', i.fname=[None] i.name='script-threshold-full', i.fname=[None] i.name='script-threshold-inc', i.fname=[None] i.name='script-verify', i.fname=[None] i.name='script-write-error', i.fname=[None] i.name='libdeja', i.fname=[None] i.name='scheduler', i.fname=['/builddir/deja-dup-43.2/build/monitor/tests/scheduler-test'] i.name='po-linguas', i.fname=['/builddir/deja-dup-43.2/po/./validate-linguas'] i.name='potfiles', i.fname=['/builddir/deja-dup-43.2/po/./validate-potfiles'] ``` Looking up the tests in question, they are all cases where tests have been defined using a `find_program(..., required: false)` which was not found. As expected, it fails with Meson 0.59 too, like this: ```python if self.test.fname[0].endswith('.jar'): AttributeError: 'NoneType' object has no attribute 'endswith' ``` I think we should not allow adding a test setup with a not-found program... probably we should not allow that anywhere else at all. In fact for say custom_target we already fail with `ERROR: Tried to use not-found external program in "command"`.
2022-03-08T22:45:53Z
[]
[]
Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 149, in run return options.run_func(options) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 2017, in run return th.doit() File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1685, in doit runners.extend(self.get_test_runner(test) for test in tests) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1685, in <genexpr> runners.extend(self.get_test_runner(test) for test in tests) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1586, in get_test_runner return SingleTestRunner(test, env, name, options) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1308, in __init__ self.cmd = self._get_cmd() File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1374, in _get_cmd test_cmd = self._get_test_cmd() File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1352, in _get_test_cmd if self.options.no_rebuild and not os.path.isfile(testentry): File "/usr/lib/python3.10/genericpath.py", line 30, in isfile st = os.stat(path) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
8,712
mesonbuild/meson
mesonbuild__meson-1010
e02aaad63286169aebf63109363fed648a185b05
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -22,6 +22,7 @@ import re import os, stat, glob, subprocess, shutil import sysconfig +from collections import OrderedDict from . mesonlib import MesonException from . import mlog from . import mesonlib @@ -806,11 +807,20 @@ def get_link_args(self): def found(self): return self.is_found -class Qt5Dependency(Dependency): - def __init__(self, environment, kwargs): - Dependency.__init__(self, 'qt5') - self.name = 'qt5' +class QtBaseDependency(Dependency): + def __init__(self, name, env, kwargs): + Dependency.__init__(self, name) + self.name = name + self.qtname = name.capitalize() + self.qtver = name[-1] self.root = '/usr' + self.bindir = None + self.silent = kwargs.get('silent', False) + # We store the value of required here instead of passing it on to + # PkgConfigDependency etc because we want to try the qmake-based + # fallback as well. + self.required = kwargs.pop('required', True) + kwargs['required'] = False mods = kwargs.get('modules', []) self.cargs = [] self.largs = [] @@ -818,69 +828,130 @@ def __init__(self, environment, kwargs): if isinstance(mods, str): mods = [mods] if len(mods) == 0: - raise DependencyException('No Qt5 modules specified.') - type_text = 'native' - if environment.is_cross_build() and kwargs.get('native', False): - type_text = 'cross' - self.pkgconfig_detect(mods, environment, kwargs) - elif not environment.is_cross_build() and shutil.which('pkg-config') is not None: - self.pkgconfig_detect(mods, environment, kwargs) - elif shutil.which('qmake') is not None: - self.qmake_detect(mods, kwargs) - else: - self.version = 'none' + raise DependencyException('No ' + self.qtname + ' modules specified.') + type_text = 'cross' if env.is_cross_build() else 'native' + found_msg = '{} {} `{{}}` dependency found:'.format(self.qtname, type_text) + from_text = 'pkg-config' + # Prefer pkg-config, then fallback to `qmake -query` + self._pkgconfig_detect(mods, env, kwargs) if not self.is_found: - mlog.log('Qt5 %s dependency found: ' % type_text, mlog.red('NO')) + from_text = self._qmake_detect(mods, env, kwargs) + if not self.is_found: + from_text = '(checked pkg-config, qmake-{}, and qmake)' \ + ''.format(self.name) + self.version = 'none' + if self.required: + err_msg = '{} {} dependency not found {}' \ + ''.format(self.qtname, type_text, from_text) + raise DependencyException(err_msg) + if not self.silent: + mlog.log(found_msg.format(from_text), mlog.red('NO')) + return + if not self.silent: + mlog.log(found_msg.format(from_text), mlog.green('YES')) + + def compilers_detect(self): + "Detect Qt (4 or 5) moc, uic, rcc in the specified bindir or in PATH" + if self.bindir: + moc = ExternalProgram(os.path.join(self.bindir, 'moc'), silent=True) + uic = ExternalProgram(os.path.join(self.bindir, 'uic'), silent=True) + rcc = ExternalProgram(os.path.join(self.bindir, 'rcc'), silent=True) else: - mlog.log('Qt5 %s dependency found: ' % type_text, mlog.green('YES')) - - def pkgconfig_detect(self, mods, environment, kwargs): - modules = [] + # We don't accept unsuffixed 'moc', 'uic', and 'rcc' because they + # are sometimes older, or newer versions. + moc = ExternalProgram('moc-' + self.name, silent=True) + uic = ExternalProgram('uic-' + self.name, silent=True) + rcc = ExternalProgram('rcc-' + self.name, silent=True) + return moc, uic, rcc + + def _pkgconfig_detect(self, mods, env, kwargs): + if self.qtver == "4": + qtpkgname = 'Qt' + else: + qtpkgname = self.qtname + modules = OrderedDict() for module in mods: - modules.append(PkgConfigDependency('Qt5' + module, environment, kwargs)) - for m in modules: + modules[module] = PkgConfigDependency(qtpkgname + module, env, kwargs) + self.is_found = True + for m in modules.values(): + if not m.found(): + self.is_found = False self.cargs += m.get_compile_args() self.largs += m.get_link_args() - self.is_found = True - self.version = modules[0].modversion - - def qmake_detect(self, mods, kwargs): - pc = subprocess.Popen(['qmake', '-v'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - (stdo, _) = pc.communicate() - if pc.returncode != 0: - return - stdo = stdo.decode() - if not 'version 5' in stdo: - mlog.log('QMake is not for Qt5.') + self.version = m.modversion + # Try to detect moc, uic, rcc + if 'Core' in modules: + core = modules['Core'] + else: + corekwargs = {'required': 'false', 'silent': 'true'} + core = PkgConfigDependency(qtpkgname + 'Core', env, corekwargs) + # Used by self.compilers_detect() + self.bindir = core.get_pkgconfig_variable('host_bins') + if not self.bindir: + # If exec_prefix is not defined, the pkg-config file is broken + prefix = core.get_pkgconfig_variable('exec_prefix') + if prefix: + self.bindir = os.path.join(prefix, 'bin') + + def _find_qmake(self, qmake, env): + # Even when cross-compiling, if we don't get a cross-info qmake, we + # fallback to using the qmake in PATH because that's what we used to do + if env.is_cross_build(): + qmake = env.cross_info.config['binaries'].get('qmake', qmake) + return ExternalProgram(qmake, silent=True) + + def _qmake_detect(self, mods, env, kwargs): + for qmake in ('qmake-' + self.name, 'qmake'): + self.qmake = self._find_qmake(qmake, env) + if not self.qmake.found(): + continue + # Check that the qmake is for qt5 + pc = subprocess.Popen(self.qmake.fullpath + ['-v'], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + universal_newlines=True) + stdo = pc.communicate()[0] + if pc.returncode != 0: + continue + if not 'Qt version ' + self.qtver in stdo: + mlog.log('QMake is not for ' + self.qtname) + continue + # Found qmake for Qt5! + break + else: + # Didn't find qmake :( return - self.version = re.search('5(\.\d+)+', stdo).group(0) - (stdo, _) = subprocess.Popen(['qmake', '-query'], stdout=subprocess.PIPE).communicate() + self.version = re.search(self.qtver + '(\.\d+)+', stdo).group(0) + # Query library path, header path, and binary path + stdo = subprocess.Popen(self.qmake.fullpath + ['-query'], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + universal_newlines=True).communicate()[0] qvars = {} - for line in stdo.decode().split('\n'): + for line in stdo.split('\n'): line = line.strip() if line == '': continue (k, v) = tuple(line.split(':', 1)) qvars[k] = v if mesonlib.is_osx(): - return self.framework_detect(qvars, mods, kwargs) + return self._framework_detect(qvars, mods, kwargs) incdir = qvars['QT_INSTALL_HEADERS'] self.cargs.append('-I' + incdir) libdir = qvars['QT_INSTALL_LIBS'] - bindir = qvars['QT_INSTALL_BINS'] + # Used by self.compilers_detect() + self.bindir = qvars['QT_INSTALL_BINS'] #self.largs.append('-L' + libdir) for module in mods: mincdir = os.path.join(incdir, 'Qt' + module) self.cargs.append('-I' + mincdir) - libfile = os.path.join(libdir, 'Qt5' + module + '.lib') + libfile = os.path.join(libdir, self.qtname + module + '.lib') if not os.path.isfile(libfile): # MinGW links directly to .dll, not to .lib. - libfile = os.path.join(bindir, 'Qt5' + module + '.dll') + libfile = os.path.join(self.bindir, self.qtname + module + '.dll') self.largs.append(libfile) self.is_found = True + return qmake - def framework_detect(self, qvars, modules, kwargs): + def _framework_detect(self, qvars, modules, kwargs): libdir = qvars['QT_INSTALL_LIBS'] for m in modules: fname = 'Qt' + m @@ -890,7 +961,8 @@ def framework_detect(self, qvars, modules, kwargs): self.is_found = True self.cargs += fwdep.get_compile_args() self.largs += fwdep.get_link_args() - + # Used by self.compilers_detect() + self.bindir = qvars['QT_INSTALL_BINS'] def get_version(self): return self.version @@ -917,43 +989,13 @@ def get_exe_args(self): # Fix this to be more portable, especially to MSVC. return ['-fPIC'] -class Qt4Dependency(Dependency): - def __init__(self, environment, kwargs): - Dependency.__init__(self, 'qt4') - self.name = 'qt4' - self.root = '/usr' - self.modules = [] - mods = kwargs.get('modules', []) - if isinstance(mods, str): - mods = [mods] - for module in mods: - self.modules.append(PkgConfigDependency('Qt' + module, environment, kwargs)) - if len(self.modules) == 0: - raise DependencyException('No Qt4 modules specified.') +class Qt5Dependency(QtBaseDependency): + def __init__(self, env, kwargs): + QtBaseDependency.__init__(self, 'qt5', env, kwargs) - def get_version(self): - return self.modules[0].get_version() - - def get_compile_args(self): - args = [] - for m in self.modules: - args += m.get_compile_args() - return args - - def get_sources(self): - return [] - - def get_link_args(self): - args = [] - for module in self.modules: - args += module.get_link_args() - return args - - def found(self): - for i in self.modules: - if not i.found(): - return False - return True +class Qt4Dependency(QtBaseDependency): + def __init__(self, env, kwargs): + QtBaseDependency.__init__(self, 'qt4', env, kwargs) class GnuStepDependency(Dependency): def __init__(self, environment, kwargs): diff --git a/mesonbuild/modules/qt4.py b/mesonbuild/modules/qt4.py --- a/mesonbuild/modules/qt4.py +++ b/mesonbuild/modules/qt4.py @@ -12,26 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .. import dependencies, mlog import os, subprocess +from .. import mlog from .. import build from ..mesonlib import MesonException +from ..dependencies import Qt4Dependency import xml.etree.ElementTree as ET class Qt4Module(): - def __init__(self): - mlog.log('Detecting Qt tools.') - # The binaries have different names on different - # distros. Joy. - self.moc = dependencies.ExternalProgram('moc-qt4', silent=True) - if not self.moc.found(): - self.moc = dependencies.ExternalProgram('moc', silent=True) - self.uic = dependencies.ExternalProgram('uic-qt4', silent=True) - if not self.uic.found(): - self.uic = dependencies.ExternalProgram('uic', silent=True) - self.rcc = dependencies.ExternalProgram('rcc-qt4', silent=True) - if not self.rcc.found(): - self.rcc = dependencies.ExternalProgram('rcc', silent=True) + tools_detected = False + + def _detect_tools(self, env): + if self.tools_detected: + return + mlog.log('Detecting Qt4 tools') + # FIXME: We currently require Qt4 to exist while importing the module. + # We should make it gracefully degrade and not create any targets if + # the import is marked as 'optional' (not implemented yet) + kwargs = {'required': 'true', 'modules': 'Core', 'silent': 'true'} + qt4 = Qt4Dependency(env, kwargs) + # Get all tools and then make sure that they are the right version + self.moc, self.uic, self.rcc = qt4.compilers_detect() # Moc, uic and rcc write their version strings to stderr. # Moc and rcc return a non-zero result when doing so. # What kind of an idiot thought that was a good idea? @@ -80,6 +81,7 @@ def __init__(self): % (' '.join(self.rcc.fullpath), rcc_ver.split()[-1])) else: mlog.log(' rcc:', mlog.red('NO')) + self.tools_detected = True def parse_qrc(self, state, fname): abspath = os.path.join(state.environment.source_dir, state.subdir, fname) @@ -115,18 +117,29 @@ def preprocess(self, state, args, kwargs): if not isinstance(srctmp, list): srctmp = [srctmp] sources = args[1:] + srctmp + self._detect_tools(state.environment) + err_msg = "{0} sources specified and couldn't find {1}, " \ + "please check your qt4 installation" + if len(moc_headers) + len(moc_sources) > 0 and not self.moc.found(): + raise MesonException(err_msg.format('MOC', 'moc-qt4')) if len(rcc_files) > 0: - rcc_kwargs = {'output' : '@[email protected]', - 'arguments' : ['@INPUT@', '-o', '@OUTPUT@']} - rcc_gen = build.Generator([self.rcc], rcc_kwargs) - rcc_output = build.GeneratedList(rcc_gen) + if not self.rcc.found(): + raise MesonException(err_msg.format('RCC', 'rcc-qt4')) qrc_deps = [] for i in rcc_files: qrc_deps += self.parse_qrc(state, i) - rcc_output.extra_depends = qrc_deps - [rcc_output.add_file(os.path.join(state.subdir, a)) for a in rcc_files] - sources.append(rcc_output) + basename = os.path.split(rcc_files[0])[1] + name = 'qt4-' + basename.replace('.', '_') + rcc_kwargs = {'input' : rcc_files, + 'output' : name + '.cpp', + 'command' : [self.rcc, '-o', '@OUTPUT@', '@INPUT@'], + 'depend_files' : qrc_deps, + } + res_target = build.CustomTarget(name, state.subdir, rcc_kwargs) + sources.append(res_target) if len(ui_files) > 0: + if not self.uic.found(): + raise MesonException(err_msg.format('UIC', 'uic-qt4')) ui_kwargs = {'output' : 'ui_@[email protected]', 'arguments' : ['-o', '@OUTPUT@', '@INPUT@']} ui_gen = build.Generator([self.uic], ui_kwargs) diff --git a/mesonbuild/modules/qt5.py b/mesonbuild/modules/qt5.py --- a/mesonbuild/modules/qt5.py +++ b/mesonbuild/modules/qt5.py @@ -12,27 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .. import dependencies, mlog import os, subprocess +from .. import mlog from .. import build from ..mesonlib import MesonException +from ..dependencies import Qt5Dependency import xml.etree.ElementTree as ET class Qt5Module(): + tools_detected = False - def __init__(self): - mlog.log('Detecting Qt tools.') - # The binaries have different names on different - # distros. Joy. - self.moc = dependencies.ExternalProgram('moc-qt5', silent=True) - if not self.moc.found(): - self.moc = dependencies.ExternalProgram('moc', silent=True) - self.uic = dependencies.ExternalProgram('uic-qt5', silent=True) - if not self.uic.found(): - self.uic = dependencies.ExternalProgram('uic', silent=True) - self.rcc = dependencies.ExternalProgram('rcc-qt5', silent=True) - if not self.rcc.found(): - self.rcc = dependencies.ExternalProgram('rcc', silent=True) + def _detect_tools(self, env): + if self.tools_detected: + return + mlog.log('Detecting Qt5 tools') + # FIXME: We currently require Qt5 to exist while importing the module. + # We should make it gracefully degrade and not create any targets if + # the import is marked as 'optional' (not implemented yet) + kwargs = {'required': 'true', 'modules': 'Core', 'silent': 'true'} + qt5 = Qt5Dependency(env, kwargs) + # Get all tools and then make sure that they are the right version + self.moc, self.uic, self.rcc = qt5.compilers_detect() # Moc, uic and rcc write their version strings to stderr. # Moc and rcc return a non-zero result when doing so. # What kind of an idiot thought that was a good idea? @@ -87,6 +87,7 @@ def __init__(self): % (' '.join(self.rcc.fullpath), rcc_ver.split()[-1])) else: mlog.log(' rcc:', mlog.red('NO')) + self.tools_detected = True def parse_qrc(self, state, fname): abspath = os.path.join(state.environment.source_dir, state.subdir, fname) @@ -122,7 +123,14 @@ def preprocess(self, state, args, kwargs): if not isinstance(srctmp, list): srctmp = [srctmp] sources = args[1:] + srctmp + self._detect_tools(state.environment) + err_msg = "{0} sources specified and couldn't find {1}, " \ + "please check your qt5 installation" + if len(moc_headers) + len(moc_sources) > 0 and not self.moc.found(): + raise MesonException(err_msg.format('MOC', 'moc-qt5')) if len(rcc_files) > 0: + if not self.rcc.found(): + raise MesonException(err_msg.format('RCC', 'rcc-qt5')) qrc_deps = [] for i in rcc_files: qrc_deps += self.parse_qrc(state, i) @@ -132,11 +140,12 @@ def preprocess(self, state, args, kwargs): 'command' : [self.rcc, '-o', '@OUTPUT@', '@INPUT@'], 'depend_files' : qrc_deps, } - res_target = build.CustomTarget(basename.replace('.', '_'), - state.subdir, - rcc_kwargs) + name = 'qt5-' + basename.replace('.', '_') + res_target = build.CustomTarget(name, state.subdir, rcc_kwargs) sources.append(res_target) if len(ui_files) > 0: + if not self.uic.found(): + raise MesonException(err_msg.format('UIC', 'uic-qt5')) ui_kwargs = {'output' : 'ui_@[email protected]', 'arguments' : ['-o', '@OUTPUT@', '@INPUT@']} ui_gen = build.Generator([self.uic], ui_kwargs) diff --git a/run_unittests.py b/run_unittests.py --- a/run_unittests.py +++ b/run_unittests.py @@ -19,7 +19,7 @@ import tempfile import mesonbuild.environment from mesonbuild.environment import detect_ninja -from mesonbuild.dependencies import PkgConfigDependency +from mesonbuild.dependencies import PkgConfigDependency, Qt5Dependency def get_soname(fname): # HACK, fix to not use shell. @@ -59,6 +59,7 @@ def setUp(self): self.ninja_command = [detect_ninja(), '-C', self.builddir] self.common_test_dir = os.path.join(src_root, 'test cases/common') self.vala_test_dir = os.path.join(src_root, 'test cases/vala') + self.framework_test_dir = os.path.join(src_root, 'test cases/frameworks') self.output = b'' self.orig_env = os.environ.copy() @@ -67,22 +68,29 @@ def tearDown(self): os.environ = self.orig_env super().tearDown() + def _run(self, command): + self.output += subprocess.check_output(command, env=os.environ.copy()) + def init(self, srcdir): - self.output += subprocess.check_output(self.meson_command + [srcdir, self.builddir]) + self._run(self.meson_command + [srcdir, self.builddir]) def build(self): - self.output += subprocess.check_output(self.ninja_command) + self._run(self.ninja_command) def run_target(self, target): self.output += subprocess.check_output(self.ninja_command + [target]) def setconf(self, arg): - self.output += subprocess.check_output(self.mconf_command + [arg, self.builddir]) + self._run(self.mconf_command + [arg, self.builddir]) def get_compdb(self): with open(os.path.join(self.builddir, 'compile_commands.json')) as ifile: return json.load(ifile) + def get_meson_log(self): + with open(os.path.join(self.builddir, 'meson-logs', 'meson-log.txt')) as f: + return f.readlines() + def introspect(self, arg): out = subprocess.check_output(self.mintro_command + [arg, self.builddir]) return json.loads(out.decode('utf-8')) @@ -181,5 +189,19 @@ def test_run_target_files_path(self): self.init(testdir) self.run_target('check_exists') + def test_qt5dependency_qmake_detection(self): + # Can't be sure that `qmake` is Qt5, so just try qmake-qt5. + if not shutil.which('qmake-qt5'): + raise unittest.SkipTest('qt5 not found') + # Disable pkg-config codepath and force searching with qmake/qmake-qt5 + os.environ['PKG_CONFIG_LIBDIR'] = self.builddir + os.environ['PKG_CONFIG_PATH'] = self.builddir + testdir = os.path.join(self.framework_test_dir, '4 qt') + self.init(testdir) + # Confirm that the dependency was found with qmake + msg = 'Qt5 native `qmake-qt5` dependency found: YES\n' + mesonlog = self.get_meson_log() + self.assertTrue(msg in mesonlog) + if __name__ == '__main__': unittest.main()
qt5 module generates broken target if moc-qt5 is not installed When building `gst-plugins-base` while `moc-qt5` is not installed on the system I get: ``` Traceback (most recent call last): File "/home/jenkins/workspace/meson/mesonbuild/mesonmain.py", line 282, in run app.generate() File "/home/jenkins/workspace/meson/mesonbuild/mesonmain.py", line 169, in generate g.generate(intr) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 184, in generate self.generate_target(t, outfile) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 257, in generate_target self.generate_custom_generator_rules(target, outfile) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 1360, in generate_custom_generator_rules self.generate_genlist_for_target(genlist, target, outfile) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 1406, in generate_genlist_for_target elem.write(outfile) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 116, in write if quote_char == '"': File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 35, in ninja_quote return text.replace(' ', '$ ').replace(':', '$:') AttributeError: 'NoneType' object has no attribute 'replace' ``` basically because the target genrated [here](https://phabricator.freedesktop.org/diffusion/GSTBASE/browse/master/tests/examples/overlay/meson.build;c8c834e4a1361149b373694c502279a3a39dbb2a$21) is broken with `None` as first argument
2016-11-08T18:20:17Z
[]
[]
Traceback (most recent call last): File "/home/jenkins/workspace/meson/mesonbuild/mesonmain.py", line 282, in run app.generate() File "/home/jenkins/workspace/meson/mesonbuild/mesonmain.py", line 169, in generate g.generate(intr) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 184, in generate self.generate_target(t, outfile) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 257, in generate_target self.generate_custom_generator_rules(target, outfile) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 1360, in generate_custom_generator_rules self.generate_genlist_for_target(genlist, target, outfile) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 1406, in generate_genlist_for_target elem.write(outfile) File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 116, in write if quote_char == '"': File "/home/jenkins/workspace/meson/mesonbuild/backend/ninjabackend.py", line 35, in ninja_quote return text.replace(' ', '$ ').replace(':', '$:') AttributeError: 'NoneType' object has no attribute 'replace'
8,713
mesonbuild/meson
mesonbuild__meson-1013
841380acfe682023b0df9fa76debbe3030f31daa
diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py --- a/mesonbuild/modules/rpm.py +++ b/mesonbuild/modules/rpm.py @@ -94,7 +94,7 @@ def generate_spec_template(self, state, args, kwargs): for compiler in compiler_deps: fn.write('BuildRequires: %s\n' % compiler) for dep in state.environment.coredata.deps: - fn.write('BuildRequires: pkgconfig(%s)\n' % dep) + fn.write('BuildRequires: pkgconfig(%s)\n' % dep[0]) for lib in state.environment.coredata.ext_libs.values(): fn.write('BuildRequires: %s # FIXME\n' % lib.fullpath) mlog.log('Warning, replace', mlog.bold(lib.fullpath),
generating RPM spec file fails With this error: ``` Traceback (most recent call last): File "/tmp/meson/mesonbuild/mesonmain.py", line 279, in run app.generate() File "/tmp/meson/mesonbuild/mesonmain.py", line 167, in generate intr.run() File "/tmp/meson/mesonbuild/interpreter.py", line 1314, in run self.evaluate_codeblock(self.ast, start=1) File "/tmp/meson/mesonbuild/interpreter.py", line 1336, in evaluate_codeblock raise e File "/tmp/meson/mesonbuild/interpreter.py", line 1330, in evaluate_codeblock self.evaluate_statement(cur) File "/tmp/meson/mesonbuild/interpreter.py", line 1455, in evaluate_statement return self.method_call(cur) File "/tmp/meson/mesonbuild/interpreter.py", line 2608, in method_call return obj.method_call(method_name, self.flatten(args), kwargs) File "/tmp/meson/mesonbuild/interpreter.py", line 996, in method_call value = fn(state, args, kwargs) File "/tmp/meson/mesonbuild/modules/rpm.py", line 97, in generate_spec_template fn.write('BuildRequires: pkgconfig(%s)\n' % dep) TypeError: not all arguments converted during string formatting ```
2016-11-08T22:11:19Z
[]
[]
Traceback (most recent call last): File "/tmp/meson/mesonbuild/mesonmain.py", line 279, in run app.generate() File "/tmp/meson/mesonbuild/mesonmain.py", line 167, in generate intr.run() File "/tmp/meson/mesonbuild/interpreter.py", line 1314, in run self.evaluate_codeblock(self.ast, start=1) File "/tmp/meson/mesonbuild/interpreter.py", line 1336, in evaluate_codeblock raise e File "/tmp/meson/mesonbuild/interpreter.py", line 1330, in evaluate_codeblock self.evaluate_statement(cur) File "/tmp/meson/mesonbuild/interpreter.py", line 1455, in evaluate_statement return self.method_call(cur) File "/tmp/meson/mesonbuild/interpreter.py", line 2608, in method_call return obj.method_call(method_name, self.flatten(args), kwargs) File "/tmp/meson/mesonbuild/interpreter.py", line 996, in method_call value = fn(state, args, kwargs) File "/tmp/meson/mesonbuild/modules/rpm.py", line 97, in generate_spec_template fn.write('BuildRequires: pkgconfig(%s)\n' % dep) TypeError: not all arguments converted during string formatting
8,716
mesonbuild/meson
mesonbuild__meson-10214
b44042b5a9f7d73112fd174a3fa70095a5b8b0ac
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -822,7 +822,7 @@ def generate_pbx_file_reference(self, objects_dict): if isinstance(s, mesonlib.File): s = os.path.join(s.subdir, s.fname) elif isinstance(s, str): - s = os.path.joni(t.subdir, s) + s = os.path.join(t.subdir, s) else: continue custom_dict = PbxDict() @@ -942,7 +942,7 @@ def generate_pbx_group(self, objects_dict): if isinstance(s, mesonlib.File): s = os.path.join(s.subdir, s.fname) elif isinstance(s, str): - s = os.path.joni(t.subdir, s) + s = os.path.join(t.subdir, s) else: continue source_file_children.add_item(self.fileref_ids[(tname, s)], s) @@ -975,7 +975,7 @@ def write_group_target_entry(self, objects_dict, t): if isinstance(s, mesonlib.File): s = os.path.join(s.subdir, s.fname) elif isinstance(s, str): - s = os.path.joni(t.subdir, s) + s = os.path.join(t.subdir, s) else: continue target_children.add_item(self.fileref_ids[(tid, s)], s)
Python traceback when I run meson setup --backend xcode **Describe the bug** When I try to set up a build directory with the Xcode backend, I get the following traceback: ``` Traceback (most recent call last): File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/mesonmain.py", line 146, in run return options.run_func(options) File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/msetup.py", line 294, in run app.generate() File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/msetup.py", line 185, in generate self._generate(env) File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/msetup.py", line 247, in _generate intr.backend.generate() File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/backend/xcodebackend.py", line 302, in generate self.generate_pbx_file_reference(objects_dict) File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/backend/xcodebackend.py", line 825, in generate_pbx_file_reference s = os.path.joni(t.subdir, s) AttributeError: module 'posixpath' has no attribute 'joni' ``` This is clearly caused by a misspelling of the word `join`. **To Reproduce** 1. Create the following empty files: - `main.c` - `ui.gresources.xml` 2. Create a `meson.build` file with the following content: ```meson project('xcode-test', 'c') gnome = import('gnome') ui_resources = gnome.compile_resources( 'ui_resources', 'ui.gresource.xml', source_dir : 'res/ui', ) exe = executable('xcode-test', 'main.c') ``` 3. Set up a build with the Xcode backend ```bash meson setup build --backend xcode ``` **Expected behavior** An Xcode project is created successfully, without any Python tracebacks. **system parameters** * Native build for Intel Mac * OS: macOS Catalina 10.15.7 (19H1715) * `python -V`: Python 3.8.12 * `meson --version`: 0.61.3 * `ninja --version`: 1.10.2 **Debugging information** I debugged this with ipdb by setting a breakpoint at `mesonbuild/backend/xcodebackend.py:825`: ``` ipdb> b mesonbuild/backend/xcodebackend.py:825 ``` The error arises when Meson is processing the argument `'ui.gresource.xml'` to `gnome.compile_resources`: ``` 824 elif isinstance(s, str): 1-> 825 s = os.path.joni(t.subdir, s) 826 else: ipdb> print(s) res/ui.gresource.xml ``` I've also located 3 occurrences of this bug in 0.61.3: https://github.com/mesonbuild/meson/blob/5cf5575a7c76746935dcd9a9e380803c85023c04/mesonbuild/backend/xcodebackend.py#L825 https://github.com/mesonbuild/meson/blob/5cf5575a7c76746935dcd9a9e380803c85023c04/mesonbuild/backend/xcodebackend.py#L945 https://github.com/mesonbuild/meson/blob/5cf5575a7c76746935dcd9a9e380803c85023c04/mesonbuild/backend/xcodebackend.py#L978 As of now, the bug persists in the latest master (commit 86aaac8e4229608b25508027267f49624a9a8cb5).
#8649 #8671 So good to know that xcode has comprehensive testsuite coverage. :D Perhaps if we installed more testsuite dependencies. EDIT: right, that's still not running in CI is it.
2022-03-30T16:48:20Z
[]
[]
Traceback (most recent call last): File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/mesonmain.py", line 146, in run return options.run_func(options) File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/msetup.py", line 294, in run app.generate() File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/msetup.py", line 185, in generate self._generate(env) File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/msetup.py", line 247, in _generate intr.backend.generate() File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/backend/xcodebackend.py", line 302, in generate self.generate_pbx_file_reference(objects_dict) File "/Users/jonancm/Library/Caches/pypoetry/virtualenvs/testapp-gtkmm3-UQ0_I4tI-py3.8/lib/python3.8/site-packages/mesonbuild/backend/xcodebackend.py", line 825, in generate_pbx_file_reference s = os.path.joni(t.subdir, s) AttributeError: module 'posixpath' has no attribute 'joni'
8,721
mesonbuild/meson
mesonbuild__meson-10230
2c4c7f6e64c923976158051cae8c63ee1364d573
diff --git a/packaging/hook-mesonbuild.py b/packaging/hook-mesonbuild.py --- a/packaging/hook-mesonbuild.py +++ b/packaging/hook-mesonbuild.py @@ -7,6 +7,9 @@ import os from glob import glob +from PyInstaller.utils.hooks import collect_data_files + +datas = [] hiddenimports = [] def get_all_modules_from_dir(dirname): @@ -18,6 +21,10 @@ def get_all_modules_from_dir(dirname): modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')] return modules +datas += collect_data_files('mesonbuild.scripts') +datas += collect_data_files('mesonbuild.cmake.data') +datas += collect_data_files('mesonbuild.dependencies.data') + hiddenimports += get_all_modules_from_dir('mesonbuild/modules') hiddenimports += get_all_modules_from_dir('mesonbuild/scripts')
Unhandled python exception with 0.62 on windows (0.61 ok) **Describe the bug** When running meson 0.62 on win32 and a project using `dependency()` (ex glib): Unhandled python exception ModuleNotFoundError: No module named 'mesonbuild.dependencies.data' ``` Traceback (most recent call last): File "mesonbuild\mesonmain.py", line 151, in run File "mesonbuild\msetup.py", line 301, in run File "mesonbuild\msetup.py", line 185, in generate File "mesonbuild\msetup.py", line 229, in _generate File "mesonbuild\interpreter\interpreter.py", line 2698, in run File "mesonbuild\interpreterbase\interpreterbase.py", line 149, in run File "mesonbuild\interpreterbase\interpreterbase.py", line 174, in evaluate_codeblock File "mesonbuild\interpreterbase\interpreterbase.py", line 167, in evaluate_codeblock File "mesonbuild\interpreterbase\interpreterbase.py", line 182, in evaluate_statement File "mesonbuild\interpreterbase\interpreterbase.py", line 567, in assignment File "mesonbuild\interpreterbase\interpreterbase.py", line 180, in evaluate_statement File "mesonbuild\interpreterbase\interpreterbase.py", line 455, in function_call File "mesonbuild\interpreterbase\decorators.py", line 768, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 768, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 768, in wrapped [Previous line repeated 5 more times] File "mesonbuild\interpreterbase\decorators.py", line 109, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 127, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 277, in wrapper File "mesonbuild\interpreter\interpreter.py", line 1620, in func_dependency File "mesonbuild\interpreter\dependencyfallbacks.py", line 352, in lookup File "mesonbuild\interpreter\dependencyfallbacks.py", line 93, in _do_dependency File "mesonbuild\dependencies\detect.py", line 112, in find_external_dependency File "mesonbuild\dependencies\cmake.py", line 135, in __init__ File "mesonbuild\dependencies\cmake.py", line 183, in _get_cmake_info File "mesonbuild\dependencies\cmake.py", line 614, in _call_cmake File "mesonbuild\dependencies\cmake.py", line 585, in _setup_cmake_dir File "importlib\resources.py", line 103, in read_text File "importlib\resources.py", line 82, in open_text File "importlib\resources.py", line 43, in open_binary File "importlib\_common.py", line 66, in get_package File "importlib\_common.py", line 57, in resolve File "importlib\__init__.py", line 126, in import_module File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'mesonbuild.dependencies.data' ``` **To Reproduce** project('foo') pcre = dependency('libpcre') **system parameters** meson 0.62 (MSI) on windev VM (https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/) works as expected on 0.61
Have you wiped your builddir after upgrading to 0.62? Forget that, it's probably https://github.com/mesonbuild/meson/commit/140097faf0eddcc7819a3353eb7c21b82a7df1e0. CC @eli-schwartz That seems quite likely, but what I don't understand is: this is stdlib functionality and the reason it is supposed to be so good (as opposed to pkg_resources) is specifically because it works everywhere. I am very curious to know what the MSI is doing differently to set up its installation environment, but I don't have the right system to investigate. Does that directory exist at all inside the meson module as packaged in the MSI? @eli-schwartz if you have linux+kvm, you may want to install a free trial windev vm. I have a script that can help (https://github.com/elmarco/virt-install-windev), but it is partially broken.
2022-04-03T05:37:38Z
[]
[]
Traceback (most recent call last): File "mesonbuild\mesonmain.py", line 151, in run File "mesonbuild\msetup.py", line 301, in run File "mesonbuild\msetup.py", line 185, in generate File "mesonbuild\msetup.py", line 229, in _generate File "mesonbuild\interpreter\interpreter.py", line 2698, in run File "mesonbuild\interpreterbase\interpreterbase.py", line 149, in run File "mesonbuild\interpreterbase\interpreterbase.py", line 174, in evaluate_codeblock File "mesonbuild\interpreterbase\interpreterbase.py", line 167, in evaluate_codeblock File "mesonbuild\interpreterbase\interpreterbase.py", line 182, in evaluate_statement File "mesonbuild\interpreterbase\interpreterbase.py", line 567, in assignment File "mesonbuild\interpreterbase\interpreterbase.py", line 180, in evaluate_statement File "mesonbuild\interpreterbase\interpreterbase.py", line 455, in function_call File "mesonbuild\interpreterbase\decorators.py", line 768, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 768, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 768, in wrapped [Previous line repeated 5 more times] File "mesonbuild\interpreterbase\decorators.py", line 109, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 127, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 277, in wrapper File "mesonbuild\interpreter\interpreter.py", line 1620, in func_dependency File "mesonbuild\interpreter\dependencyfallbacks.py", line 352, in lookup File "mesonbuild\interpreter\dependencyfallbacks.py", line 93, in _do_dependency File "mesonbuild\dependencies\detect.py", line 112, in find_external_dependency File "mesonbuild\dependencies\cmake.py", line 135, in __init__ File "mesonbuild\dependencies\cmake.py", line 183, in _get_cmake_info File "mesonbuild\dependencies\cmake.py", line 614, in _call_cmake File "mesonbuild\dependencies\cmake.py", line 585, in _setup_cmake_dir File "importlib\resources.py", line 103, in read_text File "importlib\resources.py", line 82, in open_text File "importlib\resources.py", line 43, in open_binary File "importlib\_common.py", line 66, in get_package File "importlib\_common.py", line 57, in resolve File "importlib\__init__.py", line 126, in import_module File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'mesonbuild.dependencies.data'
8,724
mesonbuild/meson
mesonbuild__meson-1025
e02aaad63286169aebf63109363fed648a185b05
diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -90,10 +90,11 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, f_abs = os.path.join(doc_src, f) shutil.copyfile(f_abs, os.path.join(htmldir, os.path.basename(f_abs))) - scan_cmd = ['gtkdoc-scan', - '--module=' + module, - '--source-dir=' + abs_src, - '--ignore-headers=' + ignore_headers] + scan_args + scan_cmd = ['gtkdoc-scan', '--module=' + module, '--source-dir=' + abs_src] + if ignore_headers: + scan_cmd.append('--ignore-headers=' + ' '.join(ignore_headers)) + # Add user-specified arguments + scan_cmd += scan_args gtkdoc_run_check(scan_cmd, abs_out) if gobject_typesfile:
gtkdoc ignore_headers support breaks gstreamer build ``` Building documentation for gstreamer Traceback (most recent call last): File "/path/to/meson/meson.py", line 26, in <module> sys.exit(main()) File "/path/to/meson/meson.py", line 23, in main return mesonmain.run(launcher, sys.argv[1:]) File "/path/to/meson/mesonbuild/mesonmain.py", line 249, in run sys.exit(run_script_command(args[1:])) File "/path/to/meson/mesonbuild/mesonmain.py", line 239, in run_script_command return cmdfunc(cmdargs) File "/path/to/meson/mesonbuild/scripts/gtkdochelper.py", line 182, in run options.ignore_headers.split('@@') if options.ignore_headers else []) File "/path/to/meson/mesonbuild/scripts/gtkdochelper.py", line 96, in build_gtkdoc '--ignore-headers=' + ignore_headers] + scan_args TypeError: Can't convert 'list' object to str implicitly ``` It seems that this error is caused by https://github.com/mesonbuild/meson/pull/980. When `ignore_headers` is not used in the build file, it defaults to an empty list, not an empty string.
@ebassi
2016-11-11T03:51:25Z
[]
[]
Traceback (most recent call last): File "/path/to/meson/meson.py", line 26, in <module> sys.exit(main()) File "/path/to/meson/meson.py", line 23, in main return mesonmain.run(launcher, sys.argv[1:]) File "/path/to/meson/mesonbuild/mesonmain.py", line 249, in run sys.exit(run_script_command(args[1:])) File "/path/to/meson/mesonbuild/mesonmain.py", line 239, in run_script_command return cmdfunc(cmdargs) File "/path/to/meson/mesonbuild/scripts/gtkdochelper.py", line 182, in run options.ignore_headers.split('@@') if options.ignore_headers else []) File "/path/to/meson/mesonbuild/scripts/gtkdochelper.py", line 96, in build_gtkdoc '--ignore-headers=' + ignore_headers] + scan_args TypeError: Can't convert 'list' object to str implicitly
8,726
mesonbuild/meson
mesonbuild__meson-1028
e02aaad63286169aebf63109363fed648a185b05
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -598,11 +598,17 @@ def eval_custom_target_command(self, target, absolute_paths=False): i = i.replace('@OUTDIR@', outdir) elif '@DEPFILE@' in i: if target.depfile is None: - raise MesonException('Custom target %s has @DEPFILE@ but no depfile keyword argument.' % target.name) + msg = 'Custom target {!r} has @DEPFILE@ but no depfile ' \ + 'keyword argument.'.format(target.name) + raise MesonException(msg) dfilename = os.path.join(outdir, target.depfile) i = i.replace('@DEPFILE@', dfilename) elif '@PRIVATE_OUTDIR_' in i: - match = re.search('@PRIVATE_OUTDIR_(ABS_)?([-a-zA-Z0-9.@:]*)@', i) + match = re.search('@PRIVATE_OUTDIR_(ABS_)?([^\/\s*]*)@', i) + if not match: + msg = 'Custom target {!r} has an invalid argument {!r}' \ + ''.format(target.name, i) + raise MesonException(msg) source = match.group(0) if match.group(1) is None and not absolute_paths: lead_dir = ''
gnome.generate_gir: cryptic error when the name of the library contains an underscore. Given this meson.build: ``` project('Hotdoc-Test', 'c') gnome = import ('gnome') glib_dep = dependency('glib-2.0') gobject_dep = dependency('gobject-2.0') sources = ['test-greeter.c'] headers = ['test-greeter.h'] testlib = shared_library('test_lib', sources, install: true, dependencies: [glib_dep, gobject_dep], c_args: ['-Wno-pedantic'], ) gir = gnome.generate_gir(testlib, sources : sources + headers, nsversion : '1.0', namespace : 'Test', symbol_prefix : 'test_', identifier_prefix : 'Test', export_packages : 'test', includes : ['GObject-2.0'], install : true, ) ``` Assuming the two source files exist, `mkdir build && cd build && meson ..` raises: ``` (dev_env)[meh@meh-host build]$ rm -rf * && meson.py .. The Meson build system Version: 0.30.0.dev1 Source dir: /home/meh/devel/hotdoc/test_hotdoc Build dir: /home/meh/devel/hotdoc/test_hotdoc/build Build type: native build Build machine cpu family: x86_64 Build machine cpu: x86_64 Project name: Hotdoc-Test Native c compiler: cc (gcc 5.3.1) Warning, glib compiled dependencies will not work reliably until this upstream issue is fixed: https://bugzilla.gnome.org/show_bug.cgi?id=745754 Found pkg-config: /usr/bin/pkg-config (0.28) Native dependency glib-2.0 found: YES 2.44.1 Native dependency gobject-2.0 found: YES 2.44.1 Build targets in project: 3 Traceback (most recent call last): File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/mesonmain.py", line 266, in run app.generate() File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/mesonmain.py", line 170, in generate g.generate(intr) File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/ninjabackend.py", line 176, in generate [self.generate_target(t, outfile) for t in self.build.get_targets().values()] File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/ninjabackend.py", line 176, in <listcomp> [self.generate_target(t, outfile) for t in self.build.get_targets().values()] File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/ninjabackend.py", line 219, in generate_target self.generate_custom_target(target, outfile) File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/ninjabackend.py", line 338, in generate_custom_target (srcs, ofilenames, cmd) = self.eval_custom_target_command(target) File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/backends.py", line 427, in eval_custom_target_command source = match.group(0) AttributeError: 'NoneType' object has no attribute 'group' (dev_env)[meh@meh-host build]$ ``` This is with latest git master, I know this project used to build some time ago, so this must be a regression. I had a quick look at the regex in question and figured out the issue, I'm not sure why regular expressions would be at all needed for these internal operations, it seems quite prone to breakage.
This is a pretty bad error, and I don't think resolution should be overly hard, @jpakkane not interested? Jussi is low on bandwidth these days, but he will review any patches you provide. :) Thanks @nirbheek , low on time here though and I don't depend on meson in production so don't expect too much ;) @MathieuDuponchelle > I had a quick look at the regex in question and figured out the issue Perhaps you could share your findings? :) Ah well I read: ``` match = re.search('@PRIVATE_OUTDIR_(ABS_)?([-a-zA-Z0-9.@:]*)@', i) source = match.group(0) ``` and guessed as "_" was not listed in there it was my problem, but I haven't tried to understand the context so that's not really helpful here :) As I said, at first glance I'm a bit surprised regexes are even used in that context, looks pretty fragile to me, but maybe there's a very good reason.
2016-11-11T05:45:51Z
[]
[]
Traceback (most recent call last): File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/mesonmain.py", line 266, in run app.generate() File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/mesonmain.py", line 170, in generate g.generate(intr) File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/ninjabackend.py", line 176, in generate [self.generate_target(t, outfile) for t in self.build.get_targets().values()] File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/ninjabackend.py", line 176, in <listcomp> [self.generate_target(t, outfile) for t in self.build.get_targets().values()] File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/ninjabackend.py", line 219, in generate_target self.generate_custom_target(target, outfile) File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/ninjabackend.py", line 338, in generate_custom_target (srcs, ofilenames, cmd) = self.eval_custom_target_command(target) File "/usr/lib/python3.4/site-packages/meson-0.30.0.dev1-py3.4.egg/mesonbuild/backend/backends.py", line 427, in eval_custom_target_command source = match.group(0) AttributeError: 'NoneType' object has no attribute 'group'
8,730
mesonbuild/meson
mesonbuild__meson-10295
78020598a6bdfd684ca3c11f99fe1de8e3eb8ed5
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -822,7 +822,7 @@ def generate_pbx_file_reference(self, objects_dict): if isinstance(s, mesonlib.File): s = os.path.join(s.subdir, s.fname) elif isinstance(s, str): - s = os.path.joni(t.subdir, s) + s = os.path.join(t.subdir, s) else: continue custom_dict = PbxDict() @@ -942,7 +942,7 @@ def generate_pbx_group(self, objects_dict): if isinstance(s, mesonlib.File): s = os.path.join(s.subdir, s.fname) elif isinstance(s, str): - s = os.path.joni(t.subdir, s) + s = os.path.join(t.subdir, s) else: continue source_file_children.add_item(self.fileref_ids[(tname, s)], s) @@ -975,7 +975,7 @@ def write_group_target_entry(self, objects_dict, t): if isinstance(s, mesonlib.File): s = os.path.join(s.subdir, s.fname) elif isinstance(s, str): - s = os.path.joni(t.subdir, s) + s = os.path.join(t.subdir, s) else: continue target_children.add_item(self.fileref_ids[(tid, s)], s) diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -793,7 +793,7 @@ def __init__(self, build: 'Build', subdir: Path, src_dir: Path, install_prefix: self.languages = [] # type: T.List[str] self.targets = [] # type: T.List[ConverterTarget] self.custom_targets = [] # type: T.List[ConverterCustomTarget] - self.trace = CMakeTraceParser('', Path('.')) # Will be replaced in analyse + self.trace: CMakeTraceParser self.output_target_map = OutputTargetMap(self.build_dir) # Generated meson data diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -183,7 +183,7 @@ defaults['rust'] = ['rustc'] defaults['swift'] = ['swiftc'] defaults['vala'] = ['valac'] -defaults['cython'] = ['cython'] +defaults['cython'] = ['cython', 'cython3'] # Official name is cython, but Debian renamed it to cython3. defaults['static_linker'] = ['ar', 'gar'] defaults['strip'] = ['strip'] defaults['vs_static_linker'] = ['lib'] diff --git a/mesonbuild/compilers/mixins/compcert.py b/mesonbuild/compilers/mixins/compcert.py --- a/mesonbuild/compilers/mixins/compcert.py +++ b/mesonbuild/compilers/mixins/compcert.py @@ -32,7 +32,7 @@ 'plain': [''], 'debug': ['-O0', '-g'], 'debugoptimized': ['-O0', '-g'], - 'release': ['-03'], + 'release': ['-O3'], 'minsize': ['-Os'], 'custom': ['-Obranchless'], } # type: T.Dict[str, T.List[str]] diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -106,14 +106,7 @@ def gnulike_default_include_dirs(compiler: T.Tuple[str, ...], lang: str) -> 'Imm env = os.environ.copy() env["LC_ALL"] = 'C' cmd = list(compiler) + [f'-x{lang}', '-E', '-v', '-'] - p = subprocess.Popen( - cmd, - stdin=subprocess.DEVNULL, - stderr=subprocess.STDOUT, - stdout=subprocess.PIPE, - env=env - ) - stdout = p.stdout.read().decode('utf-8', errors='replace') + _, stdout, _ = mesonlib.Popen_safe(cmd, stderr=subprocess.STDOUT, env=env) parse_state = 0 paths = [] # type: T.List[str] for line in stdout.split('\n'): diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -1209,7 +1209,7 @@ def add_to_argparse(self, name: str, parser: argparse.ArgumentParser, help_suffi (OptionKey('backend'), BuiltinOption(UserComboOption, 'Backend to use', 'ninja', choices=backendlist)), (OptionKey('buildtype'), BuiltinOption(UserComboOption, 'Build type to use', 'debug', choices=['plain', 'debug', 'debugoptimized', 'release', 'minsize', 'custom'])), - (OptionKey('debug'), BuiltinOption(UserBooleanOption, 'Debug', True)), + (OptionKey('debug'), BuiltinOption(UserBooleanOption, 'Enable debug symbols and other information', True)), (OptionKey('default_library'), BuiltinOption(UserComboOption, 'Default library type', 'shared', choices=['shared', 'static', 'both'], yielding=False)), (OptionKey('errorlogs'), BuiltinOption(UserBooleanOption, "Whether to print the logs from failing tests", True)), diff --git a/mesonbuild/dependencies/cmake.py b/mesonbuild/dependencies/cmake.py --- a/mesonbuild/dependencies/cmake.py +++ b/mesonbuild/dependencies/cmake.py @@ -76,10 +76,10 @@ def _original_module_name(self, module: str) -> str: # one module return module - def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None: + def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None, force_use_global_compilers: bool = False) -> None: # Gather a list of all languages to support self.language_list = [] # type: T.List[str] - if language is None: + if language is None or force_use_global_compilers: compilers = None if kwargs.get('native', False): compilers = environment.coredata.compilers.build diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -26,7 +26,7 @@ from ..compilers import AppleClangCCompiler, AppleClangCPPCompiler, detect_compiler_for from ..environment import get_llvm_tool_names from ..mesonlib import version_compare, stringlistify, extract_as_list, MachineChoice -from .base import DependencyException, DependencyMethods, strip_system_libdirs, SystemDependency +from .base import DependencyException, DependencyMethods, strip_system_libdirs, SystemDependency, ExternalDependency, DependencyTypeName from .cmake import CMakeDependency from .configtool import ConfigToolDependency from .factory import DependencyFactory @@ -392,7 +392,25 @@ class LLVMDependencyCMake(CMakeDependency): def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]) -> None: self.llvm_modules = stringlistify(extract_as_list(kwargs, 'modules')) self.llvm_opt_modules = stringlistify(extract_as_list(kwargs, 'optional_modules')) - super().__init__(name, env, kwargs, language='cpp') + + compilers = None + if kwargs.get('native', False): + compilers = env.coredata.compilers.build + else: + compilers = env.coredata.compilers.host + if not compilers or not all(x in compilers for x in ('c', 'cpp')): + # Initialize basic variables + ExternalDependency.__init__(self, DependencyTypeName('cmake'), env, kwargs) + + # Initialize CMake specific variables + self.found_modules: T.List[str] = [] + self.name = name + + # Warn and return + mlog.warning('The LLVM dependency was not found via CMake since both a C and C++ compiler are required.') + return + + super().__init__(name, env, kwargs, language='cpp', force_use_global_compilers=True) # Cmake will always create a statically linked binary, so don't use # cmake if dynamic is required diff --git a/mesonbuild/dependencies/qt.py b/mesonbuild/dependencies/qt.py --- a/mesonbuild/dependencies/qt.py +++ b/mesonbuild/dependencies/qt.py @@ -69,6 +69,12 @@ def get_qmake_host_bins(qvars: T.Dict[str, str]) -> str: return qvars['QT_INSTALL_BINS'] +def get_qmake_host_libexecs(qvars: T.Dict[str, str]) -> T.Optional[str]: + if 'QT_HOST_LIBEXECS' in qvars: + return qvars['QT_HOST_LIBEXECS'] + return qvars.get('QT_INSTALL_LIBEXECS') + + def _get_modules_lib_suffix(version: str, info: 'MachineInfo', is_debug: bool) -> str: """Get the module suffix based on platform and debug type.""" suffix = '' @@ -118,8 +124,10 @@ class _QtBase: link_args: T.List[str] clib_compiler: 'Compiler' env: 'Environment' + libexecdir: T.Optional[str] = None def __init__(self, name: str, kwargs: T.Dict[str, T.Any]): + self.name = name self.qtname = name.capitalize() self.qtver = name[-1] if self.qtver == "4": @@ -237,7 +245,7 @@ class QmakeQtDependency(_QtBase, ConfigToolDependency, metaclass=abc.ABCMeta): def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): _QtBase.__init__(self, name, kwargs) - self.tools = [f'qmake-{self.qtname}', 'qmake'] + self.tools = [f'qmake{self.qtver}', f'qmake-{self.name}', 'qmake'] # Add additional constraints that the Qt version is met, but preserve # any version requrements the user has set as well. For example, if Qt5 @@ -277,6 +285,7 @@ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): libdir = qvars['QT_INSTALL_LIBS'] # Used by qt.compilers_detect() self.bindir = get_qmake_host_bins(qvars) + self.libexecdir = get_qmake_host_libexecs(qvars) # Use the buildtype by default, but look at the b_vscrt option if the # compiler supports it. @@ -353,6 +362,7 @@ def _framework_detect(self, qvars: T.Dict[str, str], modules: T.List[str], kwarg self.is_found = True # Used by self.compilers_detect() self.bindir = get_qmake_host_bins(qvars) + self.libexecdir = get_qmake_host_libexecs(qvars) def log_info(self) -> str: return 'qmake' diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -65,7 +65,6 @@ def __init__(self, build_dir): # XXX: is there a case where this can actually remain false? self.has_choices = False self.all_subprojects: T.Set[str] = set() - self.yielding_options: T.Set[OptionKey] = set() if os.path.isdir(os.path.join(self.build_dir, 'meson-private')): self.build = build.load(self.build_dir) @@ -150,16 +149,12 @@ def print_aligned(self) -> None: for l in itertools.zip_longest(name, val, desc, fillvalue=''): print('{:{widths[0]}} {:{widths[1]}} {}'.format(*l, widths=three_column)) - def split_options_per_subproject(self, options: 'coredata.KeyedOptionDictType') -> T.Dict[str, T.Dict[str, 'UserOption']]: - result: T.Dict[str, T.Dict[str, 'UserOption']] = {} + def split_options_per_subproject(self, options: 'coredata.KeyedOptionDictType') -> T.Dict[str, 'coredata.KeyedOptionDictType']: + result: T.Dict[str, 'coredata.KeyedOptionDictType'] = {} for k, o in options.items(): - subproject = k.subproject if k.subproject: - k = k.as_root() - if o.yielding and k in options: - self.yielding_options.add(k) - self.all_subprojects.add(subproject) - result.setdefault(subproject, {})[str(k)] = o + self.all_subprojects.add(k.subproject) + result.setdefault(k.subproject, {})[k] = o return result def _add_line(self, name: OptionKey, value, choices, descr) -> None: @@ -219,9 +214,10 @@ def print_options(self, title: str, options: 'coredata.KeyedOptionDictType') -> self.add_title(title) for k, o in sorted(options.items()): printable_value = o.printable_value() - if k in self.yielding_options: + root = k.as_root() + if o.yielding and k.subproject and root in self.coredata.options: printable_value = '<inherited from main project>' - self.add_option(k, o.description, printable_value, o.choices) + self.add_option(str(root), o.description, printable_value, o.choices) def print_conf(self): def print_default_values_warning(): @@ -270,8 +266,8 @@ def print_default_values_warning(): self.print_options('Core options', host_core_options['']) if show_build_options: self.print_options('', build_core_options['']) - self.print_options('Backend options', {str(k): v for k, v in self.coredata.options.items() if k.is_backend()}) - self.print_options('Base options', {str(k): v for k, v in self.coredata.options.items() if k.is_base()}) + self.print_options('Backend options', {k: v for k, v in self.coredata.options.items() if k.is_backend()}) + self.print_options('Base options', {k: v for k, v in self.coredata.options.items() if k.is_base()}) self.print_options('Compiler options', host_compiler_options.get('', {})) if show_build_options: self.print_options('', build_compiler_options.get('', {})) diff --git a/mesonbuild/mdist.py b/mesonbuild/mdist.py --- a/mesonbuild/mdist.py +++ b/mesonbuild/mdist.py @@ -13,9 +13,11 @@ # limitations under the License. +import argparse import gzip import os import sys +import shlex import shutil import subprocess import tarfile @@ -27,8 +29,9 @@ from mesonbuild.environment import detect_ninja from mesonbuild.mesonlib import (MesonException, RealPathAction, quiet_git, windows_proof_rmtree, setup_vsenv) +from mesonbuild.msetup import add_arguments as msetup_argparse from mesonbuild.wrap import wrap -from mesonbuild import mlog, build +from mesonbuild import mlog, build, coredata from .scripts.meson_exe import run_exe archive_choices = ['gztar', 'xztar', 'zip'] @@ -251,9 +254,7 @@ def check_dist(packagename, meson_command, extra_meson_args, bld_root, privdir): unpacked_files = glob(os.path.join(unpackdir, '*')) assert len(unpacked_files) == 1 unpacked_src_dir = unpacked_files[0] - with open(os.path.join(bld_root, 'meson-info', 'intro-buildoptions.json'), encoding='utf-8') as boptions: - meson_command += ['-D{name}={value}'.format(**o) for o in json.load(boptions) - if o['name'] not in ['backend', 'install_umask', 'buildtype']] + meson_command += create_cmdline_args(bld_root) meson_command += extra_meson_args ret = run_dist_steps(meson_command, unpacked_src_dir, builddir, installdir, ninja_args) @@ -266,6 +267,15 @@ def check_dist(packagename, meson_command, extra_meson_args, bld_root, privdir): print(f'Distribution package {packagename} tested') return ret +def create_cmdline_args(bld_root): + parser = argparse.ArgumentParser() + msetup_argparse(parser) + args = parser.parse_args([]) + coredata.parse_cmd_line_options(args) + coredata.read_cmd_line_file(bld_root, args) + args.cmd_line_options.pop(coredata.OptionKey('backend'), '') + return shlex.split(coredata.format_cmd_line_options(args)) + def determine_archives_to_generate(options): result = [] for i in options.formats.split(','): diff --git a/mesonbuild/mesondata.py b/mesonbuild/mesondata.py --- a/mesonbuild/mesondata.py +++ b/mesonbuild/mesondata.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Meson development team +# Copyright 2022 The Meson development team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -217,7 +217,6 @@ ''' file_2_data_CMakeListsLLVM_txt = '''\ -cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} ) set(PACKAGE_FOUND FALSE) @@ -383,7 +382,7 @@ def write_to_private(self, env: 'Environment') -> Path: ), 'dependencies/data/CMakeListsLLVM.txt': DataFile( Path('dependencies/data/CMakeListsLLVM.txt'), - '412cec3315597041a978d018cdaca282dcd47693793540da88ae2f80d0cbd7cd', + 'a824db0251c77482993534230f33c521275047a37189ae0ac80d9078e4d7006e', file_2_data_CMakeListsLLVM_txt, ), 'dependencies/data/CMakePathInfo.txt': DataFile( diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -696,6 +696,8 @@ def darwin_get_object_archs(objpath: str) -> 'ImmutableListProtocol[str]': # Convert from lipo-style archs to meson-style CPUs stdo = stdo.replace('i386', 'x86') stdo = stdo.replace('arm64', 'aarch64') + stdo = stdo.replace('ppc7400', 'ppc') + stdo = stdo.replace('ppc970', 'ppc') # Add generic name for armv7 and armv7s if 'armv7' in stdo: stdo += ' arm' diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -18,6 +18,7 @@ sys.modules['pathlib'] = _pathlib import os.path +import platform import importlib import traceback import argparse @@ -91,8 +92,9 @@ def add_command(self, name, add_arguments_func, run_func, help_msg, aliases=None for i in [name] + aliases: self.commands[i] = p - def add_runpython_arguments(self, parser): + def add_runpython_arguments(self, parser: argparse.ArgumentParser): parser.add_argument('-c', action='store_true', dest='eval_arg', default=False) + parser.add_argument('--version', action='version', version=platform.python_version()) parser.add_argument('script_file') parser.add_argument('script_args', nargs=argparse.REMAINDER) diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -460,10 +460,12 @@ def do_copyfile(self, from_file: str, to_file: str, append_to_log(self.lf, to_file) return True - def do_symlink(self, target: str, link: str, full_dst_dir: str) -> bool: + def do_symlink(self, target: str, link: str, destdir: str, full_dst_dir: str) -> bool: abs_target = target if not os.path.isabs(target): abs_target = os.path.join(full_dst_dir, target) + elif not os.path.exists(abs_target): + abs_target = destdir_join(destdir, abs_target) if not os.path.exists(abs_target): raise MesonException(f'Tried to install symlink to missing file {abs_target}') if os.path.exists(link): @@ -635,7 +637,7 @@ def install_symlinks(self, d: InstallData, dm: DirMaker, destdir: str, fullprefi full_dst_dir = get_destdir_path(destdir, fullprefix, s.install_path) full_link_name = get_destdir_path(destdir, fullprefix, s.name) dm.makedirs(full_dst_dir, exist_ok=True) - if self.do_symlink(s.target, full_link_name, full_dst_dir): + if self.do_symlink(s.target, full_link_name, destdir, full_dst_dir): self.did_install_something = True def install_man(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix: str) -> None: @@ -756,7 +758,7 @@ def install_targets(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix raise RuntimeError(f'Unknown file type for {fname!r}') for alias, target in aliases.items(): symlinkfilename = os.path.join(outdir, alias) - self.do_symlink(target, symlinkfilename, outdir) + self.do_symlink(target, symlinkfilename, destdir, outdir) if file_copied: self.did_install_something = True try: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -364,7 +364,7 @@ def post_install(self, state: 'ModuleState', args: T.List['TYPE_var'], kwargs: ' prog = state.find_program('gtk4-update-icon-cache', required=False) found = isinstance(prog, build.Executable) or prog.found() if not found: - prog = state.find_program('gtk4-update-icon-cache') + prog = state.find_program('gtk-update-icon-cache') icondir = os.path.join(datadir_abs, 'icons', 'hicolor') script = state.backend.get_executable_serialisation([prog, '-q', '-t', '-f', icondir]) script.skip_if_destdir = True diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -326,7 +326,6 @@ def links_against_libpython(): 'variables': variables, 'paths': paths, 'install_paths': install_paths, - 'sys_paths': sys.path, 'version': sysconfig.get_python_version(), 'platform': sysconfig.get_platform(), 'is_pypy': '__pypy__' in sys.builtin_module_names, @@ -380,8 +379,13 @@ def _check_version(self, version: str) -> bool: def sanity(self, state: T.Optional['ModuleState'] = None) -> bool: # Sanity check, we expect to have something that at least quacks in tune - cmd = self.get_command() + ['-c', INTROSPECT_COMMAND] + from tempfile import NamedTemporaryFile + with NamedTemporaryFile(suffix='.py', delete=False, mode='w', encoding='utf-8') as tf: + tmpfilename = tf.name + tf.write(INTROSPECT_COMMAND) + cmd = self.get_command() + [tmpfilename] p, stdout, stderr = mesonlib.Popen_safe(cmd) + os.unlink(tmpfilename) try: info = json.loads(stdout) except json.JSONDecodeError: @@ -410,14 +414,6 @@ def _get_path(self, state: T.Optional['ModuleState'], key: str) -> None: value = state.get_option(f'{key}dir', module='python') if value: return value - # Use python's path relative to prefix, and warn if that's not a location - # python will lookup for modules. - abs_path = Path(state.get_option('prefix'), rel_path) - sys_paths = [Path(i) for i in self.info['sys_paths']] - if abs_path not in sys_paths: - mlog.warning('Python files installed by Meson might not be found by python interpreter.\n', - f'This warning can be avoided by setting "python.{key}dir" option.', - once=True) return rel_path diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -128,8 +128,12 @@ def gen_bins() -> T.Generator[T.Tuple[str, str], None, None]: for b in self.tools: if qt_dep.bindir: yield os.path.join(qt_dep.bindir, b), b - # prefer the <tool>-qt<version> of the tool to the plain one, as we + if qt_dep.libexecdir: + yield os.path.join(qt_dep.libexecdir, b), b + # prefer the (official) <tool><version> or (unofficial) <tool>-qt<version> + # of the tool to the plain one, as we # don't know what the unsuffixed one points to without calling it. + yield f'{b}{qt_dep.qtver}', b yield f'{b}-qt{qt_dep.qtver}', b yield b, b diff --git a/packaging/createmsi.py b/packaging/createmsi.py --- a/packaging/createmsi.py +++ b/packaging/createmsi.py @@ -39,49 +39,6 @@ def gen_guid(): ''' return str(uuid.uuid4()).upper() -def get_all_modules_from_dir(dirname): - ''' - Get all modules required for Meson build MSI package - from directories. - ''' - modname = os.path.basename(dirname) - modules = [os.path.splitext(os.path.split(x)[1])[0] for x in glob(os.path.join(dirname, '*'))] - modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')] - return modules - -def get_more_modules(): - ''' - Getter for missing Modules. - Python packagers want to be minimal and only copy the things - that they can see that being used. They are blind to many things. - ''' - return ['distutils.archive_util', - 'distutils.cmd', - 'distutils.config', - 'distutils.core', - 'distutils.debug', - 'distutils.dep_util', - 'distutils.dir_util', - 'distutils.dist', - 'distutils.errors', - 'distutils.extension', - 'distutils.fancy_getopt', - 'distutils.file_util', - 'distutils.spawn', - 'distutils.util', - 'distutils.version', - 'distutils.command.build_ext', - 'distutils.command.build', - 'distutils.command.install', - 'filecmp', - ] - -def get_modules(): - modules = get_all_modules_from_dir('mesonbuild/modules') - modules += get_all_modules_from_dir('mesonbuild/scripts') - modules += get_more_modules() - return modules - class Node: ''' Node to hold path and directory values @@ -166,7 +123,6 @@ def build_dist(self): if os.path.exists(sdir): shutil.rmtree(sdir) main_stage, ninja_stage = self.staging_dirs - modules = get_modules() pyinstaller = shutil.which('pyinstaller') if not pyinstaller: @@ -178,10 +134,9 @@ def build_dist(self): shutil.rmtree(pyinstaller_tmpdir) pyinst_cmd = [pyinstaller, '--clean', + '--additional-hooks-dir=packaging', '--distpath', pyinstaller_tmpdir] - for m in modules: - pyinst_cmd += ['--hidden-import', m] pyinst_cmd += ['meson.py'] subprocess.check_call(pyinst_cmd) shutil.move(pyinstaller_tmpdir + '/meson', main_stage) diff --git a/packaging/createpkg.py b/packaging/createpkg.py --- a/packaging/createpkg.py +++ b/packaging/createpkg.py @@ -22,8 +22,6 @@ sys.path.append(os.getcwd()) from mesonbuild import coredata -from createmsi import get_modules - class PkgGenerator: def __init__(self): @@ -46,10 +44,9 @@ def build_dist(self): pyinstaller_bin = '/Users/jpakkane/Library/Python/3.8/bin/pyinstaller' pyinst_cmd = [pyinstaller_bin, '--clean', + '--additional-hooks-dir=packaging', '--distpath', self.pkg_dir] - for m in get_modules(): - pyinst_cmd += ['--hidden-import', m] pyinst_cmd += ['meson.py'] subprocess.check_call(pyinst_cmd) tmpdir = os.path.join(self.pkg_dir, 'meson') diff --git a/packaging/hook-mesonbuild.py b/packaging/hook-mesonbuild.py new file mode 100644 --- /dev/null +++ b/packaging/hook-mesonbuild.py @@ -0,0 +1,49 @@ +#!hint/python3 + +""" +PyInstaller hook to make mesonbuild include everything it needs to. +""" + +import os +from glob import glob + +hiddenimports = [] + +def get_all_modules_from_dir(dirname): + ''' + Get all modules required for Meson itself from directories. + ''' + modname = os.path.basename(dirname) + modules = [os.path.splitext(os.path.split(x)[1])[0] for x in glob(os.path.join(dirname, '*'))] + modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')] + return modules + +hiddenimports += get_all_modules_from_dir('mesonbuild/modules') +hiddenimports += get_all_modules_from_dir('mesonbuild/scripts') + +# Python packagers want to be minimal and only copy the things +# that they can see being used. They are blind to many things. +hiddenimports += [ + # we run distutils as a subprocess via INTROSPECT_COMMAND. + 'distutils.archive_util', + 'distutils.cmd', + 'distutils.config', + 'distutils.core', + 'distutils.debug', + 'distutils.dep_util', + 'distutils.dir_util', + 'distutils.dist', + 'distutils.errors', + 'distutils.extension', + 'distutils.fancy_getopt', + 'distutils.file_util', + 'distutils.spawn', + 'distutils.util', + 'distutils.version', + 'distutils.command.build_ext', + 'distutils.command.build', + 'distutils.command.install', + + # needed for gtk's find_program() scripts + 'filecmp', +] diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -83,7 +83,7 @@ def temp_filename(): except OSError: pass -def _git_init(project_dir): +def git_init(project_dir): # If a user has git configuration init.defaultBranch set we want to override that with tempfile.TemporaryDirectory() as d: out = git(['--version'], str(d))[1] @@ -1158,7 +1158,7 @@ def test_dist_git(self): raise SkipTest('Dist is only supported with Ninja') try: - self.dist_impl(_git_init, _git_add_all) + self.dist_impl(git_init, _git_add_all) except PermissionError: # When run under Windows CI, something (virus scanner?) # holds on to the git files so cleaning up the dir @@ -1213,7 +1213,7 @@ def test_dist_git_script(self): project_dir = os.path.join(tmpdir, 'a') shutil.copytree(os.path.join(self.unit_test_dir, '35 dist script'), project_dir) - _git_init(project_dir) + git_init(project_dir) self.init(project_dir) self.build('dist') @@ -2571,7 +2571,7 @@ def test_clang_format(self): # Ensure that test project is in git even when running meson from tarball. srcdir = os.path.join(self.builddir, 'src') shutil.copytree(testdir, srcdir) - _git_init(srcdir) + git_init(srcdir) testdir = srcdir self.new_builddir() @@ -3563,7 +3563,7 @@ def test_wrap_git(self): shutil.copytree(os.path.join(self.unit_test_dir, '81 wrap-git'), srcdir) upstream = os.path.join(srcdir, 'subprojects', 'wrap_git_upstream') upstream_uri = Path(upstream).as_uri() - _git_init(upstream) + git_init(upstream) with open(os.path.join(srcdir, 'subprojects', 'wrap_git.wrap'), 'w', encoding='utf-8') as f: f.write(textwrap.dedent(''' [wrap-git] diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -373,8 +373,8 @@ def test_qt6dependency_qmake_detection(self): Test that qt6 detection with qmake works. This can't be an ordinary test case because it involves setting the environment. ''' - # Verify that qmake is for Qt5 - if not shutil.which('qmake-qt6'): + # Verify that qmake is for Qt6 + if not shutil.which('qmake6'): if not shutil.which('qmake'): raise SkipTest('QMake not found') output = subprocess.getoutput('qmake --version') diff --git a/unittests/pythontests.py b/unittests/pythontests.py --- a/unittests/pythontests.py +++ b/unittests/pythontests.py @@ -14,12 +14,17 @@ import os import unittest +import pathlib +import subprocess from run_tests import ( Backend ) +from .allplatformstests import git_init + from .baseplatformtests import BasePlatformTests +from mesonbuild.mesonlib import TemporaryDirectoryWinProof class PythonTests(BasePlatformTests): ''' @@ -80,3 +85,15 @@ def test_versions(self): with self.assertRaises(unittest.SkipTest): self.init(testdir, extra_args=['-Dpython=dir']) self.wipe() + + def test_dist(self): + with TemporaryDirectoryWinProof() as dirstr: + dirobj = pathlib.Path(dirstr) + mesonfile = dirobj / 'meson.build' + mesonfile.write_text('''project('test', 'c', version: '1') +pymod = import('python') +python = pymod.find_installation('python3', required: true) +''', encoding='utf-8') + git_init(dirstr) + self.init(dirstr) + subprocess.check_call(self.meson_command + ['dist', '-C', self.builddir], stdout=subprocess.DEVNULL)
Python module broken on 0.62.0 for meson dist Running `meson dist` on 0.62.0 produces this error: ``` meson-private/dist-unpack/test-1/meson.build:4:0: ERROR: python.platlibdir and python.install_env are mutually exclusive ``` Required `meson.build` file: ``` project('test', 'c', version: '1') pymod = import('python') python = pymod.find_installation('python3', required: true) ``` And then just: ``` $ meson setup builddir/ $ meson dist -C builddir/ Testing distribution package /home/whot/tmp/2022-03-25-Fri/test/build/meson-dist/test-1.tar.xz The Meson build system Version: 0.62.0 Source dir: /home/whot/tmp/2022-03-25-Fri/test/build/meson-private/dist-unpack/test-1 Build dir: /home/whot/tmp/2022-03-25-Fri/test/build/meson-private/dist-build Build type: native build Project name: test Project version: 1 C compiler for the host machine: ccache cc (gcc 12.0.1 "cc (GCC) 12.0.1 20220308 (Red Hat 12.0.1-0)") C linker for the host machine: cc ld.bfd 2.37-24 Host machine cpu family: x86_64 Host machine cpu: x86_64 build/meson-private/dist-unpack/test-1/meson.build:4:0: ERROR: python.platlibdir and python.install_env are mutually exclusive A full log can be found at /home/whot/tmp/2022-03-25-Fri/test/build/meson-private/dist-build/meson-logs/meson-log.txt Running Meson on distribution package failed Dist check build directory was /home/whot/tmp/2022-03-25-Fri/test/build/meson-private/dist-build ``` There isn't really anything in the suggested meson-log.txt file, it's just the standard checks up to `Target machine cpu: x86_64` and then the error message. Reproduced on a Ubuntu 20.04 podman container (Python 3.8.10) and an up-to-date Fedora 36 (Python 3.10.3). Bisected to commit 78945fb9832e989453fbabc471d45bb71805eca8, cc @eli-schwartz. llvm: AttributeError: 'LLVMDependencyCMake' object has no attribute 'found_modules' **Describe the bug** Somehow the dependency on LLVM does not work anymore. I'm pretty sure this was different on prior Meson versions but cannot track it down. **To Reproduce** This meson.build file triggers the error: ``` project('testa', 'cpp') llvm = dependency('llvm') ``` Error: ``` The Meson build system Version: 0.62.1 Source dir: /home/gerion/test Build dir: /home/gerion/test/build Build type: native build Project name: testa Project version: undefined C++ compiler for the host machine: ccache c++ (gcc 10.2.1 "c++ (Debian 10.2.1-6) 10.2.1 20210110") C++ linker for the host machine: c++ ld.bfd 2.35.2 Host machine cpu family: x86_64 Host machine cpu: x86_64 WARNING: The LLVM dependency was not found via CMake since both a C and C++ compiler are required. Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/mesonbuild/mesonmain.py", line 153, in run return options.run_func(options) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 301, in run app.generate() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 185, in generate self._generate(env) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 229, in _generate intr.run() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/interpreter.py", line 2700, in run super().run() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 149, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 174, in evaluate_codeblock raise e File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_statement self.assignment(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 567, in assignment value = self.evaluate_statement(node.value) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 180, in evaluate_statement return self.function_call(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 455, in function_call res = func(node, func_args, kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) [Previous line repeated 5 more times] File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 109, in wrapped ret = f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 127, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper return f(*nargs, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/interpreter.py", line 1620, in func_dependency d = df.lookup(kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 352, in lookup dep = func(kwargs, func_args, func_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 93, in _do_dependency dep = dependencies.find_external_dependency(name, self.environment, kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/dependencies/detect.py", line 120, in find_external_dependency details = d.log_details() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/dependencies/cmake.py", line 621, in log_details modules = [self._original_module_name(x) for x in self.found_modules] AttributeError: 'LLVMDependencyCMake' object has no attribute 'found_modules' meson.build:2:0: ERROR: Unhandled python exception ``` **Expected behavior** LLVM should be found. **Additional information** Changing the project language to `c` leads to the same error. Changing the project language to `c` _and_ `cpp` fixes the error: meson.build ``` project('testa', 'c', 'cpp') llvm = dependency('llvm') ``` Output: ``` The Meson build system Version: 0.62.1 Source dir: /home/gerion/test Build dir: /home/gerion/test/build Build type: native build Project name: testa Project version: undefined C compiler for the host machine: ccache cc (gcc 10.2.1 "cc (Debian 10.2.1-6) 10.2.1 20210110") C linker for the host machine: cc ld.bfd 2.35.2 C++ compiler for the host machine: ccache c++ (gcc 10.2.1 "c++ (Debian 10.2.1-6) 10.2.1 20210110") C++ linker for the host machine: c++ ld.bfd 2.35.2 Host machine cpu family: x86_64 Host machine cpu: x86_64 Found CMake: /usr/bin/cmake (3.18.4) WARNING: Ignoring LLVM CMake dependency because dynamic was requested llvm-config found: YES (/usr/bin/llvm-config-13) 13.0.1 Run-time dependency LLVM found: YES 13.0.1 Build targets in project: 0 Found ninja-1.10.1 at /usr/bin/ninja ``` Setting config-tool as search method works, too: ``` project('testa', 'cpp') llvm = dependency('llvm', method: 'config-tool') ``` Output: ``` The Meson build system Version: 0.62.1 Source dir: /home/gerion/test Build dir: /home/gerion/test/build Build type: native build Project name: testa Project version: undefined C++ compiler for the host machine: ccache c++ (gcc 10.2.1 "c++ (Debian 10.2.1-6) 10.2.1 20210110") C++ linker for the host machine: c++ ld.bfd 2.35.2 Host machine cpu family: x86_64 Host machine cpu: x86_64 llvm-config found: YES (/usr/bin/llvm-config-13) 13.0.1 Run-time dependency LLVM found: YES 13.0.1 Build targets in project: 0 Found ninja-1.10.1 at /usr/bin/ninja ``` **system parameters** * Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)?: native * what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.): Debian 11 (with llvm-13 and llvm-12 backports) * what Python version are you using e.g. 3.8.0: 3.9.0 * what `meson --version`: 0.62.1
2022-04-21T11:31:08Z
[]
[]
Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/mesonbuild/mesonmain.py", line 153, in run return options.run_func(options) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 301, in run app.generate() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 185, in generate self._generate(env) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 229, in _generate intr.run() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/interpreter.py", line 2700, in run super().run() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 149, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 174, in evaluate_codeblock raise e File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_statement self.assignment(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 567, in assignment value = self.evaluate_statement(node.value) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 180, in evaluate_statement return self.function_call(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 455, in function_call res = func(node, func_args, kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) [Previous line repeated 5 more times] File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 109, in wrapped ret = f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 127, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper return f(*nargs, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/interpreter.py", line 1620, in func_dependency d = df.lookup(kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 352, in lookup dep = func(kwargs, func_args, func_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 93, in _do_dependency dep = dependencies.find_external_dependency(name, self.environment, kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/dependencies/detect.py", line 120, in find_external_dependency details = d.log_details() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/dependencies/cmake.py", line 621, in log_details modules = [self._original_module_name(x) for x in self.found_modules] AttributeError: 'LLVMDependencyCMake' object has no attribute 'found_modules'
8,733
mesonbuild/meson
mesonbuild__meson-10331
9b94045170d499faf598e790c055e371e9c24437
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -30,7 +30,7 @@ from ..compilers import AppleClangCCompiler, AppleClangCPPCompiler, detect_compiler_for from ..environment import get_llvm_tool_names from ..mesonlib import version_compare, stringlistify, extract_as_list -from .base import DependencyException, DependencyMethods, strip_system_libdirs, SystemDependency +from .base import DependencyException, DependencyMethods, strip_system_libdirs, SystemDependency, ExternalDependency, DependencyTypeName from .cmake import CMakeDependency from .configtool import ConfigToolDependency from .factory import DependencyFactory @@ -411,7 +411,14 @@ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]) -> else: compilers = env.coredata.compilers.host if not compilers or not all(x in compilers for x in ('c', 'cpp')): - self.is_found = False + # Initialize basic variables + ExternalDependency.__init__(self, DependencyTypeName('cmake'), env, kwargs) + + # Initialize CMake specific variables + self.found_modules: T.List[str] = [] + self.name = name + + # Warn and return mlog.warning('The LLVM dependency was not found via CMake since both a C and C++ compiler are required.') return
llvm: AttributeError: 'LLVMDependencyCMake' object has no attribute 'found_modules' **Describe the bug** Somehow the dependency on LLVM does not work anymore. I'm pretty sure this was different on prior Meson versions but cannot track it down. **To Reproduce** This meson.build file triggers the error: ``` project('testa', 'cpp') llvm = dependency('llvm') ``` Error: ``` The Meson build system Version: 0.62.1 Source dir: /home/gerion/test Build dir: /home/gerion/test/build Build type: native build Project name: testa Project version: undefined C++ compiler for the host machine: ccache c++ (gcc 10.2.1 "c++ (Debian 10.2.1-6) 10.2.1 20210110") C++ linker for the host machine: c++ ld.bfd 2.35.2 Host machine cpu family: x86_64 Host machine cpu: x86_64 WARNING: The LLVM dependency was not found via CMake since both a C and C++ compiler are required. Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/mesonbuild/mesonmain.py", line 153, in run return options.run_func(options) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 301, in run app.generate() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 185, in generate self._generate(env) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 229, in _generate intr.run() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/interpreter.py", line 2700, in run super().run() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 149, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 174, in evaluate_codeblock raise e File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_statement self.assignment(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 567, in assignment value = self.evaluate_statement(node.value) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 180, in evaluate_statement return self.function_call(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 455, in function_call res = func(node, func_args, kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) [Previous line repeated 5 more times] File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 109, in wrapped ret = f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 127, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper return f(*nargs, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/interpreter.py", line 1620, in func_dependency d = df.lookup(kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 352, in lookup dep = func(kwargs, func_args, func_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 93, in _do_dependency dep = dependencies.find_external_dependency(name, self.environment, kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/dependencies/detect.py", line 120, in find_external_dependency details = d.log_details() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/dependencies/cmake.py", line 621, in log_details modules = [self._original_module_name(x) for x in self.found_modules] AttributeError: 'LLVMDependencyCMake' object has no attribute 'found_modules' meson.build:2:0: ERROR: Unhandled python exception ``` **Expected behavior** LLVM should be found. **Additional information** Changing the project language to `c` leads to the same error. Changing the project language to `c` _and_ `cpp` fixes the error: meson.build ``` project('testa', 'c', 'cpp') llvm = dependency('llvm') ``` Output: ``` The Meson build system Version: 0.62.1 Source dir: /home/gerion/test Build dir: /home/gerion/test/build Build type: native build Project name: testa Project version: undefined C compiler for the host machine: ccache cc (gcc 10.2.1 "cc (Debian 10.2.1-6) 10.2.1 20210110") C linker for the host machine: cc ld.bfd 2.35.2 C++ compiler for the host machine: ccache c++ (gcc 10.2.1 "c++ (Debian 10.2.1-6) 10.2.1 20210110") C++ linker for the host machine: c++ ld.bfd 2.35.2 Host machine cpu family: x86_64 Host machine cpu: x86_64 Found CMake: /usr/bin/cmake (3.18.4) WARNING: Ignoring LLVM CMake dependency because dynamic was requested llvm-config found: YES (/usr/bin/llvm-config-13) 13.0.1 Run-time dependency LLVM found: YES 13.0.1 Build targets in project: 0 Found ninja-1.10.1 at /usr/bin/ninja ``` Setting config-tool as search method works, too: ``` project('testa', 'cpp') llvm = dependency('llvm', method: 'config-tool') ``` Output: ``` The Meson build system Version: 0.62.1 Source dir: /home/gerion/test Build dir: /home/gerion/test/build Build type: native build Project name: testa Project version: undefined C++ compiler for the host machine: ccache c++ (gcc 10.2.1 "c++ (Debian 10.2.1-6) 10.2.1 20210110") C++ linker for the host machine: c++ ld.bfd 2.35.2 Host machine cpu family: x86_64 Host machine cpu: x86_64 llvm-config found: YES (/usr/bin/llvm-config-13) 13.0.1 Run-time dependency LLVM found: YES 13.0.1 Build targets in project: 0 Found ninja-1.10.1 at /usr/bin/ninja ``` **system parameters** * Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)?: native * what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.): Debian 11 (with llvm-13 and llvm-12 backports) * what Python version are you using e.g. 3.8.0: 3.9.0 * what `meson --version`: 0.62.1
LLVM 14 (if I recall correctly) has a design bug where its cmake config files error out when cmake doesn't have a C compiler in addition to the CXX one. For this reason, Meson was "bugfixed" to warn you if you don't have one and register the cmake method as not-found. This is *supposed* to mean Meson tries other methods, but apparently it crashes before that could happen! This is a bug and must be fixed, but either way you can force a particular method in meson.build by passing `method: 'config-tool'` as a kwarg (you can force pkgconfig or cmake etc. as well, this is most commonly used IME to force specific naming schemes where pkg-config has one name and cmake has a different one). Edit: now I see your edit that you found the `method` kwarg. @mensinda When trying to early abort before invoking `super().__init__(...)` we don't get all that nice setup work done to make the dependency instance be sane, for example `base.Dependency` makes log_tried() work by setting self.type_name, and `cmake.CMakeDependency` makes log_details() work by setting self.found_modules. This fixes it: ```diff diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 97d1633ab..d8f7d40cd 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -412,6 +412,8 @@ class LLVMDependencyCMake(CMakeDependency): compilers = env.coredata.compilers.host if not compilers or not all(x in compilers for x in ('c', 'cpp')): self.is_found = False + self.type_name = 'cmake' + self.found_modules = [] mlog.warning('The LLVM dependency was not found via CMake since both a C and C++ compiler are required.') return ``` But I'm wondering if there is some better way to do it... not sure whether to PR this. Either way I guess the failure case never got tested.
2022-04-28T17:22:07Z
[]
[]
Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/mesonbuild/mesonmain.py", line 153, in run return options.run_func(options) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 301, in run app.generate() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 185, in generate self._generate(env) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/msetup.py", line 229, in _generate intr.run() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/interpreter.py", line 2700, in run super().run() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 149, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 174, in evaluate_codeblock raise e File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_statement self.assignment(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 567, in assignment value = self.evaluate_statement(node.value) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 180, in evaluate_statement return self.function_call(cur) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/interpreterbase.py", line 455, in function_call res = func(node, func_args, kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 768, in wrapped return f(*wrapped_args, **wrapped_kwargs) [Previous line repeated 5 more times] File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 109, in wrapped ret = f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 127, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper return f(*nargs, **wrapped_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/interpreter.py", line 1620, in func_dependency d = df.lookup(kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 352, in lookup dep = func(kwargs, func_args, func_kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/interpreter/dependencyfallbacks.py", line 93, in _do_dependency dep = dependencies.find_external_dependency(name, self.environment, kwargs) File "/usr/local/lib/python3.9/dist-packages/mesonbuild/dependencies/detect.py", line 120, in find_external_dependency details = d.log_details() File "/usr/local/lib/python3.9/dist-packages/mesonbuild/dependencies/cmake.py", line 621, in log_details modules = [self._original_module_name(x) for x in self.found_modules] AttributeError: 'LLVMDependencyCMake' object has no attribute 'found_modules'
8,739
mesonbuild/meson
mesonbuild__meson-10368
04c728a126cc484cda21d21d672630d298cae9b8
diff --git a/mesonbuild/build.py b/mesonbuild/build.py --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1255,7 +1255,7 @@ def process_kwargs(self, kwargs): if self.gnu_symbol_visibility != '': permitted = ['default', 'internal', 'hidden', 'protected', 'inlineshidden'] if self.gnu_symbol_visibility not in permitted: - raise InvalidArguments('GNU symbol visibility arg {} not one of: {}'.format(self.symbol_visibility, ', '.join(permitted))) + raise InvalidArguments('GNU symbol visibility arg {} not one of: {}'.format(self.gnu_symbol_visibility, ', '.join(permitted))) def validate_win_subsystem(self, value: str) -> str: value = value.lower()
"AttributeError: 'SharedLibrary' object has no attribute 'symbol_visibility'" **Describe the bug** Generated automatically. Please see #9646 for a detailed description. A minimal working example can be found below. .. ``` Traceback (most recent call last): File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\mesonmain.py", line 138, in run return options.run_func(options) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 294, in run app.generate() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 185, in generate self._generate(env) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 229, in _generate intr.run() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2484, in run super().run() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 148, in run self.evaluate_codeblock(self.ast, start=1) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 173, in evaluate_codeblock raise e File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 166, in evaluate_codeblock self.evaluate_statement(cur) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 179, in evaluate_statement return self.function_call(cur) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 454, in function_call res = func(node, func_args, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\decorators.py", line 115, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 1566, in func_both_lib return self.build_both_libraries(node, args, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\decorators.py", line 621, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2606, in build_both_libraries shared_lib = self.build_target(node, args, kwargs, build.SharedLibrary) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2686, in build_target target = targetclass(name, self.subdir, self.subproject, for_machine, sources, objs, self.environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 1925, in __init__ super().__init__(name, subdir, subproject, for_machine, sources, objects, environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 707, in __init__ self.process_kwargs(kwargs, environment) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 2105, in process_kwargs super().process_kwargs(kwargs, environment) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 1202, in process_kwargs raise InvalidArguments('GNU symbol visibility arg {} not one of: {}'.format(self.symbol_visibility, ', '.join(permitted))) AttributeError: 'SharedLibrary' object has no attribute 'symbol_visibility' ``` **To Reproduce** ```meson project('generated', ['c', 'java']) obj = include_directories('include') EPEoaYRwaJ = [obj] kvMRlYWxIz = 'UFcnFpXoGA' ZIvwWTpayw = 'foo.c' unYffMSjuQ = true AmAcyZyWjt = 'String' cKwAEEemsH = [ declare_dependency(), declare_dependency() ] EObsEpeyLK = files('foo.c', 'bar.c') JipolBAuXQ = [ 'foo', 'bar' ] CWotWyWtGl = [ files('foo.c')[0], 'bar.c' ] xfCuRcisWU = 'String' LdVtydubMn = [ static_library('IWpYFRiABa', 'foo.c') ] ICUjphCGHI = [ static_library('nuFkcvddhX', 'foo.c') ] oAPZflBlet = true vVMmLeCgvu = true AiSgytUeFE = 'String' BlZmrXFKrn = 'rwxr-xr-x' tboawPWNFU = 'String' PLoyGYqcyk = files('foo.c', 'bar.c') sxDdAvfORS = [ 'key1=value1', 'key2=value2' ] rDMrwSPZzN = 'String' zzgqCGKWMT = true umWJIWarwP = [ 'foo', 'bar' ] WTZgrhJHNY = [ 'foo', 'bar' ] hmFcrgkBPm = true jmpSJLNnVl = 'String' LlTKOzfasW = 'String' RhvPqVTjxY = 'String' both_libraries(kvMRlYWxIz,ZIvwWTpayw,build_by_default : unYffMSjuQ,build_rpath : AmAcyZyWjt,dependencies : cKwAEEemsH,extra_files : EObsEpeyLK,link_args : JipolBAuXQ,link_depends : CWotWyWtGl,link_language : xfCuRcisWU,link_whole : LdVtydubMn,link_with : ICUjphCGHI,implicit_include_directories : oAPZflBlet,include_directories : EPEoaYRwaJ,install : vVMmLeCgvu,install_dir : AiSgytUeFE,install_mode : BlZmrXFKrn,install_rpath : tboawPWNFU,objects : PLoyGYqcyk,override_options : sxDdAvfORS,gnu_symbol_visibility : rDMrwSPZzN,d_import_dirs : EPEoaYRwaJ,d_unittest : zzgqCGKWMT,d_module_versions : umWJIWarwP,d_debug : WTZgrhJHNY,native : hmFcrgkBPm,name_prefix : jmpSJLNnVl,name_suffix : LlTKOzfasW,rust_crate_type : RhvPqVTjxY) TvnKvZHPDw = 'CdMdqCWFKz' KeWbdizJJt = 'foo.c' LrKltPjyhE = true IVGrQTNnjq = 'String' YuOHedzgRl = [ declare_dependency(), declare_dependency() ] ydRwntCizR = files('foo.c', 'bar.c') fTWEWPsqEY = [ 'foo', 'bar' ] mgZvrvlfhH = [ files('foo.c')[0], 'bar.c' ] nHnLNLPCih = 'String' rxCluKBwAw = [ static_library('APPPjzSVRE', 'foo.c') ] HsClDCwRjT = [ static_library('yODlveIvpJ', 'foo.c') ] RGFJyGYLPq = true CiHQNNaZKN = true bluLGIcqBI = 'String' WFWQCgvSHo = 'rwxr-xr-x' iQRwqqTcgl = 'String' cUBDVMWrlX = files('foo.c', 'bar.c') BSFGBpMMXk = [ 'key1=value1', 'key2=value2' ] FFEqGgAJEV = 'String' bRDAiTiwXm = true jvmyoyFMRM = [ 'foo', 'bar' ] dcxLKNUPtF = [ 'foo', 'bar' ] DyNAvHTpxq = true LllsimITKS = 'String' xulyaZAZGE = 'String' NVNoCkUVjv = 'String' both_libraries(TvnKvZHPDw,KeWbdizJJt,build_by_default : LrKltPjyhE,build_rpath : IVGrQTNnjq,dependencies : YuOHedzgRl,extra_files : ydRwntCizR,link_args : fTWEWPsqEY,link_depends : mgZvrvlfhH,link_language : nHnLNLPCih,link_whole : rxCluKBwAw,link_with : HsClDCwRjT,implicit_include_directories : RGFJyGYLPq,include_directories : EPEoaYRwaJ,install : CiHQNNaZKN,install_dir : bluLGIcqBI,install_mode : WFWQCgvSHo,install_rpath : iQRwqqTcgl,objects : cUBDVMWrlX,override_options : BSFGBpMMXk,gnu_symbol_visibility : FFEqGgAJEV,d_import_dirs : EPEoaYRwaJ,d_unittest : bRDAiTiwXm,d_module_versions : jvmyoyFMRM,d_debug : dcxLKNUPtF,native : DyNAvHTpxq,name_prefix : LllsimITKS,name_suffix : xulyaZAZGE,rust_crate_type : NVNoCkUVjv) sWLnIYpgPH = 'EJgIPucEkv' rUnZAYuoRB = [ files('foo.c')[0], 'bar.c' ] JOEDNXrEAy = true ozXqYZWNiz = 'String' RMJrxRqWiv = [ declare_dependency(), declare_dependency() ] KwHIsclGJm = files('foo.c', 'bar.c') NFkoJkEBpG = [ 'foo', 'bar' ] NHQZgKJYzr = [ files('foo.c')[0], 'bar.c' ] OTTeiONInI = 'String' YIPKntzGeT = [ static_library('GljbZWwCaM', 'foo.c') ] PktqkbDrzH = [ static_library('VnvMwMZzGK', 'foo.c') ] quQrawGkec = true irKyFjBnDT = true SfKiRokVAW = 'String' kcEDjRrKTr = 'rwxr-xr-x' nqudKJcBKV = 'String' gzJuLQiJSb = files('foo.c', 'bar.c') UknmKHUHYZ = [ 'key1=value1', 'key2=value2' ] RNgmarmrrW = 'String' HdjAEWWjJN = true rSiaEFBzHW = [ 'foo', 'bar' ] zekFVCLCGC = [ 'foo', 'bar' ] OdSOdivtnv = true VOoXJMmddW = 'String' Lgwsdmtquo = 'String' SXyheVGDOi = 'String' both_libraries(sWLnIYpgPH,rUnZAYuoRB,build_by_default : JOEDNXrEAy,build_rpath : ozXqYZWNiz,dependencies : RMJrxRqWiv,extra_files : KwHIsclGJm,link_args : NFkoJkEBpG,link_depends : NHQZgKJYzr,link_language : OTTeiONInI,link_whole : YIPKntzGeT,link_with : PktqkbDrzH,implicit_include_directories : quQrawGkec,include_directories : EPEoaYRwaJ,install : irKyFjBnDT,install_dir : SfKiRokVAW,install_mode : kcEDjRrKTr,install_rpath : nqudKJcBKV,objects : gzJuLQiJSb,override_options : UknmKHUHYZ,gnu_symbol_visibility : RNgmarmrrW,d_import_dirs : EPEoaYRwaJ,d_unittest : HdjAEWWjJN,d_module_versions : rSiaEFBzHW,d_debug : zekFVCLCGC,native : OdSOdivtnv,name_prefix : VOoXJMmddW,name_suffix : Lgwsdmtquo,rust_crate_type : SXyheVGDOi) hFXGeGMkIs = 'ayuJaUrrPZ' dNHrliBsMD = [ files('foo.c')[0], 'bar.c' ] QZRlgsYMIT = true jXMundYgMq = 'String' RUHgOupqAH = [ declare_dependency(), declare_dependency() ] jsCLuQJXkV = files('foo.c', 'bar.c') rgTlDAjAWa = [ 'foo', 'bar' ] awhSusoOuq = [ files('foo.c')[0], 'bar.c' ] ZYbgOinTlA = 'String' NOnMYhInDX = [ static_library('IhCKBxEdac', 'foo.c') ] fMuDBWTqNH = [ static_library('GjwUWYDrwA', 'foo.c') ] YMQVmxFgbB = true qYoNKrkkwv = true TPglniyQvR = 'String' cPnbnEMWPe = 'rwxr-xr-x' lHNJPjTTaC = 'String' tsxiyFFNca = files('foo.c', 'bar.c') sAZGbnoegJ = [ 'key1=value1', 'key2=value2' ] oMbWCrnvAD = 'String' wxpZRFnKpJ = true gXxPlJAwKq = [ 'foo', 'bar' ] BXYKeIIUsR = [ 'foo', 'bar' ] zHwLOKlTUE = true TlWgscHmKf = 'String' qxUHPrmZJX = 'String' OHuOvpuwDt = 'String' both_libraries(hFXGeGMkIs,dNHrliBsMD,build_by_default : QZRlgsYMIT,build_rpath : jXMundYgMq,dependencies : RUHgOupqAH,extra_files : jsCLuQJXkV,link_args : rgTlDAjAWa,link_depends : awhSusoOuq,link_language : ZYbgOinTlA,link_whole : NOnMYhInDX,link_with : fMuDBWTqNH,implicit_include_directories : YMQVmxFgbB,include_directories : EPEoaYRwaJ,install : qYoNKrkkwv,install_dir : TPglniyQvR,install_mode : cPnbnEMWPe,install_rpath : lHNJPjTTaC,objects : tsxiyFFNca,override_options : sAZGbnoegJ,gnu_symbol_visibility : oMbWCrnvAD,d_import_dirs : EPEoaYRwaJ,d_unittest : wxpZRFnKpJ,d_module_versions : gXxPlJAwKq,d_debug : BXYKeIIUsR,native : zHwLOKlTUE,name_prefix : TlWgscHmKf,name_suffix : qxUHPrmZJX,rust_crate_type : OHuOvpuwDt) error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` **Expected behaviour** No crash. **System parameters** ``` The Meson build system Version: 0.60.1 Build type: native build C compiler for the host machine: gcc (gcc 8.3.0 "gcc (x86_64-posix-seh, Built by strawberryperl.com project) 8.3.0") C linker for the host machine: gcc ld.bfd 2.32 Java compiler for the host machine: javac (unknown 17.0.1) Host machine cpu family: x86_64 Host machine cpu: x86_64 ```
The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) iNxRUToEAI = 'IoVBcurmHj' wpnXfagzCr = [ files('foo.c')[0], 'bar.c' ] OaMKBMZetx = true LlLUDFaGDc = 'String' ndMbFBbIyC = [ declare_dependency(), declare_dependency() ] AkZTAhqlaZ = files('foo.c', 'bar.c') cmixxSpfTl = [ 'foo', 'bar' ] BAIMBRDgbe = [ files('foo.c')[0], 'bar.c' ] bBIAPKvxTc = 'String' CeRCoabjOV = [ static_library('UdHbJdRSHN', 'foo.c') ] PPWPMtmDRA = [ static_library('SElvphBMKY', 'foo.c') ] CyFhhRXUYP = true yEPHanaKuS = [ include_directories('include'), 'include' ] WrcIJrwNRI = true hfnqsrkdBP = 'String' wPjidhxcrn = 'rwxr-xr-x' xZtBxUgvzu = 'String' kCwZOkMQhO = files('foo.c', 'bar.c') DEsUKpFpZP = [ 'key1=value1', 'key2=value2' ] tmpIvIhjpE = 'String' PnYCSzxhcQ = include_directories('include') gZsOmbRCVm = true yYQYLDrZiR = [ 'foo', 'bar' ] NKWQnedAMP = [ 'foo', 'bar' ] ICoRxtjPNR = true LYMLMxsHiK = 'String' SMnqvHBnMe = 'String' lukimGfRLK = 'String' dlZZRmbBJq = both_libraries(iNxRUToEAI,wpnXfagzCr,build_by_default : OaMKBMZetx,build_rpath : LlLUDFaGDc,dependencies : ndMbFBbIyC,extra_files : AkZTAhqlaZ,link_args : cmixxSpfTl,link_depends : BAIMBRDgbe,link_language : bBIAPKvxTc,link_whole : CeRCoabjOV,link_with : PPWPMtmDRA,implicit_include_directories : CyFhhRXUYP,include_directories : yEPHanaKuS,install : WrcIJrwNRI,install_dir : hfnqsrkdBP,install_mode : wPjidhxcrn,install_rpath : xZtBxUgvzu,objects : kCwZOkMQhO,override_options : DEsUKpFpZP,gnu_symbol_visibility : tmpIvIhjpE,d_import_dirs : PnYCSzxhcQ,d_unittest : gZsOmbRCVm,d_module_versions : yYQYLDrZiR,d_debug : NKWQnedAMP,native : ICoRxtjPNR,name_prefix : LYMLMxsHiK,name_suffix : SMnqvHBnMe,rust_crate_type : lukimGfRLK) ogSqOuMsLc = true dlZZRmbBJq.extract_all_objects(recursive : ogSqOuMsLc) qFkxajBQZF = [] dlZZRmbBJq.extract_objects(qFkxajBQZF) tFATbFddFM = [] dlZZRmbBJq.extract_objects(tFATbFddFM) dlZZRmbBJq.found() dlZZRmbBJq.full_path() dlZZRmbBJq.get_shared_lib() dlZZRmbBJq.get_static_lib() dlZZRmbBJq.name() dlZZRmbBJq.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) obj = files('foo.c')[0] QAqzGsURVv = [obj] zfyEVRMHXV = 'SmBJhhisBz' qMBJkmkHQS = 'foo.c' xKLprRwLEK = true qbgAiXUxvE = 'String' HFlelHBdud = [ declare_dependency(), declare_dependency() ] nJXxYRgVyu = [ 'foo', 'bar' ] yebYHWNVPf = 'String' WeeFxOMmcT = [ static_library('IUvYSnCGEG', 'foo.c') ] FtMboFPrVU = [ static_library('mIXHgudoKR', 'foo.c') ] elUZZYqAYC = true wYGGcXLfFL = [ include_directories('include'), 'include' ] djgBJFLFqd = true DtecXXVXhh = 'String' cPKkorMHIp = 'rwxr-xr-x' OlXWyhNpWf = 'String' EoMXyDLwWm = [ 'key1=value1', 'key2=value2' ] xRIxTbRWPM = 'String' ujSmRlAgiJ = include_directories('include') XFddOBKwHS = true aaWspTKmDp = [ 'foo', 'bar' ] HFtArUmPGj = [ 'foo', 'bar' ] yNKUsVJEdb = true taEmYKLEGV = 'String' CveeaIzyqP = 'String' FZNdXZQugF = 'String' both_libraries(zfyEVRMHXV,qMBJkmkHQS,build_by_default : xKLprRwLEK,build_rpath : qbgAiXUxvE,dependencies : HFlelHBdud,extra_files : QAqzGsURVv,link_args : nJXxYRgVyu,link_depends : QAqzGsURVv,link_language : yebYHWNVPf,link_whole : WeeFxOMmcT,link_with : FtMboFPrVU,implicit_include_directories : elUZZYqAYC,include_directories : wYGGcXLfFL,install : djgBJFLFqd,install_dir : DtecXXVXhh,install_mode : cPKkorMHIp,install_rpath : OlXWyhNpWf,objects : QAqzGsURVv,override_options : EoMXyDLwWm,gnu_symbol_visibility : xRIxTbRWPM,d_import_dirs : ujSmRlAgiJ,d_unittest : XFddOBKwHS,d_module_versions : aaWspTKmDp,d_debug : HFtArUmPGj,native : yNKUsVJEdb,name_prefix : taEmYKLEGV,name_suffix : CveeaIzyqP,rust_crate_type : FZNdXZQugF) LnAWssPUvv = 'oyhVoQGjgo' MpraZxoOJz = 'foo.c' tyxYHCGtnX = true ZLdItZkYQT = 'String' KhlBzJJRRQ = [ declare_dependency(), declare_dependency() ] yOKvvhiSKh = [ 'foo', 'bar' ] NWvJFppSZf = 'String' hNlqYBQoOF = [ static_library('hByuDLHZUA', 'foo.c') ] KXyVItbVrc = [ static_library('rcUMRSQbQz', 'foo.c') ] rgXtsFYGui = true DeSGsfPcsE = [ include_directories('include'), 'include' ] ATiHDZRrMx = true xEiaPsPbyF = 'String' gJmBOsXmfs = 'rwxr-xr-x' ofRysmVrJR = 'String' KrFrlsNGte = [ 'key1=value1', 'key2=value2' ] PNwHNSzWGd = 'String' WwwwVrNmJA = [ include_directories('include'), 'include' ] mCfrIfVmrh = true CgrFbHUMif = [ 'foo', 'bar' ] vwhFiZAXRi = [ 'foo', 'bar' ] OwBgpKPwPu = true ZcPvHILeVm = 'String' qRdeWraZGU = 'String' xVFwLtThdp = 'String' both_libraries(LnAWssPUvv,MpraZxoOJz,build_by_default : tyxYHCGtnX,build_rpath : ZLdItZkYQT,dependencies : KhlBzJJRRQ,extra_files : QAqzGsURVv,link_args : yOKvvhiSKh,link_depends : QAqzGsURVv,link_language : NWvJFppSZf,link_whole : hNlqYBQoOF,link_with : KXyVItbVrc,implicit_include_directories : rgXtsFYGui,include_directories : DeSGsfPcsE,install : ATiHDZRrMx,install_dir : xEiaPsPbyF,install_mode : gJmBOsXmfs,install_rpath : ofRysmVrJR,objects : QAqzGsURVv,override_options : KrFrlsNGte,gnu_symbol_visibility : PNwHNSzWGd,d_import_dirs : WwwwVrNmJA,d_unittest : mCfrIfVmrh,d_module_versions : CgrFbHUMif,d_debug : vwhFiZAXRi,native : OwBgpKPwPu,name_prefix : ZcPvHILeVm,name_suffix : qRdeWraZGU,rust_crate_type : xVFwLtThdp) eLluySWulF = 'lFHrGjyzcz' ksLZaKyUgJ = true LoDJJkbxGV = 'String' dZPdapBMVj = [ declare_dependency(), declare_dependency() ] FAyKkmyTBU = [ 'foo', 'bar' ] jmzWPJrBye = 'String' JzBZzwWQut = [ static_library('SqaIdWrJev', 'foo.c') ] heYTuCvrsM = [ static_library('LAslfHDmos', 'foo.c') ] LCAkhqCZko = true WROjYHTjXQ = [ include_directories('include'), 'include' ] hSvjVIQlRi = true AJbhxCvrBV = 'String' wOqaDYvEhg = 'rwxr-xr-x' cFtrzVFTIS = 'String' KzJVnREDtJ = [ 'key1=value1', 'key2=value2' ] kMcNtjyYys = 'String' zjnbzJhQdX = include_directories('include') stNDNcIMDn = true yidHwkyoih = [ 'foo', 'bar' ] QoRNskpTGk = [ 'foo', 'bar' ] XolzzpuyEv = true RlaIDHnFVh = 'String' fKGvFfmNok = 'String' COfBlFdmMB = 'String' both_libraries(eLluySWulF,QAqzGsURVv,build_by_default : ksLZaKyUgJ,build_rpath : LoDJJkbxGV,dependencies : dZPdapBMVj,extra_files : QAqzGsURVv,link_args : FAyKkmyTBU,link_depends : QAqzGsURVv,link_language : jmzWPJrBye,link_whole : JzBZzwWQut,link_with : heYTuCvrsM,implicit_include_directories : LCAkhqCZko,include_directories : WROjYHTjXQ,install : hSvjVIQlRi,install_dir : AJbhxCvrBV,install_mode : wOqaDYvEhg,install_rpath : cFtrzVFTIS,objects : QAqzGsURVv,override_options : KzJVnREDtJ,gnu_symbol_visibility : kMcNtjyYys,d_import_dirs : zjnbzJhQdX,d_unittest : stNDNcIMDn,d_module_versions : yidHwkyoih,d_debug : QoRNskpTGk,native : XolzzpuyEv,name_prefix : RlaIDHnFVh,name_suffix : fKGvFfmNok,rust_crate_type : COfBlFdmMB) LgnCWJlbnJ = 'qqzihUTKTP' kFMLZznGVR = true xrIUBgdTrY = 'String' FooKgpPAtu = [ declare_dependency(), declare_dependency() ] yQRsjaJsqS = [ 'foo', 'bar' ] MpKuEPaqQt = 'String' LmJXJHgjCI = [ static_library('sUuEmksKkt', 'foo.c') ] GfqFxzYrnL = [ static_library('TuZoRKVqru', 'foo.c') ] HpZGnNqNKb = true uRedsFzyIf = [ include_directories('include'), 'include' ] rabaCoIlmS = true fUYHVfZxzN = 'String' zAkCeXHmUq = 'rwxr-xr-x' GJBYdlDBxU = 'String' MukOTvKPDZ = [ 'key1=value1', 'key2=value2' ] hxroCopIUT = 'String' owjswNrJix = [ include_directories('include'), 'include' ] NZSFcYiEwQ = true MKXJiOILwV = [ 'foo', 'bar' ] MdExRmPvuj = [ 'foo', 'bar' ] NEeFpkyhIM = true hkKygijqYQ = 'String' JNBGmostAP = 'String' CuXxcLWmxV = 'String' both_libraries(LgnCWJlbnJ,QAqzGsURVv,build_by_default : kFMLZznGVR,build_rpath : xrIUBgdTrY,dependencies : FooKgpPAtu,extra_files : QAqzGsURVv,link_args : yQRsjaJsqS,link_depends : QAqzGsURVv,link_language : MpKuEPaqQt,link_whole : LmJXJHgjCI,link_with : GfqFxzYrnL,implicit_include_directories : HpZGnNqNKb,include_directories : uRedsFzyIf,install : rabaCoIlmS,install_dir : fUYHVfZxzN,install_mode : zAkCeXHmUq,install_rpath : GJBYdlDBxU,objects : QAqzGsURVv,override_options : MukOTvKPDZ,gnu_symbol_visibility : hxroCopIUT,d_import_dirs : owjswNrJix,d_unittest : NZSFcYiEwQ,d_module_versions : MKXJiOILwV,d_debug : MdExRmPvuj,native : NEeFpkyhIM,name_prefix : hkKygijqYQ,name_suffix : JNBGmostAP,rust_crate_type : CuXxcLWmxV) error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) kdcLKnYZrr = 'YVLoqqPRFa' PPziDCAvmk = 'foo.c' TLWXHWqTBL = true FDDDuijgJl = 'String' nBfPBbNdLO = [ declare_dependency(), declare_dependency() ] JuXoqGDgyp = files('foo.c', 'bar.c') fjfgiZhlyf = [ 'foo', 'bar' ] SMAzpReCVj = [ files('foo.c')[0], 'bar.c' ] OmcMsgdNwN = 'String' mltvQwjBdC = [ static_library('kUNrugpVaG', 'foo.c') ] uJxyJwqiOE = [ static_library('rwOOOhVkKc', 'foo.c') ] EkEISktxkb = true yxxWTBPPDs = [ include_directories('include'), 'include' ] eQHjeoplhq = true jJhMAdeDkI = 'String' YSzvTekxSc = 'rwxr-xr-x' BJXsslucdF = 'String' JsyPjewFwJ = files('foo.c', 'bar.c') BWwvkGBkQl = [ 'key1=value1', 'key2=value2' ] iAFbZunjep = 'String' SsJGQFAzzh = include_directories('include') BmhNXDKKtE = true rMPpRDTMEb = [ 'foo', 'bar' ] jRWYKLHFxy = [ 'foo', 'bar' ] WrMbOoXAVm = true VUaGHzUCMZ = 'String' BSbMzUJNws = 'String' KeuvjPmVrn = 'String' OZBNydYeiy = both_libraries(kdcLKnYZrr,PPziDCAvmk,build_by_default : TLWXHWqTBL,build_rpath : FDDDuijgJl,dependencies : nBfPBbNdLO,extra_files : JuXoqGDgyp,link_args : fjfgiZhlyf,link_depends : SMAzpReCVj,link_language : OmcMsgdNwN,link_whole : mltvQwjBdC,link_with : uJxyJwqiOE,implicit_include_directories : EkEISktxkb,include_directories : yxxWTBPPDs,install : eQHjeoplhq,install_dir : jJhMAdeDkI,install_mode : YSzvTekxSc,install_rpath : BJXsslucdF,objects : JsyPjewFwJ,override_options : BWwvkGBkQl,gnu_symbol_visibility : iAFbZunjep,d_import_dirs : SsJGQFAzzh,d_unittest : BmhNXDKKtE,d_module_versions : rMPpRDTMEb,d_debug : jRWYKLHFxy,native : WrMbOoXAVm,name_prefix : VUaGHzUCMZ,name_suffix : BSbMzUJNws,rust_crate_type : KeuvjPmVrn) fqJriwtEIm = true OZBNydYeiy.extract_all_objects(recursive : fqJriwtEIm) bePfljChmT = [] OZBNydYeiy.extract_objects(bePfljChmT) MmRDEMRdia = [] OZBNydYeiy.extract_objects(MmRDEMRdia) OZBNydYeiy.found() OZBNydYeiy.full_path() OZBNydYeiy.get_shared_lib() OZBNydYeiy.get_static_lib() OZBNydYeiy.name() OZBNydYeiy.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) obj = declare_dependency() bSfgqOIvsh = [obj] XMkJXsSgoq = 'hmzHYHruBb' shMMgFOetL = 'foo.c' wxwunZmCLq = true sVLzDkkMne = 'String' GyIHmZMWCD = files('foo.c', 'bar.c') qqDltzyWXj = [ 'foo', 'bar' ] KKEtDxhrrH = [ files('foo.c')[0], 'bar.c' ] LmyDqQOrFq = 'String' bYjsjuOAwS = [ static_library('qVIwaIJBkB', 'foo.c') ] ijaXCDxhPr = [ static_library('njDFcjtyQX', 'foo.c') ] NdIxBuNlOA = true vgrQrWZEnn = [ include_directories('include'), 'include' ] VoAdcCloCz = true jfPKOhlaUK = 'String' QMMjbnRyBe = 'rwxr-xr-x' wSwSoFVSmO = 'String' RQXBGbKgnG = files('foo.c', 'bar.c') xoUNOpAqoA = [ 'key1=value1', 'key2=value2' ] qbtBFHpaOc = 'String' gKfRUaMceR = include_directories('include') rgvNyePyRM = true mPtNpqxrar = [ 'foo', 'bar' ] oRjKFRweHb = [ 'foo', 'bar' ] awLImVcrbx = true JaguXAzsgI = 'String' CNtEHcWcay = 'String' MQcfDKQOxI = 'String' both_libraries(XMkJXsSgoq,shMMgFOetL,build_by_default : wxwunZmCLq,build_rpath : sVLzDkkMne,dependencies : bSfgqOIvsh,extra_files : GyIHmZMWCD,link_args : qqDltzyWXj,link_depends : KKEtDxhrrH,link_language : LmyDqQOrFq,link_whole : bYjsjuOAwS,link_with : ijaXCDxhPr,implicit_include_directories : NdIxBuNlOA,include_directories : vgrQrWZEnn,install : VoAdcCloCz,install_dir : jfPKOhlaUK,install_mode : QMMjbnRyBe,install_rpath : wSwSoFVSmO,objects : RQXBGbKgnG,override_options : xoUNOpAqoA,gnu_symbol_visibility : qbtBFHpaOc,d_import_dirs : gKfRUaMceR,d_unittest : rgvNyePyRM,d_module_versions : mPtNpqxrar,d_debug : oRjKFRweHb,native : awLImVcrbx,name_prefix : JaguXAzsgI,name_suffix : CNtEHcWcay,rust_crate_type : MQcfDKQOxI) SrTkUqCCIL = 'uJgWzSlabj' dpckwvbMaC = 'foo.c' DTbrRGDbXT = true rqgxRNIztk = 'String' kQeWPWzmvu = files('foo.c', 'bar.c') enNpPXQfLN = [ 'foo', 'bar' ] SRiKyctzzL = [ files('foo.c')[0], 'bar.c' ] sNJeDJibOJ = 'String' FzgeZjMPWa = [ static_library('JKHKEcVgyp', 'foo.c') ] hiOKxzcOhD = [ static_library('limUSsYBIU', 'foo.c') ] TkgZiAvSnB = true dHhmGhJLYa = [ include_directories('include'), 'include' ] LFzEIZzgMC = true UBqFHdSdnK = 'String' CDoVrYKTVt = 'rwxr-xr-x' CacTQOwbNs = 'String' QOysdcRaFV = files('foo.c', 'bar.c') QdSwtZkmlP = [ 'key1=value1', 'key2=value2' ] HVUPsaqrPD = 'String' cikgmiTnTB = [ include_directories('include'), 'include' ] vAAfUTSEQf = true PPatSMxmeO = [ 'foo', 'bar' ] QTufYOQrhX = [ 'foo', 'bar' ] rdZunFcjYH = true bADKzCvKme = 'String' vaUMDJTTsr = 'String' LIRaGmwyho = 'String' both_libraries(SrTkUqCCIL,dpckwvbMaC,build_by_default : DTbrRGDbXT,build_rpath : rqgxRNIztk,dependencies : bSfgqOIvsh,extra_files : kQeWPWzmvu,link_args : enNpPXQfLN,link_depends : SRiKyctzzL,link_language : sNJeDJibOJ,link_whole : FzgeZjMPWa,link_with : hiOKxzcOhD,implicit_include_directories : TkgZiAvSnB,include_directories : dHhmGhJLYa,install : LFzEIZzgMC,install_dir : UBqFHdSdnK,install_mode : CDoVrYKTVt,install_rpath : CacTQOwbNs,objects : QOysdcRaFV,override_options : QdSwtZkmlP,gnu_symbol_visibility : HVUPsaqrPD,d_import_dirs : cikgmiTnTB,d_unittest : vAAfUTSEQf,d_module_versions : PPatSMxmeO,d_debug : QTufYOQrhX,native : rdZunFcjYH,name_prefix : bADKzCvKme,name_suffix : vaUMDJTTsr,rust_crate_type : LIRaGmwyho) dqFAIUghWf = 'gbgzNxzXcQ' fLjyoxkMCr = [ files('foo.c')[0], 'bar.c' ] dYlqsmEPxh = true TSgFmMvSuz = 'String' rQAEivcUie = files('foo.c', 'bar.c') OgbtgPqicQ = [ 'foo', 'bar' ] BfWDhozvSK = [ files('foo.c')[0], 'bar.c' ] pTRiUKSveh = 'String' WWXVnZtszD = [ static_library('aAQsEaOOCj', 'foo.c') ] HAnEckWnit = [ static_library('JaPfNZMGdH', 'foo.c') ] AlBBMnIZVj = true wfsOsrhxkC = [ include_directories('include'), 'include' ] DtlGPnAWJI = true ZdGOkNgzbw = 'String' psfefLGUaX = 'rwxr-xr-x' GblJKbziOO = 'String' RXDfQvFXeQ = files('foo.c', 'bar.c') xUSznRMnwl = [ 'key1=value1', 'key2=value2' ] YFKvdPOgoH = 'String' GCtLJdXJoF = include_directories('include') tYRfQHXLRH = true gScLmwbrsa = [ 'foo', 'bar' ] HMhxaWwfwv = [ 'foo', 'bar' ] uMwMxkpCRw = true jfIFdnNYpl = 'String' OLAAzyeJdr = 'String' XbLlUqyyah = 'String' both_libraries(dqFAIUghWf,fLjyoxkMCr,build_by_default : dYlqsmEPxh,build_rpath : TSgFmMvSuz,dependencies : bSfgqOIvsh,extra_files : rQAEivcUie,link_args : OgbtgPqicQ,link_depends : BfWDhozvSK,link_language : pTRiUKSveh,link_whole : WWXVnZtszD,link_with : HAnEckWnit,implicit_include_directories : AlBBMnIZVj,include_directories : wfsOsrhxkC,install : DtlGPnAWJI,install_dir : ZdGOkNgzbw,install_mode : psfefLGUaX,install_rpath : GblJKbziOO,objects : RXDfQvFXeQ,override_options : xUSznRMnwl,gnu_symbol_visibility : YFKvdPOgoH,d_import_dirs : GCtLJdXJoF,d_unittest : tYRfQHXLRH,d_module_versions : gScLmwbrsa,d_debug : HMhxaWwfwv,native : uMwMxkpCRw,name_prefix : jfIFdnNYpl,name_suffix : OLAAzyeJdr,rust_crate_type : XbLlUqyyah) OLRgXnEGfO = 'kBpWQQiEhM' NaJPlCAxbx = [ files('foo.c')[0], 'bar.c' ] mgULmQwMhv = true JNsGgHSqyp = 'String' UlnpALZXic = files('foo.c', 'bar.c') SPmKVnhtXV = [ 'foo', 'bar' ] LNmdETVuHn = [ files('foo.c')[0], 'bar.c' ] BJTyyHljvl = 'String' xUcBbCogwD = [ static_library('zQbtCXOVpG', 'foo.c') ] jmtaHIKKHP = [ static_library('dLFRwROedK', 'foo.c') ] MaVsjqBSEw = true VSkpPhnaWX = [ include_directories('include'), 'include' ] qJprTNcWCM = true uFvehdMFtM = 'String' SQfSRvDsny = 'rwxr-xr-x' fQCruYBWqD = 'String' hLZWmvFvQv = files('foo.c', 'bar.c') oFbwRzWMOS = [ 'key1=value1', 'key2=value2' ] FwgftiyBRZ = 'String' ggLwqurJEc = [ include_directories('include'), 'include' ] wqlJupTJdg = true LEWXEpIrKR = [ 'foo', 'bar' ] ZsSyRGUzHt = [ 'foo', 'bar' ] dRztkOqsTg = true YGdcRquSio = 'String' ywHbrswPUT = 'String' ZgdZiVEHBF = 'String' both_libraries(OLRgXnEGfO,NaJPlCAxbx,build_by_default : mgULmQwMhv,build_rpath : JNsGgHSqyp,dependencies : bSfgqOIvsh,extra_files : UlnpALZXic,link_args : SPmKVnhtXV,link_depends : LNmdETVuHn,link_language : BJTyyHljvl,link_whole : xUcBbCogwD,link_with : jmtaHIKKHP,implicit_include_directories : MaVsjqBSEw,include_directories : VSkpPhnaWX,install : qJprTNcWCM,install_dir : uFvehdMFtM,install_mode : SQfSRvDsny,install_rpath : fQCruYBWqD,objects : hLZWmvFvQv,override_options : oFbwRzWMOS,gnu_symbol_visibility : FwgftiyBRZ,d_import_dirs : ggLwqurJEc,d_unittest : wqlJupTJdg,d_module_versions : LEWXEpIrKR,d_debug : ZsSyRGUzHt,native : dRztkOqsTg,name_prefix : YGdcRquSio,name_suffix : ywHbrswPUT,rust_crate_type : ZgdZiVEHBF) error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) obj = files('foo.c')[0] PsdavrlKgy = [obj] JzuJIzYaxy = 'QlOcqFtnXd' ZBlnbtRNeh = 'foo.c' rcMvEzeeih = true aYlTOurlTE = 'String' lMKXlxWiYY = [ declare_dependency(), declare_dependency() ] ulbxzlUzna = [ 'foo', 'bar' ] dwpyaFrREM = 'String' zWQjQaclrw = [ static_library('VTkSYVWdwD', 'foo.c') ] UIxPcHSLSS = [ static_library('jsRuIedPsr', 'foo.c') ] JwDRGoNYLg = true LXGGyoMXjQ = [ include_directories('include'), 'include' ] yLbjTmrZQd = true HXseVclTWr = 'String' bnnglCsfDE = 'rwxr-xr-x' WgZEnDQdHG = 'String' gnESCNbPWq = [ 'key1=value1', 'key2=value2' ] RGUvcDGXng = 'String' ysILqzOdcb = include_directories('include') hGDChVRsJL = true gUJJDzuZph = [ 'foo', 'bar' ] bzqIIXvhRI = [ 'foo', 'bar' ] ZXdQYqnGkZ = true nvCCHFYknR = 'String' PIWREzyxDp = 'String' rzPXkkLHNq = 'String' both_libraries(JzuJIzYaxy,ZBlnbtRNeh,build_by_default : rcMvEzeeih,build_rpath : aYlTOurlTE,dependencies : lMKXlxWiYY,extra_files : PsdavrlKgy,link_args : ulbxzlUzna,link_depends : PsdavrlKgy,link_language : dwpyaFrREM,link_whole : zWQjQaclrw,link_with : UIxPcHSLSS,implicit_include_directories : JwDRGoNYLg,include_directories : LXGGyoMXjQ,install : yLbjTmrZQd,install_dir : HXseVclTWr,install_mode : bnnglCsfDE,install_rpath : WgZEnDQdHG,objects : PsdavrlKgy,override_options : gnESCNbPWq,gnu_symbol_visibility : RGUvcDGXng,d_import_dirs : ysILqzOdcb,d_unittest : hGDChVRsJL,d_module_versions : gUJJDzuZph,d_debug : bzqIIXvhRI,native : ZXdQYqnGkZ,name_prefix : nvCCHFYknR,name_suffix : PIWREzyxDp,rust_crate_type : rzPXkkLHNq) GzOjYmxGaE = 'WxdvhgNyBh' SaeWiSgTAZ = 'foo.c' NsPIBGNEhn = true kCGakbhwmu = 'String' AVPvsXNCKu = [ declare_dependency(), declare_dependency() ] wSVHDHydyY = [ 'foo', 'bar' ] kkkTfRQsSC = 'String' jefTzIVVAL = [ static_library('GeKkPAkVWt', 'foo.c') ] kMgJdaXEpG = [ static_library('vXyotXIRvT', 'foo.c') ] YHFsigFzWE = true lPJQkrdrXa = [ include_directories('include'), 'include' ] XYLdnmYzWl = true SdFIHWMMVU = 'String' xVujBpNbtT = 'rwxr-xr-x' thphWUgxue = 'String' qkqdmZLHEx = [ 'key1=value1', 'key2=value2' ] XLpvnljDhG = 'String' zZTWtGcKlU = [ include_directories('include'), 'include' ] HGLfIEEQGc = true SrWbdlBASx = [ 'foo', 'bar' ] YqhyeqWQky = [ 'foo', 'bar' ] dQfwpLtIoc = true OalKjgWqCo = 'String' nyZcxdRsik = 'String' UAyWoQzIAE = 'String' both_libraries(GzOjYmxGaE,SaeWiSgTAZ,build_by_default : NsPIBGNEhn,build_rpath : kCGakbhwmu,dependencies : AVPvsXNCKu,extra_files : PsdavrlKgy,link_args : wSVHDHydyY,link_depends : PsdavrlKgy,link_language : kkkTfRQsSC,link_whole : jefTzIVVAL,link_with : kMgJdaXEpG,implicit_include_directories : YHFsigFzWE,include_directories : lPJQkrdrXa,install : XYLdnmYzWl,install_dir : SdFIHWMMVU,install_mode : xVujBpNbtT,install_rpath : thphWUgxue,objects : PsdavrlKgy,override_options : qkqdmZLHEx,gnu_symbol_visibility : XLpvnljDhG,d_import_dirs : zZTWtGcKlU,d_unittest : HGLfIEEQGc,d_module_versions : SrWbdlBASx,d_debug : YqhyeqWQky,native : dQfwpLtIoc,name_prefix : OalKjgWqCo,name_suffix : nyZcxdRsik,rust_crate_type : UAyWoQzIAE) kMdeOSYRrH = 'sooihqrPKV' AvGoWKBFhm = true fxDuRupCyg = 'String' suUELnBHuj = [ declare_dependency(), declare_dependency() ] EwqpzpRsmd = [ 'foo', 'bar' ] mEmtqrrAOG = 'String' moqjCXomDv = [ static_library('vbtTMeJlaU', 'foo.c') ] drRreqQSKh = [ static_library('BlCCGErJPM', 'foo.c') ] CVxtWkADRw = true FcCwwZRein = [ include_directories('include'), 'include' ] ZgpbDlZvZh = true yZPwHWohWM = 'String' DKZvbrVzMp = 'rwxr-xr-x' HlmdzCGMgk = 'String' olFFgEgnhl = [ 'key1=value1', 'key2=value2' ] NXAuDSJOJM = 'String' qhdbxvDOUq = include_directories('include') iPDRbpRPmK = true XytgcVTFqn = [ 'foo', 'bar' ] ijhYRjgxvD = [ 'foo', 'bar' ] gmOowtfPdR = true HlbwbTYWZi = 'String' eQaUYqMHNR = 'String' ysYhqOlwkS = 'String' both_libraries(kMdeOSYRrH,PsdavrlKgy,build_by_default : AvGoWKBFhm,build_rpath : fxDuRupCyg,dependencies : suUELnBHuj,extra_files : PsdavrlKgy,link_args : EwqpzpRsmd,link_depends : PsdavrlKgy,link_language : mEmtqrrAOG,link_whole : moqjCXomDv,link_with : drRreqQSKh,implicit_include_directories : CVxtWkADRw,include_directories : FcCwwZRein,install : ZgpbDlZvZh,install_dir : yZPwHWohWM,install_mode : DKZvbrVzMp,install_rpath : HlmdzCGMgk,objects : PsdavrlKgy,override_options : olFFgEgnhl,gnu_symbol_visibility : NXAuDSJOJM,d_import_dirs : qhdbxvDOUq,d_unittest : iPDRbpRPmK,d_module_versions : XytgcVTFqn,d_debug : ijhYRjgxvD,native : gmOowtfPdR,name_prefix : HlbwbTYWZi,name_suffix : eQaUYqMHNR,rust_crate_type : ysYhqOlwkS) yjnTkarMun = 'ndAZUlpeVi' vCUCEVMoYZ = true bPwieYKjkW = 'String' NDDBMignnt = [ declare_dependency(), declare_dependency() ] FuQybevTIE = [ 'foo', 'bar' ] euSmWMdrax = 'String' DraClNBGlx = [ static_library('AACsxeSlwA', 'foo.c') ] HprrtUaQeV = [ static_library('NhdeIpTCtJ', 'foo.c') ] YFcRjsEzVB = true LYOaUgGOzk = [ include_directories('include'), 'include' ] rCNrFIYGuU = true YOXeVbvjSW = 'String' ZdxzMLRctl = 'rwxr-xr-x' ANftxBLnrb = 'String' hetcAhfhGi = [ 'key1=value1', 'key2=value2' ] CIXOztpvmv = 'String' SrIdPmUwtX = [ include_directories('include'), 'include' ] njiAOXSKFp = true ZeaPynzrwv = [ 'foo', 'bar' ] gByapPqNKV = [ 'foo', 'bar' ] QMNYLTqypJ = true xEklwFrMRG = 'String' DGSqmfPBUF = 'String' aVssRcvCCt = 'String' both_libraries(yjnTkarMun,PsdavrlKgy,build_by_default : vCUCEVMoYZ,build_rpath : bPwieYKjkW,dependencies : NDDBMignnt,extra_files : PsdavrlKgy,link_args : FuQybevTIE,link_depends : PsdavrlKgy,link_language : euSmWMdrax,link_whole : DraClNBGlx,link_with : HprrtUaQeV,implicit_include_directories : YFcRjsEzVB,include_directories : LYOaUgGOzk,install : rCNrFIYGuU,install_dir : YOXeVbvjSW,install_mode : ZdxzMLRctl,install_rpath : ANftxBLnrb,objects : PsdavrlKgy,override_options : hetcAhfhGi,gnu_symbol_visibility : CIXOztpvmv,d_import_dirs : SrIdPmUwtX,d_unittest : njiAOXSKFp,d_module_versions : ZeaPynzrwv,d_debug : gByapPqNKV,native : QMNYLTqypJ,name_prefix : xEklwFrMRG,name_suffix : DGSqmfPBUF,rust_crate_type : aVssRcvCCt) error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ```
2022-05-08T17:29:54Z
[]
[]
Traceback (most recent call last): File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\mesonmain.py", line 138, in run return options.run_func(options) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 294, in run app.generate() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 185, in generate self._generate(env) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 229, in _generate intr.run() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2484, in run super().run() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 148, in run self.evaluate_codeblock(self.ast, start=1) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 173, in evaluate_codeblock raise e File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 166, in evaluate_codeblock self.evaluate_statement(cur) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 179, in evaluate_statement return self.function_call(cur) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 454, in function_call res = func(node, func_args, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\decorators.py", line 115, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 1566, in func_both_lib return self.build_both_libraries(node, args, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\decorators.py", line 621, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2606, in build_both_libraries shared_lib = self.build_target(node, args, kwargs, build.SharedLibrary) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2686, in build_target target = targetclass(name, self.subdir, self.subproject, for_machine, sources, objs, self.environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 1925, in __init__ super().__init__(name, subdir, subproject, for_machine, sources, objects, environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 707, in __init__ self.process_kwargs(kwargs, environment) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 2105, in process_kwargs super().process_kwargs(kwargs, environment) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 1202, in process_kwargs raise InvalidArguments('GNU symbol visibility arg {} not one of: {}'.format(self.symbol_visibility, ', '.join(permitted))) AttributeError: 'SharedLibrary' object has no attribute 'symbol_visibility'
8,742
mesonbuild/meson
mesonbuild__meson-1039
b2a39dd06ee139152d5522c961e6ba04acdec791
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -1844,7 +1844,11 @@ def get_options(self): } def get_option_link_args(self, options): - return options['c_winlibs'].value[:] + # FIXME: See GnuCCompiler.get_option_link_args + if 'c_winlibs' in options: + return options['c_winlibs'].value[:] + else: + return msvc_winlibs[:] def unix_link_flags_to_native(self, args): result = [] @@ -1949,7 +1953,11 @@ def get_option_compile_args(self, options): return args def get_option_link_args(self, options): - return options['cpp_winlibs'].value[:] + # FIXME: See GnuCCompiler.get_option_link_args + if 'cpp_winlibs' in options: + return options['cpp_winlibs'].value[:] + else: + return msvc_winlibs[:] GCC_STANDARD = 0 GCC_OSX = 1 @@ -2061,7 +2069,17 @@ def get_option_compile_args(self, options): def get_option_link_args(self, options): if self.gcc_type == GCC_MINGW: - return options['c_winlibs'].value + # FIXME: This check is needed because we currently pass + # cross-compiler options to the native compiler too and when + # cross-compiling from Windows to Linux, `options` will contain + # Linux-specific options which doesn't include `c_winlibs`. The + # proper fix is to allow cross-info files to specify compiler + # options and to maintain both cross and native compiler options in + # coredata: https://github.com/mesonbuild/meson/issues/1029 + if 'c_winlibs' in options: + return options['c_winlibs'].value[:] + else: + return gnu_winlibs[:] return [] class GnuCPPCompiler(GnuCompiler, CPPCompiler): @@ -2083,7 +2101,7 @@ def get_options(self): False)} if self.gcc_type == GCC_MINGW: opts.update({ - 'cpp_winlibs': coredata.UserStringArrayOption('c_winlibs', 'Standard Win libraries to link against', + 'cpp_winlibs': coredata.UserStringArrayOption('cpp_winlibs', 'Standard Win libraries to link against', gnu_winlibs), }) return opts @@ -2099,7 +2117,11 @@ def get_option_compile_args(self, options): def get_option_link_args(self, options): if self.gcc_type == GCC_MINGW: - return options['cpp_winlibs'].value + # FIXME: See GnuCCompiler.get_option_link_args + if 'cpp_winlibs' in options: + return options['cpp_winlibs'].value[:] + else: + return gnu_winlibs[:] return [] def get_compiler_check_args(self):
cross-compile from windows to linux Crashes on `cpp_winlibs`: ``` The Meson build system Version: 0.35.1 Source dir: F:\avian\test Build dir: F:\avian\test\build\linux-64 Build type: cross build Project name: avian 18:22Native cpp compiler: c++ (gcc 4.8.1) Cross cpp compiler: f:/cygwin64/bin/x86_64-pc-linux-gnu-g++ (gcc 4.8.2) Native c compiler: gcc (gcc 4.8.1) Cross c compiler: f:/cygwin64/bin/x86_64-pc-linux-gnu-gcc (gcc 4.8.2) Native java compiler: javac (unknown 1.8.0) Cross java compiler: javac (unknown 1.8.0) Host machine cpu family: x86_64 Host machine cpu: i686 Target machine cpu family: x86_64 Target machine cpu: i686 Build machine cpu family: x86_64 Build machine cpu: x86_64 Found pkg-config: f:\cygwin64\bin\pkg-config.EXE (0.29.1) Cross dependency zlib found: YES 1.2.7 Checking for size of "void*": 8 Build targets in project: 2 Traceback (most recent call last): File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 282, in run app.generate() File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 169, in generate g.generate(intr) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 187, in generate self.generate_target(t, outfile) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 355, in generate_target elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 1817, in generate_link commands += linker.get_option_link_args(self.environment.coredata.compiler_options) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\compilers.py", line 2027, in get_option_link_args return options['cpp_winlibs'].value KeyError: 'cpp_winlibs' ```
What's your cross-info file? This is most likely happening because your cross-compiler is advertising itself as GCC/MinGW. Is that correct for a Linux cross-compiler on Windows? > What's your cross-info file? This is most likely happening because your cross-compiler is advertising itself as GCC/MinGW. Is that correct for a Linux cross-compiler on Windows? ``` [host_machine] system = 'linux' cpu_family = 'x86_64' cpu = 'i686' endian = 'little' [binaries] c = 'f:/cygwin64/bin/x86_64-pc-linux-gnu-gcc' cpp = 'f:/cygwin64/bin/x86_64-pc-linux-gnu-g++' ar = 'f:/cygwin64/bin/x86_64-pc-linux-gnu-ar' strip = 'f:/cygwin64/bin/x86_64-pc-linux-gnu-strip' pkgconfig = 'f:/cygwin64/bin/x86_64-pc-linux-gnu-pkg-config' [properties] root = 'f:/cygwin64/usr/x86_64-pc-linux-gnu' ``` F:\cygwin64\bin>x86_64-pc-linux-gnu-gcc.exe --version ``` x86_64-pc-linux-gnu-gcc (GCC) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ``` Please paste the output of: `echo | f:/cygwin64/bin/x86_64-pc-linux-gnu-g++ -E -dM - | grep -i MINGW`. I'm not sure what the equivalent is with `cmd.exe` if you're using that, but I want to know if the default pre-processor defines have `__MINGW32__` or `__MINGW64__` in them. Edit: Maybe just attach the entire output of `echo | f:/cygwin64/bin/x86_64-pc-linux-gnu-g++ -E -dM -` here. F:\cygwin64\bin>echo | x86_64-pc-linux-gnu-g++ -E -dM - | grep -i MINGW ``` ``` F:\cygwin64\bin>echo | x86_64-pc-linux-gnu-g++ -E -dM - ``` #define __DBL_MIN_EXP__ (-1021) #define __UINT_LEAST16_MAX__ 65535 #define __ATOMIC_ACQUIRE 2 #define __FLT_MIN__ 1.17549435082228750797e-38F #define __UINT_LEAST8_TYPE__ unsigned char #define __INTMAX_C(c) c ## L #define __CHAR_BIT__ 8 #define __UINT8_MAX__ 255 #define __WINT_MAX__ 4294967295U #define __ORDER_LITTLE_ENDIAN__ 1234 #define __SIZE_MAX__ 18446744073709551615UL #define __WCHAR_MAX__ 2147483647 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L) #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __FLT_EVAL_METHOD__ 0 #define __unix__ 1 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __x86_64 1 #define __UINT_FAST64_MAX__ 18446744073709551615UL #define __SIG_ATOMIC_TYPE__ int #define __DBL_MIN_10_EXP__ (-307) #define __FINITE_MATH_ONLY__ 0 #define __GNUC_PATCHLEVEL__ 2 #define __UINT_FAST8_MAX__ 255 #define __DEC64_MAX_EXP__ 385 #define __INT8_C(c) c #define __UINT_LEAST64_MAX__ 18446744073709551615UL #define __SHRT_MAX__ 32767 #define __LDBL_MAX__ 1.18973149535723176502e+4932L #define __UINT_LEAST8_MAX__ 255 #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __UINTMAX_TYPE__ long unsigned int #define __linux 1 #define __DEC32_EPSILON__ 1E-6DF #define __unix 1 #define __UINT32_MAX__ 4294967295U #define __LDBL_MAX_EXP__ 16384 #define __WINT_MIN__ 0U #define __linux__ 1 #define __SCHAR_MAX__ 127 #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1) #define __INT64_C(c) c ## L #define __DBL_DIG__ 15 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __SIZEOF_INT__ 4 #define __SIZEOF_POINTER__ 8 #define __USER_LABEL_PREFIX__ #define __STDC_HOSTED__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __FLT_EPSILON__ 1.19209289550781250000e-7F #define __LDBL_MIN__ 3.36210314311209350626e-4932L #define __DEC32_MAX__ 9.999999E96DF #define __INT32_MAX__ 2147483647 #define __SIZEOF_LONG__ 8 #define __UINT16_C(c) c #define __DECIMAL_DIG__ 21 #define __gnu_linux__ 1 #define __LDBL_HAS_QUIET_NAN__ 1 #define __GNUC__ 4 #define __MMX__ 1 #define __FLT_HAS_DENORM__ 1 #define __SIZEOF_LONG_DOUBLE__ 16 #define __BIGGEST_ALIGNMENT__ 16 #define __DBL_MAX__ ((double)1.79769313486231570815e+308L) #define __INT_FAST32_MAX__ 9223372036854775807L #define __DBL_HAS_INFINITY__ 1 #define __DEC32_MIN_EXP__ (-94) #define __INT_FAST16_TYPE__ long int #define __LDBL_HAS_DENORM__ 1 #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL #define __INT_LEAST32_MAX__ 2147483647 #define __DEC32_MIN__ 1E-95DF #define __DBL_MAX_EXP__ 1024 #define __DEC128_EPSILON__ 1E-33DL #define __SSE2_MATH__ 1 #define __ATOMIC_HLE_RELEASE 131072 #define __PTRDIFF_MAX__ 9223372036854775807L #define __amd64 1 #define __ATOMIC_HLE_ACQUIRE 65536 #define __LONG_LONG_MAX__ 9223372036854775807LL #define __SIZEOF_SIZE_T__ 8 #define __SIZEOF_WINT_T__ 4 #define __GCC_HAVE_DWARF2_CFI_ASM 1 #define __GXX_ABI_VERSION 1002 #define __FLT_MIN_EXP__ (-125) #define __INT_FAST64_TYPE__ long int #define __DBL_MIN__ ((double)2.22507385850720138309e-308L) #define __LP64__ 1 #define __DECIMAL_BID_FORMAT__ 1 #define __DEC128_MIN__ 1E-6143DL #define __REGISTER_PREFIX__ #define __UINT16_MAX__ 65535 #define __DBL_HAS_DENORM__ 1 #define __UINT8_TYPE__ unsigned char #define __NO_INLINE__ 1 #define __FLT_MANT_DIG__ 24 #define __VERSION__ "4.8.2" #define __UINT64_C(c) c ## UL #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __INT32_C(c) c #define __DEC64_EPSILON__ 1E-15DD #define __ORDER_PDP_ENDIAN__ 3412 #define __DEC128_MIN_EXP__ (-6142) #define __INT_FAST32_TYPE__ long int #define __UINT_LEAST16_TYPE__ short unsigned int #define unix 1 #define __INT16_MAX__ 32767 #define __SIZE_TYPE__ long unsigned int #define __UINT64_MAX__ 18446744073709551615UL #define __INT8_TYPE__ signed char #define __ELF__ 1 #define __FLT_RADIX__ 2 #define __INT_LEAST16_TYPE__ short int #define __LDBL_EPSILON__ 1.08420217248550443401e-19L #define __UINTMAX_C(c) c ## UL #define __SSE_MATH__ 1 #define __k8 1 #define __SIG_ATOMIC_MAX__ 2147483647 #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __SIZEOF_PTRDIFF_T__ 8 #define __x86_64__ 1 #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF #define __INT_FAST16_MAX__ 9223372036854775807L #define __UINT_FAST32_MAX__ 18446744073709551615UL #define __UINT_LEAST64_TYPE__ long unsigned int #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MAX_10_EXP__ 38 #define __LONG_MAX__ 9223372036854775807L #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL #define __FLT_HAS_INFINITY__ 1 #define __UINT_FAST16_TYPE__ long unsigned int #define __DEC64_MAX__ 9.999999999999999E384DD #define __CHAR16_TYPE__ short unsigned int #define __PRAGMA_REDEFINE_EXTNAME 1 #define __INT_LEAST16_MAX__ 32767 #define __DEC64_MANT_DIG__ 16 #define __INT64_MAX__ 9223372036854775807L #define __UINT_LEAST32_MAX__ 4294967295U #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __INT_LEAST64_TYPE__ long int #define __INT16_TYPE__ short int #define __INT_LEAST8_TYPE__ signed char #define __DEC32_MAX_EXP__ 97 #define __INT_FAST8_MAX__ 127 #define __INTPTR_MAX__ 9223372036854775807L #define linux 1 #define __SSE2__ 1 #define __LDBL_MANT_DIG__ 64 #define __DBL_HAS_QUIET_NAN__ 1 #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) #define __code_model_small__ 1 #define __k8__ 1 #define __INTPTR_TYPE__ long int #define __UINT16_TYPE__ short unsigned int #define __WCHAR_TYPE__ int #define __SIZEOF_FLOAT__ 4 #define __UINTPTR_MAX__ 18446744073709551615UL #define __DEC64_MIN_EXP__ (-382) #define __INT_FAST64_MAX__ 9223372036854775807L #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __FLT_DIG__ 6 #define __UINT_FAST64_TYPE__ long unsigned int #define __INT_MAX__ 2147483647 #define __amd64__ 1 #define __INT64_TYPE__ long int #define __FLT_MAX_EXP__ 128 #define __ORDER_BIG_ENDIAN__ 4321 #define __DBL_MANT_DIG__ 53 #define __INT_LEAST64_MAX__ 9223372036854775807L #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __DEC64_MIN__ 1E-383DD #define __WINT_TYPE__ unsigned int #define __UINT_LEAST32_TYPE__ unsigned int #define __SIZEOF_SHORT__ 2 #define __SSE__ 1 #define __LDBL_MIN_EXP__ (-16381) #define __INT_LEAST8_MAX__ 127 #define __SIZEOF_INT128__ 16 #define __LDBL_MAX_10_EXP__ 4932 #define __ATOMIC_RELAXED 0 #define __DBL_EPSILON__ ((double)2.22044604925031308085e-16L) #define _LP64 1 #define __UINT8_C(c) c #define __INT_LEAST32_TYPE__ int #define __SIZEOF_WCHAR_T__ 4 #define __UINT64_TYPE__ long unsigned int #define __INT_FAST8_TYPE__ signed char #define __DBL_DECIMAL_DIG__ 17 #define __FXSR__ 1 #define __DEC_EVAL_METHOD__ 2 #define __UINT32_C(c) c ## U #define __INTMAX_MAX__ 9223372036854775807L #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F #define __INT8_MAX__ 127 #define __UINT_FAST32_TYPE__ long unsigned int #define __CHAR32_TYPE__ unsigned int #define __FLT_MAX__ 3.40282346638528859812e+38F #define __INT32_TYPE__ int #define __SIZEOF_DOUBLE__ 8 #define __FLT_MIN_10_EXP__ (-37) #define __INTMAX_TYPE__ long int #define __DEC128_MAX_EXP__ 6145 #define __ATOMIC_CONSUME 1 #define __GNUC_MINOR__ 8 #define __UINTMAX_MAX__ 18446744073709551615UL #define __DEC32_MANT_DIG__ 7 #define __DBL_MAX_10_EXP__ 308 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L #define __INT16_C(c) c #define __STDC__ 1 #define __PTRDIFF_TYPE__ long int #define __ATOMIC_SEQ_CST 5 #define __UINT32_TYPE__ unsigned int #define __UINTPTR_TYPE__ long unsigned int #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD #define __DEC128_MANT_DIG__ 34 #define __LDBL_MIN_10_EXP__ (-4931) #define __SIZEOF_LONG_LONG__ 8 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __LDBL_DIG__ 18 #define __FLT_DECIMAL_DIG__ 9 #define __UINT_FAST16_MAX__ 18446744073709551615UL #define __GNUC_GNU_INLINE__ 1 #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __UINT_FAST8_TYPE__ unsigned char #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_RELEASE 3 ``` native compiler is mingw64: F:\avian>echo | g++ -E -dM - | grep -i MINGW ``` #define __MINGW32__ 1 #define __MINGW64__ 1 ``` F:\avian>gcc --version ``` gcc.EXE (rev5, Built by MinGW-W64 project) 4.8.1 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ``` Can you apply this patch to your Meson installation and try? http://dpaste.com/0802VNP.txt I would've submitted a PR, but that code has changed in master and you wouldn't be able to apply it. Actually, this is already fixed in master and will be in the 0.36.0 release. Just need you to confirm that it's fixed with that patch. This patch fixes compilation if only cross files are compiled, but if some files are native and some cross-compiled - still the same crash. Simplest test: ``` project('hello', ['c']) exe = executable('hello-win', sources: [ 'hello.c' ], native: true) exe = executable('hello-lin', sources: [ 'hello.c' ]) ``` ``` #include <stdio.h> int main(int argc, char** argv) { printf("Hello world!"); return 0; } ``` (this is only test, in real life native executable will be used as generator of some headers for cross executable) In master branch - same result: ``` The Meson build system Version: 0.36.0.dev1 Source dir: F:\avian\test Build dir: F:\avian\test\build\linux-64 Build type: cross build Project name: hello Native c compiler: gcc (gcc 4.8.1) Cross c compiler: f:/cygwin64/bin/x86_64-pc-linux-gnu-gcc (gcc 4.8.2) Host machine cpu family: x86_64 Host machine cpu: i686 Target machine cpu family: x86_64 Target machine cpu: i686 Build machine cpu family: x86_64 Build machine cpu: x86_64 Build targets in project: 2 Traceback (most recent call last): File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 283, in run app.generate() File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 173, in generate g.generate(intr) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 192, in generate self.generate_target(t, outfile) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 427, in generate_target elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 1961, in generate_link commands += linker.get_option_link_args(self.environment.coredata.compiler_options) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\compilers.py", line 2064, in get_option_link_args return options['c_winlibs'].value KeyError: 'c_winlibs' ``` The problem now is that the cross-compiler options are passed to both the native and the cross-compiler. The native (MinGW) compiler always expects `c_winlibs` to be in the options but they aren't, so it errors out. The fix is to use the default value of `c_winlibs` if they're not in the compiler options, and the complete fix is to allow the cross-info file to specify compiler options. I'll implement the first part for this release since it's simple (and happening today), but the second part will have to wait for the next one. It should fix your issue though.
2016-11-13T09:47:59Z
[]
[]
Traceback (most recent call last): File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 282, in run app.generate() File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 169, in generate g.generate(intr) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 187, in generate self.generate_target(t, outfile) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 355, in generate_target elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 1817, in generate_link commands += linker.get_option_link_args(self.environment.coredata.compiler_options) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\compilers.py", line 2027, in get_option_link_args return options['cpp_winlibs'].value KeyError: 'cpp_winlibs'
8,743
mesonbuild/meson
mesonbuild__meson-10613
748251fba6be36f07e060a5a6788eaa076d46f93
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -439,7 +439,8 @@ def __init__(self, variables: T.Optional[T.Dict[str, T.Any]] = None) -> None: for key, value in variables.items(): value = mesonlib.listify(value) for i in value: - assert isinstance(i, str) + if not isinstance(i, str): + raise EnvironmentException(f"Value '{i}' of CMake variable '{key}' defined in a machine file is a {type(i).__name__} and not a str") self.variables[key] = value def get_variables(self) -> T.Dict[str, T.List[str]]:
Meson told me report an "Unhandled python exception". While defining a cross build file for `Windows`, I wrote a section for `cmake`, ```ini [cmake] CMAKE_C_COMPILER_WORKS = 1 ``` and I forgot to wrap "1" in single quotes and it threw this unhandled exception. ```bash ❯ meson setup --cross-file=cross-windows-x86_64.ini build-win Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 146, in run return options.run_func(options) File "/usr/lib/python3.10/site-packages/mesonbuild/msetup.py", line 294, in run app.generate() File "/usr/lib/python3.10/site-packages/mesonbuild/msetup.py", line 180, in generate env = environment.Environment(self.source_dir, self.build_dir, self.options) File "/usr/lib/python3.10/site-packages/mesonbuild/environment.py", line 536, in __init__ cmakevars.host = CMakeVariables(config.get('cmake', {})) File "/usr/lib/python3.10/site-packages/mesonbuild/envconfig.py", line 442, in __init__ assert isinstance(i, str) AssertionError ERROR: Unhandled python exception This is a Meson bug and should be reported! ```
@mensinda
2022-07-18T15:08:08Z
[]
[]
Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 146, in run return options.run_func(options) File "/usr/lib/python3.10/site-packages/mesonbuild/msetup.py", line 294, in run app.generate() File "/usr/lib/python3.10/site-packages/mesonbuild/msetup.py", line 180, in generate env = environment.Environment(self.source_dir, self.build_dir, self.options) File "/usr/lib/python3.10/site-packages/mesonbuild/environment.py", line 536, in __init__ cmakevars.host = CMakeVariables(config.get('cmake', {})) File "/usr/lib/python3.10/site-packages/mesonbuild/envconfig.py", line 442, in __init__ assert isinstance(i, str) AssertionError
8,757
mesonbuild/meson
mesonbuild__meson-10824
7e4188a53fdebda6a06b6ac3bd4bc4e51411702d
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -1043,8 +1043,12 @@ def gen_vcxproj(self, target, ofname, guid): # reversed is used to keep order of includes for i in reversed(d.get_incdirs()): curdir = os.path.join(d.get_curdir(), i) - args.append('-I' + self.relpath(curdir, target.subdir)) # build dir - args.append('-I' + os.path.join(proj_to_src_root, curdir)) # src dir + try: + args.append('-I' + self.relpath(curdir, target.subdir)) # build dir + args.append('-I' + os.path.join(proj_to_src_root, curdir)) # src dir + except ValueError: + # Include is on different drive + args.append('-I' + os.path.normpath(curdir)) for i in d.get_extra_build_dirs(): curdir = os.path.join(d.get_curdir(), i) args.append('-I' + self.relpath(curdir, target.subdir)) # build dir
Visual Studio Backend Doesn't Work when project is on different drive as include paths **Describe the bug** When installing the project in a specific drive, e.g. drive D, and adding include paths on a different drive , e.g. drive C, meson setup will crash: Traceback (most recent call last): File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\mesonmain.py", line 140, in run return options.run_func(options) File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\msetup.py", line 253, in run app.generate() File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\msetup.py", line 161, in generate self._generate(env) File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\msetup.py", line 223, in _generate intr.backend.generate() File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 188, in generate projlist = self.generate_projects() File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 422, in generate_projects self.gen_vcxproj(target, str(projfile_path), proj_uuid) File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 971, in gen_vcxproj args.append('-I' + self.relpath(curdir, target.subdir)) # build dir File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\backends.py", line 339, in relpath os.path.join('dummyprefixdir', fromdir)) File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\ntpath.py", line 562, in relpath path_drive, start_drive)) ValueError: path is on mount 'C:', start on mount 'D:' When looking at the code: https://github.com/mesonbuild/meson/blob/0.56/mesonbuild/backend/vs2010backend.py This logic is not correct: for d in reversed(target.get_include_dirs()): # reversed is used to keep order of includes for i in reversed(d.get_incdirs()): curdir = os.path.join(d.get_curdir(), i) args.append('-I' + self.relpath(curdir, target.subdir)) # **** won't work if different drive letters **** What if the include path is in drive D and the current directory is in drive C? **To Reproduce** Install dependency xyz in drive C and project on drive D xyz_dep = dependency('xyz') libxyz = library( dependencies: [ xyz_dep ] ) **Expected behavior** Meson should support project directories on any drive and include directories on any drive **system parameters** native build Windows 10 Python 3.7.9
2022-09-17T11:21:46Z
[]
[]
Traceback (most recent call last): File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\mesonmain.py", line 140, in run return options.run_func(options) File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\msetup.py", line 253, in run app.generate() File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\msetup.py", line 161, in generate self._generate(env) File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\msetup.py", line 223, in _generate intr.backend.generate() File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 188, in generate projlist = self.generate_projects() File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 422, in generate_projects self.gen_vcxproj(target, str(projfile_path), proj_uuid) File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 971, in gen_vcxproj args.append('-I' + self.relpath(curdir, target.subdir)) # build dir File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\mesonbuild\backend\backends.py", line 339, in relpath os.path.join('dummyprefixdir', fromdir)) File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\ntpath.py", line 562, in relpath path_drive, start_drive)) ValueError: path is on mount 'C:', start on mount 'D:'
8,779
mesonbuild/meson
mesonbuild__meson-1091
bfd190279ca6e8d08917dde0ff22ba33f6162e45
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -233,7 +233,7 @@ def check_pkgconfig(self): '(%s)' % out.decode().strip()) PkgConfigDependency.pkgconfig_found = True return - except Exception: + except (FileNotFoundError, PermissionError): pass PkgConfigDependency.pkgconfig_found = False if not self.silent: @@ -358,7 +358,7 @@ def check_wxconfig(self): self.wxc = wxc WxDependency.wx_found = True return - except Exception: + except (FileNotFoundError, PermissionError): pass WxDependency.wxconfig_found = False mlog.log('Found wx-config:', mlog.red('NO')) @@ -1040,7 +1040,7 @@ def detect(self): gp = subprocess.Popen([confprog, '--help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) gp.communicate() - except FileNotFoundError: + except (FileNotFoundError, PermissionError): self.args = None mlog.log('Dependency GnuStep found:', mlog.red('NO'), '(no gnustep-config)') return diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -43,7 +43,8 @@ def detect_ninja(): for n in ['ninja', 'ninja-build']: try: p = subprocess.Popen([n, '--version'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) - except FileNotFoundError: + except (FileNotFoundError, PermissionError): + # Doesn't exist in PATH or isn't executable continue version = p.communicate()[0].decode(errors='ignore') # Perhaps we should add a way for the caller to know the failure mode
difficult error to debug if ninja can't be found I updated ninja but forgot to `chmod +x` it and got this error. At first I had no clue what was happening until I remembered I updated `ninja`. ``` python3 ./ECS/meson/meson.py --prefix=/home/gitlab-runner/builds/15268147/0/dist-ecs --buildtype=debugoptimized build Traceback (most recent call last): File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/mesonmain.py", line 283, in run app.generate() File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/mesonmain.py", line 173, in generate g.generate(intr) File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/backend/ninjabackend.py", line 203, in generate self.generate_ending(outfile) File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/backend/ninjabackend.py", line 2094, in generate_ending ninja_command = environment.detect_ninja() File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/environment.py", line 51, in detect_ninja p = subprocess.Popen([n, '--version'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) File "/usr/local/lib/python3.5/subprocess.py", line 947, in __init__ restore_signals, start_new_session) File "/usr/local/lib/python3.5/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg) PermissionError: [Errno 13] Permission denied ```
Interesting that `subprocess.Popen` returns a `PermissionError` instead of a `FileNotFoundError` if there's a file in `PATH` with the correct name but no executable bit. Nothing else does this.
2016-11-23T09:09:47Z
[]
[]
Traceback (most recent call last): File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/mesonmain.py", line 283, in run app.generate() File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/mesonmain.py", line 173, in generate g.generate(intr) File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/backend/ninjabackend.py", line 203, in generate self.generate_ending(outfile) File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/backend/ninjabackend.py", line 2094, in generate_ending ninja_command = environment.detect_ninja() File "/home/gitlab-runner/builds/15268147/0/ECS/meson/mesonbuild/environment.py", line 51, in detect_ninja p = subprocess.Popen([n, '--version'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) File "/usr/local/lib/python3.5/subprocess.py", line 947, in __init__ restore_signals, start_new_session) File "/usr/local/lib/python3.5/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg) PermissionError: [Errno 13] Permission denied
8,784
mesonbuild/meson
mesonbuild__meson-1092
bfd190279ca6e8d08917dde0ff22ba33f6162e45
diff --git a/meson.py b/meson.py --- a/meson.py +++ b/meson.py @@ -14,10 +14,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mesonbuild import mesonmain -import sys, os +from mesonbuild import mlog, mesonmain +import sys, os, locale def main(): + # Warn if the locale is not UTF-8. This can cause various unfixable issues + # such as os.stat not being able to decode filenames with unicode in them. + # There is no way to reset both the preferred encoding and the filesystem + # encoding, so we can just warn about it. + e = locale.getpreferredencoding() + if e.upper() != 'UTF-8': + mlog.warning('You are using {!r} which is not a a Unicode-compatible ' + 'locale.'.format(e)) + mlog.warning('You might see errors if you use UTF-8 strings as ' + 'filenames, as strings, or as file contents.') + mlog.warning('Please switch to a UTF-8 locale for your platform.') # Always resolve the command path so Ninja can find it for regen, tests, etc. launcher = os.path.realpath(sys.argv[0]) return mesonmain.run(launcher, sys.argv[1:]) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -303,7 +303,7 @@ def do_conf_file(src, dst, confdata): replace_if_different(dst, dst_tmp) def dump_conf_header(ofilename, cdata): - with open(ofilename, 'w') as ofile: + with open(ofilename, 'w', encoding='utf-8') as ofile: ofile.write('''/* * Autogenerated by the Meson build system. * Do not edit, your changes will be lost.
UnicodeEncodeError in mesonlib.do_conf_file() ```python Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 283, in run app.generate() File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 171, in generate intr.run() File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1336, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1358, in evaluate_codeblock raise e File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1352, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1473, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2494, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 66, in wrapped return f(self, node, args, kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2209, in func_subdir self.evaluate_codeblock(codeblock) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1358, in evaluate_codeblock raise e File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1352, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1473, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2494, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2257, in func_configure_file mesonlib.do_conf_file(ifile_abs, ofile_abs, conf.held_object) File "/usr/lib/python3.5/site-packages/mesonbuild/mesonlib.py", line 292, in do_conf_file f.writelines(result) UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 13: ordinal not in range(128) ```
I'm hitting this bug too with LANG=C. Workaround is export LANG=en_US.utf8 The problem is that you're trying to write a unicode character to a file when using a non-unicode encoding. We can fix this by setting the `encoding` kwarg while writing files. However, this will break in other ways, such as when using files with unicode filenames. What's the output of: ``` python3 -c 'import locale; print(locale.getpreferredencoding())' ``` With `LANG=C` that will return `ANSI_X3.4-1968` or some similar ansi encoding. I don't think we can do anything about a broken `LANG` setting except while writing/reading files.
2016-11-23T10:58:43Z
[]
[]
Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 283, in run app.generate() File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 171, in generate intr.run() File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1336, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1358, in evaluate_codeblock raise e File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1352, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1473, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2494, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 66, in wrapped return f(self, node, args, kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2209, in func_subdir self.evaluate_codeblock(codeblock) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1358, in evaluate_codeblock raise e File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1352, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1473, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2494, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2257, in func_configure_file mesonlib.do_conf_file(ifile_abs, ofile_abs, conf.held_object) File "/usr/lib/python3.5/site-packages/mesonbuild/mesonlib.py", line 292, in do_conf_file f.writelines(result) UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 13: ordinal not in range(128)
8,785
mesonbuild/meson
mesonbuild__meson-11063
68a84f6535de738a71efd9d413ca43371d165219
diff --git a/mesonbuild/build.py b/mesonbuild/build.py --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -36,7 +36,7 @@ extract_as_list, typeslistify, stringlistify, classify_unity_sources, get_filenames_templates_dict, substitute_values, has_path_sep, OptionKey, PerMachineDefaultable, OptionOverrideProxy, - MesonBugException, EnvironmentVariables + MesonBugException, EnvironmentVariables, pickle_load, ) from .compilers import ( is_object, clink_langs, sort_clink, all_languages, @@ -2900,24 +2900,11 @@ def get_sources_string_names(sources, backend): def load(build_dir: str) -> Build: filename = os.path.join(build_dir, 'meson-private', 'build.dat') - load_fail_msg = f'Build data file {filename!r} is corrupted. Try with a fresh build tree.' - nonexisting_fail_msg = f'No such build data file as "{filename!r}".' try: - with open(filename, 'rb') as f: - obj = pickle.load(f) + return pickle_load(filename, 'Build data', Build) except FileNotFoundError: - raise MesonException(nonexisting_fail_msg) - except (pickle.UnpicklingError, EOFError): - raise MesonException(load_fail_msg) - except AttributeError: - raise MesonException( - f"Build data file {filename!r} references functions or classes that don't " - "exist. This probably means that it was generated with an old " - "version of meson. Try running from the source directory " - f"meson setup {build_dir} --wipe") - if not isinstance(obj, Build): - raise MesonException(load_fail_msg) - return obj + raise MesonException(f'No such build data file as {filename!r}.') + def save(obj: Build, filename: str) -> None: with open(filename, 'wb') as f: diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -2289,16 +2289,21 @@ def pickle_load(filename: str, object_name: str, object_type: T.Type) -> T.Any: except (pickle.UnpicklingError, EOFError): raise MesonException(load_fail_msg) except (TypeError, ModuleNotFoundError, AttributeError): + build_dir = os.path.dirname(os.path.dirname(filename)) raise MesonException( f"{object_name} file {filename!r} references functions or classes that don't " "exist. This probably means that it was generated with an old " - "version of meson.") + "version of meson. Try running from the source directory " + f'meson setup {build_dir} --wipe') if not isinstance(obj, object_type): raise MesonException(load_fail_msg) from ..coredata import version as coredata_version from ..coredata import major_versions_differ, MesonVersionMismatchException - if major_versions_differ(obj.version, coredata_version): - raise MesonVersionMismatchException(obj.version, coredata_version) + version = getattr(obj, 'version', None) + if version is None: + version = obj.environment.coredata.version + if major_versions_differ(version, coredata_version): + raise MesonVersionMismatchException(version, coredata_version) return obj
meson crash: mesonbuild.mesonlib is not a package. The command ` meson configure . -Doptimization=0` crashes with a python stack trace: ``` Traceback (most recent call last): File "/Users/john/.local/share/virtualenvs/etc-vauAPygS/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 194, in run return options.run_func(options) File "/Users/john/.local/share/virtualenvs/etc-vauAPygS/lib/python3.10/site-packages/mesonbuild/mconf.py", line 300, in run c = Conf(builddir) File "/Users/john/.local/share/virtualenvs/etc-vauAPygS/lib/python3.10/site-packages/mesonbuild/mconf.py", line 72, in __init__ self.build = build.load(self.build_dir) File "/Users/john/.local/share/virtualenvs/etc-vauAPygS/lib/python3.10/site-packages/mesonbuild/build.py", line 2907, in load obj = pickle.load(f) ModuleNotFoundError: No module named 'mesonbuild.mesonlib.universal'; 'mesonbuild.mesonlib' is not a package ERROR: Unhandled python exception This is a Meson bug and should be reported! ``` Source is [cairo](https://gitlab.freedesktop.org/cairo/cairo/) at [commit 6dc5df6](https://gitlab.freedesktop.org/cairo/cairo/-/commit/c6dc5df61264be1bec2e622355b97c6c45d236fc). Native compilation on macOS 13.1beta with Xcode 14.1's toolchain. Python is a locally-compiled 3.10 in a pyenv-controlled virtenv, and meson-0.64.0 was just pulled from pypi with pip3.
your system sounds broken @tristan957 OK, but that's not very helpful. What is broken about it? Usually when I have seen this error it is because Meson was installed with a different version of Python than what it is being executed with. But this happened in meson configure, when configuring an existing build directory. The actual problem is that Meson requires you to re-setup when you update to a new major version. Usually you'd get an "error: you configured with meson 0.63 which is an older version, pls redo everything, kthxbai", more or less. In this case it failed before the error message could be generated so you got a stacktrace instead. This is a UX bug, I know why it happened and I will PR the fix shortly. Hmm. It turns out that @tristan957 was almost right: There are in fact two python builds accessible to meson though they're both v3.10.0. Meson was installed in the virtenv, but $PYTHON pointed to another instance of python3.10 and that python's sys.path doesn't include meson's modules. However, it's also correct that once I did `rm -rf * && meson ../../src/cairo` with the new meson version `meson configure . -Doptimization=0` no longer crashes. Glad a PR could come out of it and your problem fixed :).
2022-11-17T02:05:07Z
[]
[]
Traceback (most recent call last): File "/Users/john/.local/share/virtualenvs/etc-vauAPygS/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 194, in run return options.run_func(options) File "/Users/john/.local/share/virtualenvs/etc-vauAPygS/lib/python3.10/site-packages/mesonbuild/mconf.py", line 300, in run c = Conf(builddir) File "/Users/john/.local/share/virtualenvs/etc-vauAPygS/lib/python3.10/site-packages/mesonbuild/mconf.py", line 72, in __init__ self.build = build.load(self.build_dir) File "/Users/john/.local/share/virtualenvs/etc-vauAPygS/lib/python3.10/site-packages/mesonbuild/build.py", line 2907, in load obj = pickle.load(f) ModuleNotFoundError: No module named 'mesonbuild.mesonlib.universal'; 'mesonbuild.mesonlib' is not a package
8,797
mesonbuild/meson
mesonbuild__meson-11458
1c00375ed897b034f464e12e9748633d641a8027
diff --git a/mesonbuild/interpreterbase/interpreterbase.py b/mesonbuild/interpreterbase/interpreterbase.py --- a/mesonbuild/interpreterbase/interpreterbase.py +++ b/mesonbuild/interpreterbase/interpreterbase.py @@ -31,12 +31,13 @@ ) from .exceptions import ( + BreakRequest, + ContinueRequest, InterpreterException, - InvalidCode, InvalidArguments, + InvalidCode, + MesonException, SubdirDoneRequest, - ContinueRequest, - BreakRequest ) from .decorators import FeatureNew @@ -71,6 +72,13 @@ T.Callable[[mparser.BaseNode, T.List[TYPE_var], T.Dict[str, TYPE_var]], TYPE_var] ] + +class InvalidCodeOnVoid(InvalidCode): + + def __init__(self, op_type: str) -> None: + super().__init__(f'Cannot perform {op_type!r} operation on void statement.') + + class InterpreterBase: def __init__(self, source_root: str, subdir: str, subproject: 'SubProject'): self.source_root = source_root @@ -238,7 +246,10 @@ def evaluate_dictstatement(self, cur: mparser.DictNode) -> InterpreterObject: def resolve_key(key: mparser.BaseNode) -> str: if not isinstance(key, mparser.StringNode): FeatureNew.single_use('Dictionary entry using non literal key', '0.53.0', self.subproject) - str_key = _unholder(self.evaluate_statement(key)) + key_holder = self.evaluate_statement(key) + if key_holder is None: + raise InvalidArguments('Key cannot be void.') + str_key = _unholder(key_holder) if not isinstance(str_key, str): raise InvalidArguments('Key must be a string') return str_key @@ -248,6 +259,8 @@ def resolve_key(key: mparser.BaseNode) -> str: def evaluate_notstatement(self, cur: mparser.NotNode) -> InterpreterObject: v = self.evaluate_statement(cur.value) + if v is None: + raise InvalidCodeOnVoid('not') if isinstance(v, Disabler): return v return self._holderify(v.operator_call(MesonOperator.NOT, None)) @@ -259,10 +272,12 @@ def evaluate_if(self, node: mparser.IfClauseNode) -> T.Optional[Disabler]: # statement evaluation. self.tmp_meson_version = None result = self.evaluate_statement(i.condition) + if result is None: + raise InvalidCodeOnVoid('if') if isinstance(result, Disabler): return result if not isinstance(result, InterpreterObject): - raise mesonlib.MesonBugException(f'Argument to not ({result}) is not an InterpreterObject but {type(result).__name__}.') + raise mesonlib.MesonBugException(f'Argument to if ({result}) is not an InterpreterObject but {type(result).__name__}.') res = result.operator_call(MesonOperator.BOOL, None) if not isinstance(res, bool): raise InvalidCode(f'If clause {result!r} does not evaluate to true or false.') @@ -281,9 +296,13 @@ def evaluate_if(self, node: mparser.IfClauseNode) -> T.Optional[Disabler]: def evaluate_comparison(self, node: mparser.ComparisonNode) -> InterpreterObject: val1 = self.evaluate_statement(node.left) + if val1 is None: + raise MesonException('Cannot compare a void statement on the left-hand side') if isinstance(val1, Disabler): return val1 val2 = self.evaluate_statement(node.right) + if val2 is None: + raise MesonException('Cannot compare a void statement on the right-hand side') if isinstance(val2, Disabler): return val2 @@ -308,30 +327,40 @@ def evaluate_comparison(self, node: mparser.ComparisonNode) -> InterpreterObject def evaluate_andstatement(self, cur: mparser.AndNode) -> InterpreterObject: l = self.evaluate_statement(cur.left) + if l is None: + raise MesonException('Cannot compare a void statement on the left-hand side') if isinstance(l, Disabler): return l l_bool = l.operator_call(MesonOperator.BOOL, None) if not l_bool: return self._holderify(l_bool) r = self.evaluate_statement(cur.right) + if r is None: + raise MesonException('Cannot compare a void statement on the right-hand side') if isinstance(r, Disabler): return r return self._holderify(r.operator_call(MesonOperator.BOOL, None)) def evaluate_orstatement(self, cur: mparser.OrNode) -> InterpreterObject: l = self.evaluate_statement(cur.left) + if l is None: + raise MesonException('Cannot compare a void statement on the left-hand side') if isinstance(l, Disabler): return l l_bool = l.operator_call(MesonOperator.BOOL, None) if l_bool: return self._holderify(l_bool) r = self.evaluate_statement(cur.right) + if r is None: + raise MesonException('Cannot compare a void statement on the right-hand side') if isinstance(r, Disabler): return r return self._holderify(r.operator_call(MesonOperator.BOOL, None)) def evaluate_uminusstatement(self, cur: mparser.UMinusNode) -> InterpreterObject: v = self.evaluate_statement(cur.value) + if v is None: + raise InvalidCodeOnVoid('unary minus') if isinstance(v, Disabler): return v v.current_node = cur @@ -344,6 +373,8 @@ def evaluate_arithmeticstatement(self, cur: mparser.ArithmeticNode) -> Interpret r = self.evaluate_statement(cur.right) if isinstance(r, Disabler): return r + if l is None or r is None: + raise InvalidCodeOnVoid(cur.operation) mapping: T.Dict[str, MesonOperator] = { 'add': MesonOperator.PLUS, @@ -359,6 +390,8 @@ def evaluate_arithmeticstatement(self, cur: mparser.ArithmeticNode) -> Interpret def evaluate_ternary(self, node: mparser.TernaryNode) -> T.Optional[InterpreterObject]: assert isinstance(node, mparser.TernaryNode) result = self.evaluate_statement(node.condition) + if result is None: + raise MesonException('Cannot use a void statement as condition for ternary operator.') if isinstance(result, Disabler): return result result.current_node = node @@ -424,6 +457,8 @@ def evaluate_plusassign(self, node: mparser.PlusAssignmentNode) -> None: assert isinstance(node, mparser.PlusAssignmentNode) varname = node.var_name addition = self.evaluate_statement(node.value) + if addition is None: + raise InvalidCodeOnVoid('plus assign') # Remember that all variables are immutable. We must always create a # full new variable and then assign it. @@ -435,12 +470,15 @@ def evaluate_plusassign(self, node: mparser.PlusAssignmentNode) -> None: def evaluate_indexing(self, node: mparser.IndexNode) -> InterpreterObject: assert isinstance(node, mparser.IndexNode) iobject = self.evaluate_statement(node.iobject) + if iobject is None: + raise InterpreterException('Tried to evaluate indexing on void.') if isinstance(iobject, Disabler): return iobject - index = _unholder(self.evaluate_statement(node.index)) + index_holder = self.evaluate_statement(node.index) + if index_holder is None: + raise InvalidArguments('Cannot use void statement as index.') + index = _unholder(index_holder) - if iobject is None: - raise InterpreterException('Tried to evaluate indexing on None') iobject.current_node = node return self._holderify(iobject.operator_call(MesonOperator.INDEX, index)) @@ -578,7 +616,7 @@ def assignment(self, node: mparser.AssignmentNode) -> None: def set_variable(self, varname: str, variable: T.Union[TYPE_var, InterpreterObject], *, holderify: bool = False) -> None: if variable is None: - raise InvalidCode('Can not assign None to variable.') + raise InvalidCode('Can not assign void to variable.') if holderify: variable = self._holderify(variable) else:
'NoneType' object has no attribute 'current_node' **Describe the bug** I was setting up a build of GIMP3 from the master branch in MSYS2/MinGW64, but I'm getting an internal error: ``` Configuring org.gimp.extension.goat-exercises.metainfo.xml.in using configuration Traceback (most recent call last): File "D:/meson/mesonbuild/mesonmain.py", line 193, in run return options.run_func(options) File "D:/meson/mesonbuild/msetup.py", line 309, in run app.generate() File "D:/meson/mesonbuild/msetup.py", line 186, in generate self._generate(env) File "D:/meson/mesonbuild/msetup.py", line 230, in _generate intr.run() File "D:/meson/mesonbuild/interpreter/interpreter.py", line 2886, in run super().run() File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 149, in run self.evaluate_codeblock(self.ast, start=1) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 174, in evaluate_codeblock raise e File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_codeblock self.evaluate_statement(cur) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 180, in evaluate_statement return self.function_call(cur) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 462, in function_call res = func(node, func_args, kwargs) File "D:/meson/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper return f(*nargs, **wrapped_kwargs) File "D:/meson/mesonbuild/interpreterbase/decorators.py", line 590, in wrapper return f(*wrapped_args, **wrapped_kwargs) File "D:/meson/mesonbuild/interpreter/interpreter.py", line 2298, in func_subdir self.evaluate_codeblock(codeblock) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 174, in evaluate_codeblock raise e File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_codeblock self.evaluate_statement(cur) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 208, in evaluate_statement return self.evaluate_uminusstatement(cur) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 339, in evaluate_uminusstatement v.current_node = cur AttributeError: 'NoneType' object has no attribute 'current_node' ../gimp/plug-ins/meson.build:4:1: ERROR: Unhandled python exception This is a Meson bug and should be reported! ``` I am launching Meson with the following command-line: `python /d/meson/meson.py setup ../gimp --prefix=$GIMP_PREFIX --buildtype=debug` **To Reproduce** * `git clone --depth=1 https://gitlab.gnome.org/GNOME/gimp.git` * `mkdir gimp-build` * `cd gimp-build` * `meson setup ../gimp --buildtype=debug` **system parameters** * Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)? `Native` * what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) `Win10` * what Python version are you using e.g. 3.8.0 `Python 3.10.9` * what meson --version `Tried both 0.64.1 and current master (1.0.99)` * what ninja --version if it's a Ninja build `Ninja 1.11.1`
Looks like I made a mistake: instead of commenting a line: `#subdir('file-exr')` I wrote that: `-subdir('file-exr')` This confuses the parser. This is still a legitimate bug, we should not display this exception.
2023-02-25T17:19:55Z
[]
[]
Traceback (most recent call last): File "D:/meson/mesonbuild/mesonmain.py", line 193, in run return options.run_func(options) File "D:/meson/mesonbuild/msetup.py", line 309, in run app.generate() File "D:/meson/mesonbuild/msetup.py", line 186, in generate self._generate(env) File "D:/meson/mesonbuild/msetup.py", line 230, in _generate intr.run() File "D:/meson/mesonbuild/interpreter/interpreter.py", line 2886, in run super().run() File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 149, in run self.evaluate_codeblock(self.ast, start=1) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 174, in evaluate_codeblock raise e File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_codeblock self.evaluate_statement(cur) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 180, in evaluate_statement return self.function_call(cur) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 462, in function_call res = func(node, func_args, kwargs) File "D:/meson/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper return f(*nargs, **wrapped_kwargs) File "D:/meson/mesonbuild/interpreterbase/decorators.py", line 590, in wrapper return f(*wrapped_args, **wrapped_kwargs) File "D:/meson/mesonbuild/interpreter/interpreter.py", line 2298, in func_subdir self.evaluate_codeblock(codeblock) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 174, in evaluate_codeblock raise e File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_codeblock self.evaluate_statement(cur) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 208, in evaluate_statement return self.evaluate_uminusstatement(cur) File "D:/meson/mesonbuild/interpreterbase/interpreterbase.py", line 339, in evaluate_uminusstatement v.current_node = cur AttributeError: 'NoneType' object has no attribute 'current_node'
8,828
mesonbuild/meson
mesonbuild__meson-1156
344231d336339c0ea4c1eb072ef37ba5e15ff901
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -18,7 +18,7 @@ from .. import mlog from .. import dependencies from .. import compilers -from ..mesonlib import File, MesonException, get_compiler_for_source +from ..mesonlib import File, MesonException, get_compiler_for_source, Popen_safe from .backends import InstallData from ..build import InvalidArguments import os, sys, pickle, re @@ -158,18 +158,14 @@ def detect_vs_dep_prefix(self, tempfilename): int dummy; ''') - pc = subprocess.Popen(['cl', '/showIncludes', '/c', 'incdetect.c'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - cwd=self.environment.get_scratch_dir()) + pc, stdo = Popen_safe(['cl', '/showIncludes', '/c', 'incdetect.c'], + cwd=self.environment.get_scratch_dir())[0:2] - (stdo, _) = pc.communicate() - - for line in stdo.split(b'\r\n'): - if line.endswith(b'stdio.h'): - matchstr = b':'.join(line.split(b':')[0:2]) + b':' - with open(tempfilename, 'ab') as binfile: - binfile.write(b'msvc_deps_prefix = ' + matchstr + b'\r\n') + for line in stdo.split('\n'): + if line.endswith('stdio.h'): + matchstr = ':'.join(line.split(':')[0:2]) + ':' + with open(tempfilename, 'a') as binfile: + binfile.write('msvc_deps_prefix = ' + matchstr + '\n') return open(tempfilename, 'a') raise MesonException('Could not determine vs dep dependency prefix string.') diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -18,7 +18,7 @@ import tempfile from .import mesonlib from . import mlog -from .mesonlib import MesonException, version_compare +from .mesonlib import MesonException, version_compare, Popen_safe from . import coredata """This file contains the data files of all compilers Meson knows @@ -457,12 +457,7 @@ def compile(self, code, extra_args=None): mlog.debug('Working directory: ', tmpdirname) mlog.debug('Command line: ', ' '.join(commands), '\n') mlog.debug('Code:\n', code) - p = subprocess.Popen(commands, cwd=tmpdirname, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - (stde, stdo) = p.communicate() - stde = stde.decode() - stdo = stdo.decode() + p, stdo, stde = Popen_safe(commands, cwd=tmpdirname) mlog.debug('Compiler stdout:\n', stdo) mlog.debug('Compiler stderr:\n', stde) @@ -594,9 +589,7 @@ def get_std_shared_lib_link_args(self): return ['-shared'] def get_library_dirs(self): - output = subprocess.Popen(self.exelist + ['--print-search-dirs'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) - (stdo, _) = output.communicate() - stdo = stdo.decode('utf-8') + stdo = Popen_safe(self.exelist + ['--print-search-dirs'])[1] for line in stdo.split('\n'): if line.startswith('libraries:'): libstr = line.split('=', 1)[1] @@ -653,10 +646,7 @@ def sanity_check_impl(self, work_dir, environment, sname, code): ofile.write(code) # Compile sanity check cmdlist = self.exelist + extra_flags + [source_name] + self.get_output_args(binary_name) - pc = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=work_dir) - (stdo, stde) = pc.communicate() - stdo = stdo.decode() - stde = stde.decode() + pc, stdo, stde = Popen_safe(cmdlist, cwd=work_dir) mlog.debug('Sanity check compiler command line:', ' '.join(cmdlist)) mlog.debug('Sanity check compile stdout:') mlog.debug(stdo) @@ -800,15 +790,11 @@ def run(self, code, env, extra_args=None, dependencies=None): else: cmdlist = p.output_name try: - pe = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + pe, so, se = Popen_safe(cmdlist) except Exception as e: mlog.debug('Could not run: %s (error: %s)\n' % (cmdlist, e)) return RunResult(False) - (so, se) = pe.communicate() - so = so.decode() - se = se.decode() mlog.debug('Program stdout:\n') mlog.debug(so) mlog.debug('Program stderr:\n') @@ -1919,7 +1905,7 @@ def get_include_args(self, path, is_system): # understand and you can't tell it to error out on those. # http://stackoverflow.com/questions/15259720/how-can-i-make-the-microsoft-c-compiler-treat-unknown-flags-as-errors-rather-t def has_argument(self, arg, env): - warning_text = b'9002' + warning_text = '9002' code = 'int i;\n' (fd, srcname) = tempfile.mkstemp(suffix='.'+self.default_suffix) os.close(fd) @@ -1932,8 +1918,7 @@ def has_argument(self, arg, env): mlog.debug('Running VS compile:') mlog.debug('Command line: ', ' '.join(commands)) mlog.debug('Code:\n', code) - p = subprocess.Popen(commands, cwd=os.path.split(srcname)[0], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stde, stdo) = p.communicate() + p, stdo, stde = Popen_safe(commands, cwd=os.path.split(srcname)[0]) if p.returncode != 0: raise MesonException('Compiling test app failed.') return not(warning_text in stde or warning_text in stdo) @@ -2587,10 +2572,9 @@ class ArLinker(): def __init__(self, exelist): self.exelist = exelist self.id = 'ar' - pc = subprocess.Popen(self.exelist + ['-h'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) - (stdo, _) = pc.communicate() + pc, stdo = Popen_safe(self.exelist + ['-h'])[0:2] # Enable deterministic builds if they are available. - if b'[D]' in stdo: + if '[D]' in stdo: self.std_args = ['csrD'] else: self.std_args = ['csr'] diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -23,7 +23,7 @@ import os, stat, glob, subprocess, shutil import sysconfig from collections import OrderedDict -from . mesonlib import MesonException, version_compare, version_compare_many +from . mesonlib import MesonException, version_compare, version_compare_many, Popen_safe from . import mlog from . import mesonlib from .environment import detect_cpu_family, for_windows @@ -170,17 +170,14 @@ def __init__(self, name, environment, kwargs): self._set_libs() def _call_pkgbin(self, args): - p = subprocess.Popen([self.pkgbin] + args, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=os.environ, universal_newlines=True) - out = p.communicate()[0] + p, out = Popen_safe([self.pkgbin] + args, env=os.environ)[0:2] return (p.returncode, out.strip()) def _set_cargs(self): ret, out = self._call_pkgbin(['--cflags', self.name]) if ret != 0: raise DependencyException('Could not generate cargs for %s:\n\n%s' % \ - (self.name, out.decode(errors='ignore'))) + (self.name, out)) self.cargs = out.split() def _set_libs(self): @@ -190,7 +187,7 @@ def _set_libs(self): ret, out = self._call_pkgbin(libcmd) if ret != 0: raise DependencyException('Could not generate libs for %s:\n\n%s' % \ - (self.name, out.decode(errors='ignore'))) + (self.name, out)) self.libs = [] for lib in out.split(): if lib.endswith(".la"): @@ -238,13 +235,11 @@ def check_pkgconfig(self): pkgbin = os.environ[evar].strip() else: pkgbin = 'pkg-config' - p = subprocess.Popen([pkgbin, '--version'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out = p.communicate()[0] + p, out = Popen_safe([pkgbin, '--version'])[0:2] if p.returncode == 0: if not self.silent: mlog.log('Found pkg-config:', mlog.bold(shutil.which(pkgbin)), - '(%s)' % out.decode().strip()) + '(%s)' % out.strip()) PkgConfigDependency.pkgconfig_found = True return except (FileNotFoundError, PermissionError): @@ -303,16 +298,13 @@ def __init__(self, environment, kwargs): mlog.log("Neither wx-config-3.0 nor wx-config found; can't detect dependency") return - p = subprocess.Popen([self.wxc, '--version'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out = p.communicate()[0] + p, out = Popen_safe([self.wxc, '--version'])[0:2] if p.returncode != 0: mlog.log('Dependency wxwidgets found:', mlog.red('NO')) self.cargs = [] self.libs = [] else: - self.modversion = out.decode().strip() + self.modversion = out.strip() version_req = kwargs.get('version', None) if version_req is not None: if not version_compare(self.modversion, version_req, strict=True): @@ -324,20 +316,15 @@ def __init__(self, environment, kwargs): self.requested_modules = self.get_requested(kwargs) # wx-config seems to have a cflags as well but since it requires C++, # this should be good, at least for now. - p = subprocess.Popen([self.wxc, '--cxxflags'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out = p.communicate()[0] + p, out = Popen_safe([self.wxc, '--cxxflags'])[0:2] if p.returncode != 0: raise DependencyException('Could not generate cargs for wxwidgets.') - self.cargs = out.decode().split() + self.cargs = out.split() - p = subprocess.Popen([self.wxc, '--libs'] + self.requested_modules, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out = p.communicate()[0] + p, out = Popen_safe([self.wxc, '--libs'] + self.requested_modules)[0:2] if p.returncode != 0: raise DependencyException('Could not generate libs for wxwidgets.') - self.libs = out.decode().split() + self.libs = out.split() def get_requested(self, kwargs): modules = 'modules' @@ -363,12 +350,10 @@ def get_link_args(self): def check_wxconfig(self): for wxc in ['wx-config-3.0', 'wx-config']: try: - p = subprocess.Popen([wxc, '--version'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out = p.communicate()[0] + p, out = Popen_safe([wxc, '--version'])[0:2] if p.returncode == 0: mlog.log('Found wx-config:', mlog.bold(shutil.which(wxc)), - '(%s)' % out.decode().strip()) + '(%s)' % out.strip()) self.wxc = wxc WxDependency.wx_found = True return @@ -943,10 +928,7 @@ def _qmake_detect(self, mods, env, kwargs): if not self.qmake.found(): continue # Check that the qmake is for qt5 - pc = subprocess.Popen(self.qmake.fullpath + ['-v'], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - universal_newlines=True) - stdo = pc.communicate()[0] + pc, stdo = Popen_safe(self.qmake.fullpath + ['-v'])[0:2] if pc.returncode != 0: continue if not 'Qt version ' + self.qtver in stdo: @@ -959,9 +941,7 @@ def _qmake_detect(self, mods, env, kwargs): return self.version = re.search(self.qtver + '(\.\d+)+', stdo).group(0) # Query library path, header path, and binary path - stdo = subprocess.Popen(self.qmake.fullpath + ['-query'], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - universal_newlines=True).communicate()[0] + stdo = Popen_safe(self.qmake.fullpath + ['-query'])[1] qvars = {} for line in stdo.split('\n'): line = line.strip() @@ -1051,9 +1031,7 @@ def __init__(self, environment, kwargs): def detect(self): confprog = 'gnustep-config' try: - gp = subprocess.Popen([confprog, '--help'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - gp.communicate() + gp = Popen_safe([confprog, '--help'])[0] except (FileNotFoundError, PermissionError): self.args = None mlog.log('Dependency GnuStep found:', mlog.red('NO'), '(no gnustep-config)') @@ -1066,20 +1044,12 @@ def detect(self): arg = '--gui-libs' else: arg = '--base-libs' - fp = subprocess.Popen([confprog, '--objc-flags'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (flagtxt, flagerr) = fp.communicate() - flagtxt = flagtxt.decode() - flagerr = flagerr.decode() + fp, flagtxt, flagerr = Popen_safe([confprog, '--objc-flags']) if fp.returncode != 0: raise DependencyException('Error getting objc-args: %s %s' % (flagtxt, flagerr)) args = flagtxt.split() self.args = self.filter_arsg(args) - fp = subprocess.Popen([confprog, arg], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (libtxt, liberr) = fp.communicate() - libtxt = libtxt.decode() - liberr = liberr.decode() + fp, libtxt, liberr = Popen_safe([confprog, arg]) if fp.returncode != 0: raise DependencyException('Error getting objc-lib args: %s %s' % (libtxt, liberr)) self.libs = self.weird_filter(libtxt.split()) @@ -1184,16 +1154,10 @@ def __init__(self, environment, kwargs): pass sdlconf = shutil.which('sdl2-config') if sdlconf: - pc = subprocess.Popen(['sdl2-config', '--cflags'], - stdout=subprocess.PIPE, - stderr=subprocess.DEVNULL) - (stdo, _) = pc.communicate() - self.cargs = stdo.decode().strip().split() - pc = subprocess.Popen(['sdl2-config', '--libs'], - stdout=subprocess.PIPE, - stderr=subprocess.DEVNULL) - (stdo, _) = pc.communicate() - self.linkargs = stdo.decode().strip().split() + pc, stdo = Popen_safe(['sdl2-config', '--cflags'])[0:2] + self.cargs = stdo.strip().split() + pc, stdo = Popen_safe(['sdl2-config', '--libs'])[0:2] + self.linkargs = stdo.strip().split() self.is_found = True mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.green('YES'), '(%s)' % sdlconf) self.version = '2' # FIXME diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -17,6 +17,7 @@ from . import mesonlib from . import mlog from .compilers import * +from .mesonlib import Popen_safe import configparser import shutil @@ -42,11 +43,10 @@ def find_coverage_tools(): def detect_ninja(): for n in ['ninja', 'ninja-build']: try: - p = subprocess.Popen([n, '--version'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + p, version = Popen_safe([n, '--version'])[0:2] except (FileNotFoundError, PermissionError): # Doesn't exist in PATH or isn't executable continue - version = p.communicate()[0].decode(errors='ignore') # Perhaps we should add a way for the caller to know the failure mode # (not found or too old) if p.returncode == 0 and mesonlib.version_compare(version, ">=1.6"): @@ -306,9 +306,7 @@ def get_gnu_compiler_defines(compiler): # Arguments to output compiler pre-processor defines to stdout # gcc, g++, and gfortran all support these arguments args = compiler + ['-E', '-dM', '-'] - p = subprocess.Popen(args, universal_newlines=True, - stdin=subprocess.PIPE, stdout=subprocess.PIPE) - output = p.communicate('')[0] + p, output = Popen_safe(args, write='', stdin=subprocess.PIPE)[0:2] if p.returncode != 0: raise EnvironmentException('Unable to detect GNU compiler type:\n' + output) # Parse several lines of the type: @@ -372,14 +370,10 @@ def detect_c_compiler(self, want_cross): arg = '/?' else: arg = '--version' - p = subprocess.Popen([compiler, arg], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + p, out, err = Popen_safe([compiler, arg]) except OSError as e: popen_exceptions[' '.join([compiler, arg])] = e continue - (out, err) = p.communicate() - out = out.decode(errors='ignore') - err = err.decode(errors='ignore') version = search_version(out) if 'Free Software Foundation' in out: defines = self.get_gnu_compiler_defines([compiler]) @@ -428,15 +422,10 @@ def detect_fortran_compiler(self, want_cross): for compiler in compilers: for arg in ['--version', '-V']: try: - p = subprocess.Popen([compiler, arg], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + p, out, err = Popen_safe([compiler, arg]) except OSError as e: popen_exceptions[' '.join([compiler, arg])] = e continue - (out, err) = p.communicate() - out = out.decode(errors='ignore') - err = err.decode(errors='ignore') version = search_version(out) @@ -512,15 +501,10 @@ def detect_cpp_compiler(self, want_cross): else: arg = '--version' try: - p = subprocess.Popen([compiler, arg], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + p, out, err = Popen_safe([compiler, arg]) except OSError as e: popen_exceptions[' '.join([compiler, arg])] = e continue - (out, err) = p.communicate() - out = out.decode(errors='ignore') - err = err.decode(errors='ignore') version = search_version(out) if 'Free Software Foundation' in out: defines = self.get_gnu_compiler_defines([compiler]) @@ -559,12 +543,9 @@ def detect_objc_compiler(self, want_cross): is_cross = False exe_wrap = None try: - p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p, out, err = Popen_safe(exelist + ['--version']) except OSError: raise EnvironmentException('Could not execute ObjC compiler "%s"' % ' '.join(exelist)) - (out, err) = p.communicate() - out = out.decode(errors='ignore') - err = err.decode(errors='ignore') version = search_version(out) if 'Free Software Foundation' in out: defines = self.get_gnu_compiler_defines(exelist) @@ -587,12 +568,9 @@ def detect_objcpp_compiler(self, want_cross): is_cross = False exe_wrap = None try: - p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p, out, err = Popen_safe(exelist + ['--version']) except OSError: raise EnvironmentException('Could not execute ObjC++ compiler "%s"' % ' '.join(exelist)) - (out, err) = p.communicate() - out = out.decode(errors='ignore') - err = err.decode(errors='ignore') version = search_version(out) if 'Free Software Foundation' in out: defines = self.get_gnu_compiler_defines(exelist) @@ -604,12 +582,9 @@ def detect_objcpp_compiler(self, want_cross): def detect_java_compiler(self): exelist = ['javac'] try: - p = subprocess.Popen(exelist + ['-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p, out, err = Popen_safe(exelist + ['-version']) except OSError: raise EnvironmentException('Could not execute Java compiler "%s"' % ' '.join(exelist)) - (out, err) = p.communicate() - out = out.decode(errors='ignore') - err = err.decode(errors='ignore') version = search_version(err) if 'javac' in err: return JavaCompiler(exelist, version) @@ -618,12 +593,9 @@ def detect_java_compiler(self): def detect_cs_compiler(self): exelist = ['mcs'] try: - p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p, out, err = Popen_safe(exelist + ['--version']) except OSError: raise EnvironmentException('Could not execute C# compiler "%s"' % ' '.join(exelist)) - (out, err) = p.communicate() - out = out.decode(errors='ignore') - err = err.decode(errors='ignore') version = search_version(out) if 'Mono' in out: return MonoCompiler(exelist, version) @@ -632,11 +604,9 @@ def detect_cs_compiler(self): def detect_vala_compiler(self): exelist = ['valac'] try: - p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p, out = Popen_safe(exelist + ['--version'])[0:2] except OSError: raise EnvironmentException('Could not execute Vala compiler "%s"' % ' '.join(exelist)) - (out, _) = p.communicate() - out = out.decode(errors='ignore') version = search_version(out) if 'Vala' in out: return ValaCompiler(exelist, version) @@ -645,11 +615,9 @@ def detect_vala_compiler(self): def detect_rust_compiler(self): exelist = ['rustc'] try: - p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p, out = Popen_safe(exelist + ['--version'])[0:2] except OSError: raise EnvironmentException('Could not execute Rust compiler "%s"' % ' '.join(exelist)) - (out, _) = p.communicate() - out = out.decode(errors='ignore') version = search_version(out) if 'rustc' in out: return RustCompiler(exelist, version) @@ -679,11 +647,9 @@ def detect_d_compiler(self): raise EnvironmentException('Could not find any supported D compiler.') try: - p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p, out = Popen_safe(exelist + ['--version'])[0:2] except OSError: raise EnvironmentException('Could not execute D compiler "%s"' % ' '.join(exelist)) - (out, _) = p.communicate() - out = out.decode(errors='ignore') version = search_version(out) if 'LLVM D compiler' in out: return LLVMDCompiler(exelist, version, is_cross) @@ -696,11 +662,9 @@ def detect_d_compiler(self): def detect_swift_compiler(self): exelist = ['swiftc'] try: - p = subprocess.Popen(exelist + ['-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p, _, err = Popen_safe(exelist + ['-v']) except OSError: raise EnvironmentException('Could not execute Swift compiler "%s"' % ' '.join(exelist)) - (_, err) = p.communicate() - err = err.decode(errors='ignore') version = search_version(err) if 'Swift' in err: return SwiftCompiler(exelist, version) @@ -723,12 +687,9 @@ def detect_static_linker(self, compiler): else: arg = '--version' try: - p = subprocess.Popen([linker, arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p, out, err = Popen_safe([linker, arg]) except OSError: raise EnvironmentException('Could not execute static linker "%s".' % linker) - (out, err) = p.communicate() - out = out.decode(errors='ignore') - err = err.decode(errors='ignore') if '/OUT:' in out or '/OUT:' in err: return VisualStudioLinker([linker]) if p.returncode == 0: diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -22,6 +22,7 @@ from . import compilers from .wrap import wrap from . import mesonlib +from .mesonlib import Popen_safe from .dependencies import InternalDependency, Dependency from .interpreterbase import InterpreterBase from .interpreterbase import check_stringlist, noPosargs, noKwargs, stringArgs @@ -70,17 +71,8 @@ class RunProcess(InterpreterObject): def __init__(self, command_array, source_dir, build_dir, subdir, in_builddir=False): super().__init__() - pc = self.run_command(command_array, source_dir, build_dir, subdir, in_builddir) - (stdout, stderr) = pc.communicate() + pc, self.stdout, self.stderr = self.run_command(command_array, source_dir, build_dir, subdir, in_builddir) self.returncode = pc.returncode - if sys.stdout.encoding: - self.stdout = stdout.decode(encoding=sys.stdout.encoding, errors='ignore').replace('\r\n', '\n') - else: - self.stdout = stdout.decode(errors='ignore').replace('\r\n', '\n') - if sys.stderr.encoding: - self.stderr = stderr.decode(encoding=sys.stderr.encoding, errors='ignore').replace('\r\n', '\n') - else: - self.stderr = stderr.decode(errors='ignore').replace('\r\n', '\n') self.methods.update({'returncode' : self.returncode_method, 'stdout' : self.stdout_method, 'stderr' : self.stderr_method, @@ -99,22 +91,19 @@ def run_command(self, command_array, source_dir, build_dir, subdir, in_builddir) child_env.update(env) mlog.debug('Running command:', ' '.join(command_array)) try: - return subprocess.Popen(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=child_env, cwd=cwd) + return Popen_safe(command_array, env=child_env, cwd=cwd) except FileNotFoundError: pass # Was not a command, is a program in path? exe = shutil.which(cmd_name) if exe is not None: command_array = [exe] + command_array[1:] - return subprocess.Popen(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=child_env, cwd=cwd) + return Popen_safe(command_array, env=child_env, cwd=cwd) # No? Maybe it is a script in the source tree. fullpath = os.path.join(source_dir, subdir, cmd_name) command_array = [fullpath] + command_array[1:] try: - return subprocess.Popen(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=child_env, cwd=cwd) + return Popen_safe(command_array, env=child_env, cwd=cwd) except FileNotFoundError: raise InterpreterException('Could not execute command "%s".' % cmd_name) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -385,3 +385,10 @@ def expand_arguments(args): print(e) return None return expended_args + +def Popen_safe(args, write=None, stderr=subprocess.PIPE, **kwargs): + p = subprocess.Popen(args, universal_newlines=True, + stdout=subprocess.PIPE, + stderr=stderr, **kwargs) + o, e = p.communicate(write) + return (p, o, e) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -20,7 +20,7 @@ import sys import copy import subprocess -from ..mesonlib import MesonException +from ..mesonlib import MesonException, Popen_safe from .. import dependencies from .. import mlog from .. import mesonlib @@ -197,9 +197,7 @@ def _get_gresource_dependencies(self, state, input_file, source_dirs, dependenci cmd += ['--sourcedir', os.path.join(state.subdir, source_dir)] cmd += ['--sourcedir', state.subdir] # Current dir - pc = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True, - cwd=state.environment.get_source_dir()) - (stdout, _) = pc.communicate() + pc, stdout = Popen_safe(cmd, cwd=state.environment.get_source_dir())[0:2] if pc.returncode != 0: mlog.warning('glib-compile-resources has failed to get the dependencies for {}'.format(cmd[1])) raise subprocess.CalledProcessError(pc.returncode, cmd) diff --git a/mesonbuild/modules/qt4.py b/mesonbuild/modules/qt4.py --- a/mesonbuild/modules/qt4.py +++ b/mesonbuild/modules/qt4.py @@ -15,7 +15,7 @@ import os, subprocess from .. import mlog from .. import build -from ..mesonlib import MesonException +from ..mesonlib import MesonException, Popen_safe from ..dependencies import Qt4Dependency import xml.etree.ElementTree as ET @@ -37,11 +37,9 @@ def _detect_tools(self, env): # Moc and rcc return a non-zero result when doing so. # What kind of an idiot thought that was a good idea? if self.moc.found(): - mp = subprocess.Popen(self.moc.get_command() + ['-v'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = mp.communicate() - stdout = stdout.decode().strip() - stderr = stderr.decode().strip() + stdout, stderr = Popen_safe(self.moc.get_command() + ['-v'])[1:3] + stdout = stdout.strip() + stderr = stderr.strip() if 'Qt Meta' in stderr: moc_ver = stderr else: @@ -52,11 +50,9 @@ def _detect_tools(self, env): else: mlog.log(' moc:', mlog.red('NO')) if self.uic.found(): - up = subprocess.Popen(self.uic.get_command() + ['-v'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = up.communicate() - stdout = stdout.decode().strip() - stderr = stderr.decode().strip() + stdout, stderr = Popen_safe(self.uic.get_command() + ['-v'])[1:3] + stdout = stdout.strip() + stderr = stderr.strip() if 'version 4.' in stderr: uic_ver = stderr else: @@ -67,11 +63,9 @@ def _detect_tools(self, env): else: mlog.log(' uic:', mlog.red('NO')) if self.rcc.found(): - rp = subprocess.Popen(self.rcc.get_command() + ['-v'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = rp.communicate() - stdout = stdout.decode().strip() - stderr = stderr.decode().strip() + stdout, stderr = Popen_safe(self.rcc.get_command() + ['-v'])[1:3] + stdout = stdout.strip() + stderr = stderr.strip() if 'version 4.' in stderr: rcc_ver = stderr else: diff --git a/mesonbuild/modules/qt5.py b/mesonbuild/modules/qt5.py --- a/mesonbuild/modules/qt5.py +++ b/mesonbuild/modules/qt5.py @@ -15,7 +15,7 @@ import os, subprocess from .. import mlog from .. import build -from ..mesonlib import MesonException +from ..mesonlib import MesonException, Popen_safe from ..dependencies import Qt5Dependency import xml.etree.ElementTree as ET @@ -37,11 +37,9 @@ def _detect_tools(self, env): # Moc and rcc return a non-zero result when doing so. # What kind of an idiot thought that was a good idea? if self.moc.found(): - mp = subprocess.Popen(self.moc.get_command() + ['-v'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = mp.communicate() - stdout = stdout.decode().strip() - stderr = stderr.decode().strip() + stdout, stderr = Popen_safe(self.moc.get_command() + ['-v'])[1:3] + stdout = stdout.strip() + stderr = stderr.strip() if 'Qt 5' in stderr: moc_ver = stderr elif '5.' in stdout: @@ -54,11 +52,9 @@ def _detect_tools(self, env): else: mlog.log(' moc:', mlog.red('NO')) if self.uic.found(): - up = subprocess.Popen(self.uic.get_command() + ['-v'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = up.communicate() - stdout = stdout.decode().strip() - stderr = stderr.decode().strip() + stdout, stderr = Popen_safe(self.uic.get_command() + ['-v'])[1:3] + stdout = stdout.strip() + stderr = stderr.strip() if 'version 5.' in stderr: uic_ver = stderr elif '5.' in stdout: @@ -71,11 +67,9 @@ def _detect_tools(self, env): else: mlog.log(' uic:', mlog.red('NO')) if self.rcc.found(): - rp = subprocess.Popen(self.rcc.get_command() + ['-v'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = rp.communicate() - stdout = stdout.decode().strip() - stderr = stderr.decode().strip() + stdout, stderr = Popen_safe(self.rcc.get_command() + ['-v'])[1:3] + stdout = stdout.strip() + stderr = stderr.strip() if 'version 5.' in stderr: rcc_ver = stderr elif '5.' in stdout: diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -17,7 +17,7 @@ import subprocess import shutil import argparse -from ..mesonlib import MesonException +from ..mesonlib import MesonException, Popen_safe from . import destdir_join parser = argparse.ArgumentParser() @@ -46,15 +46,13 @@ parser.add_argument('--installdir', dest='install_dir') def gtkdoc_run_check(cmd, cwd): - p = subprocess.Popen(cmd, cwd=cwd, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stde, stdo) = p.communicate() + # Put stderr into stdout since we want to print it out anyway. + # This preserves the order of messages. + p, out = Popen_safe(cmd, cwd=cwd, stderr=subprocess.STDOUT)[0:2] if p.returncode != 0: err_msg = ["{!r} failed with status {:d}".format(cmd[0], p.returncode)] - if stde: - err_msg.append(stde.decode(errors='ignore')) - if stdo: - err_msg.append(stdo.decode(errors='ignore')) + if out: + err_msg.append(out) raise MesonException('\n'.join(err_msg)) def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, diff --git a/mesonbuild/scripts/meson_exe.py b/mesonbuild/scripts/meson_exe.py --- a/mesonbuild/scripts/meson_exe.py +++ b/mesonbuild/scripts/meson_exe.py @@ -21,7 +21,7 @@ import platform import subprocess -import mesonbuild +from ..mesonlib import MesonException, Popen_safe options = None @@ -45,7 +45,7 @@ def run_exe(exe): else: if exe.is_cross: if exe.exe_runner is None: - raise Exception('BUG: Trying to run cross-compiled exes with no wrapper') + raise AssertionError('BUG: Trying to run cross-compiled exes with no wrapper') else: cmd = [exe.exe_runner] + exe.fname else: @@ -55,17 +55,12 @@ def run_exe(exe): if len(exe.extra_paths) > 0: child_env['PATH'] = (os.pathsep.join(exe.extra_paths + ['']) + child_env['PATH']) - p = subprocess.Popen(cmd + exe.cmd_args, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - env=child_env, - cwd=exe.workdir) - stdout, stderr = p.communicate() + p, stdout, stderr = Popen_safe(cmd + exe.cmd_args, env=child_env, cwd=exe.workdir) if exe.capture and p.returncode == 0: - with open(exe.capture, 'wb') as output: + with open(exe.capture, 'w') as output: output.write(stdout) if stderr: - sys.stderr.buffer.write(stderr) + sys.stderr.write(stderr) return p.returncode def run(args): diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py --- a/mesonbuild/scripts/meson_install.py +++ b/mesonbuild/scripts/meson_install.py @@ -18,6 +18,7 @@ from glob import glob from . import depfixer from . import destdir_join +from ..mesonlib import MesonException, Popen_safe install_log_file = None @@ -205,12 +206,11 @@ def install_targets(d): do_copy(fname, outname) if should_strip: print('Stripping target') - ps = subprocess.Popen(['strip', outname], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdo, stde) = ps.communicate() + ps, stdo, stde = Popen_safe(['strip', outname]) if ps.returncode != 0: print('Could not strip file.\n') - print('Stdout:\n%s\n' % stdo.decode()) - print('Stderr:\n%s\n' % stde.decode()) + print('Stdout:\n%s\n' % stdo) + print('Stderr:\n%s\n' % stde) sys.exit(1) printed_symlink_error = False for alias in aliases: diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py --- a/mesonbuild/scripts/symbolextractor.py +++ b/mesonbuild/scripts/symbolextractor.py @@ -23,7 +23,8 @@ # http://cgit.freedesktop.org/libreoffice/core/commit/?id=3213cd54b76bc80a6f0516aac75a48ff3b2ad67c import os, sys, subprocess -from mesonbuild import mesonlib +from .. import mesonlib +from ..mesonlib import MesonException, Popen_safe import argparse parser = argparse.ArgumentParser() @@ -59,23 +60,21 @@ def linux_syms(libfilename, outfilename): nmbin = os.environ[evar].strip() else: nmbin = 'nm' - pe = subprocess.Popen([readelfbin, '-d', libfilename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output = pe.communicate()[0].decode() + pe, output = Popen_safe([readelfbin, '-d', libfilename])[0:2] if pe.returncode != 0: raise RuntimeError('Readelf does not work') result = [x for x in output.split('\n') if 'SONAME' in x] assert(len(result) <= 1) - pnm = subprocess.Popen([nmbin, '--dynamic', '--extern-only', '--defined-only', '--format=posix', libfilename], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output = pnm.communicate()[0].decode() + pnm, output = Popen_safe([nmbin, '--dynamic', '--extern-only', + '--defined-only', '--format=posix', + libfilename])[0:2] if pnm.returncode != 0: raise RuntimeError('nm does not work.') result += [' '.join(x.split()[0:2]) for x in output.split('\n') if len(x) > 0] write_if_changed('\n'.join(result) + '\n', outfilename) def osx_syms(libfilename, outfilename): - pe = subprocess.Popen(['otool', '-l', libfilename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output = pe.communicate()[0].decode() + pe, output = Popen_safe(['otool', '-l', libfilename])[0:2] if pe.returncode != 0: raise RuntimeError('Otool does not work.') arr = output.split('\n') @@ -84,8 +83,7 @@ def osx_syms(libfilename, outfilename): match = i break result = [arr[match+2], arr[match+5]] # Libreoffice stores all 5 lines but the others seem irrelevant. - pnm = subprocess.Popen(['nm', '-g', '-P', libfilename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output = pnm.communicate()[0].decode() + pnm, output = Popen_safe(['nm', '-g', '-P', libfilename])[0:2] if pnm.returncode != 0: raise RuntimeError('nm does not work.') result += [' '.join(x.split()[0:2]) for x in output.split('\n') if len(x) > 0 and not x.endswith('U')]
--backend vs2015 always crashes on non-english Windows ``` The Meson build system Version: 0.36.0 Source dir: F:\avian\hello-c 19:18Build dir: F:\avian\hello-c\build Build type: native build Project name: hello Traceback (most recent call last): File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 283, in run app.generate() File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 163, in generate intr = interpreter.Interpreter(b, g) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1190, in __init__ self.parse_project() File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1260, in parse_project self.evaluate_codeblock(self.ast, end=1) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1358, in evaluate_codeblock raise e File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1352, in evaluate_codeblock self.evaluate_statement(cur) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1473, in evaluate_statement return self.function_call(cur) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 2494, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 74, in wrapped return f(self, node, args, kwargs) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1688, in func_project self.add_languages(args[1:], True) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1804, in add_languages (comp, cross_comp) = self.detect_compilers(lang, need_cross_compiler) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1773, in detect_compilers comp.sanity_check(self.environment.get_scratch_dir(), self.environment) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\compilers.py", line 684, in sanity_check return self.sanity_check_impl(work_dir, environment, 'sanitycheckc.c', code) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\compilers.py", line 659, in sanity_check_impl stde = stde.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8e in position 0: invalid start byte ```
Simpest test - hello.c builds by msvc(32/64), mingw(32/64) https://github.com/msink/hello-c On appveyor all 4 test passed, on my local windows mingw passed, msvc crashes. `chcp 65001` fixes this, at least on my computer (win7-x64 russian) ``` rem script for local testing chcp 65001 for %%t in (mingw,msvc) do ( for %%p in (x86,x64) do ( for %%c in (debug,release) do ( setlocal set Compiler=%%t set Platform=%%p set Configuration=%%c call appveyor.bat endlocal ) ) ) ``` Apparently this is fixed with Python 3.6: https://www.python.org/dev/peps/pep-0528/ However, we should also include a workaround inside Meson itself instead of telling people to run `chcp` before running Meson. Apparently there is also a module that does this: https://pypi.org/project/win_unicode_console/ Could you please try to use that and tell us if it works? If so, it would be great to have a patch to Meson that does what the module does on Windows. That PEP is about console I/O (as is the package) but Meson here is crashing due to a bad decode out of `subprocess`. Could using `universal_newlines=True` fix the problem? > a module that does this: https://pypi.org/project/win_unicode_console/ No, I tried this - no result. `chcp 65001` fixes my build. Dont know why. My Windows doesn't have Russian or any European language available (probably because of ridiculous OEM things). I tested this with Hindi as my display language but I couldn't reproduce it (probably because it retained `cp1252` as the codepage). I'm going to try shooting in the dark now and send you some patches to test. Okey, or I can pull a branch of your repository ( https://github.com/centricular/meson.git ) and test... This patch fixes msvc on my computer: ``` diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index ced2b6f..96af423 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys import shutil import contextlib import subprocess, os.path @@ -461,8 +462,8 @@ class Compiler(): stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stde, stdo) = p.communicate() - stde = stde.decode() - stdo = stdo.decode() + stde = stde.decode(sys.stderr.encoding) + stdo = stdo.decode(sys.stdout.encoding) mlog.debug('Compiler stdout:\n', stdo) mlog.debug('Compiler stderr:\n', stde) @@ -655,8 +656,8 @@ class CCompiler(Compiler): cmdlist = self.exelist + extra_flags + [source_name] + self.get_output_args(binary_name) pc = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=work_dir) (stdo, stde) = pc.communicate() - stdo = stdo.decode() - stde = stde.decode() + stdo = stdo.decode(sys.stdout.encoding) + stde = stde.decode(sys.stderr.encoding) mlog.debug('Sanity check compiler command line:', ' '.join(cmdlist)) mlog.debug('Sanity check compile stdout:') mlog.debug(stdo) @@ -774,8 +775,8 @@ int main () {{ return RunResult(False) (so, se) = pe.communicate() - so = so.decode() - se = se.decode() + so = so.decode(sys.stdout.encoding) + se = se.decode(sys.stderr.encoding) mlog.debug('Program stdout:\n') mlog.debug(so) mlog.debug('Program stderr:\n') ``` Dont know if it is correct way (I'm total noob in python) but it works for me, both without and with `chcp 65001`
2016-12-07T01:36:14Z
[]
[]
Traceback (most recent call last): File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 283, in run app.generate() File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\mesonmain.py", line 163, in generate intr = interpreter.Interpreter(b, g) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1190, in __init__ self.parse_project() File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1260, in parse_project self.evaluate_codeblock(self.ast, end=1) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1358, in evaluate_codeblock raise e File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1352, in evaluate_codeblock self.evaluate_statement(cur) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1473, in evaluate_statement return self.function_call(cur) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 2494, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 74, in wrapped return f(self, node, args, kwargs) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1688, in func_project self.add_languages(args[1:], True) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1804, in add_languages (comp, cross_comp) = self.detect_compilers(lang, need_cross_compiler) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\interpreter.py", line 1773, in detect_compilers comp.sanity_check(self.environment.get_scratch_dir(), self.environment) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\compilers.py", line 684, in sanity_check return self.sanity_check_impl(work_dir, environment, 'sanitycheckc.c', code) File "c:\program files (x86)\python35-32\lib\site-packages\mesonbuild\compilers.py", line 659, in sanity_check_impl stde = stde.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8e in position 0: invalid start byte
8,834
mesonbuild/meson
mesonbuild__meson-11690
285e0d3c597d17fb980d95bda1d153f3e2829bcf
diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -176,8 +176,8 @@ class _VerPickleLoadable(Protocol): from glob import glob -if os.path.basename(sys.executable) == 'meson.exe': - # In Windows and using the MSI installed executable. +if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): + # using a PyInstaller bundle, e.g. the MSI installed executable python_command = [sys.executable, 'runpython'] else: python_command = [sys.executable] diff --git a/packaging/hook-mesonbuild.py b/packaging/hook-mesonbuild.py --- a/packaging/hook-mesonbuild.py +++ b/packaging/hook-mesonbuild.py @@ -21,7 +21,7 @@ def get_all_modules_from_dir(dirname): modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')] return modules -datas += collect_data_files('mesonbuild.scripts') +datas += collect_data_files('mesonbuild.scripts', include_py_files=True, excludes=['**/__pycache__']) datas += collect_data_files('mesonbuild.cmake.data') datas += collect_data_files('mesonbuild.dependencies.data')
No such file or directory: 'C:\\Program Files\\Meson\\mesonbuild\\scripts\\python_info.py' ### Discussed in https://github.com/mesonbuild/meson/discussions/11688 <div type='discussions-op-text'> <sup>Originally posted by **KyrietS** April 15, 2023</sup> Hi, I tried compiling Cairo but when I ran `meson setup build/` I got an error: ``` meson.build:111:27: ERROR: <PythonExternalProgram 'python3' -> ['C:\\Program Files\\Meson\\meson.exe', 'runpython']> is not a valid python or it is missing distutils ``` Inside `build/meson-logs/meson-log.txt` I can see: ``` Program stderr: Traceback (most recent call last): File "mesonbuild\mesonmain.py", line 194, in run File "mesonbuild\mesonmain.py", line 149, in run_runpython_command File "runpy.py", line 288, in run_path File "runpy.py", line 252, in _get_code_from_file FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Program Files\\Meson\\mesonbuild\\scripts\\python_info.py' ``` My specs: * Windows 11 * Python 3.11.3 * Meson 1.1.0 </div>
2023-04-16T04:19:09Z
[]
[]
Traceback (most recent call last): File "mesonbuild\mesonmain.py", line 194, in run File "mesonbuild\mesonmain.py", line 149, in run_runpython_command File "runpy.py", line 288, in run_path File "runpy.py", line 252, in _get_code_from_file FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Program Files\\Meson\\mesonbuild\\scripts\\python_info.py'
8,845
mesonbuild/meson
mesonbuild__meson-1171
ec47db6c0c6511d249b6d57fd24ca288e00eb9a3
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -178,6 +178,8 @@ def flatten_object_list(self, target, proj_dir_to_build_root=''): o = os.path.join(proj_dir_to_build_root, self.build_to_src, target.get_subdir(), obj) obj_list.append(o) + elif isinstance(obj, mesonlib.File): + obj_list.append(obj.rel_to_builddir(self.build_to_src)) elif isinstance(obj, build.ExtractedObjects): obj_list += self.determine_ext_objs(obj, proj_dir_to_build_root) else: @@ -233,39 +235,21 @@ def serialise_tests(self): self.write_benchmark_file(datafile) return (test_data, benchmark_data) - def determine_linker(self, target, src): + def determine_linker(self, target): + ''' + If we're building a static library, there is only one static linker. + Otherwise, we query the target for the dynamic linker. + ''' if isinstance(target, build.StaticLibrary): if target.is_cross: return self.build.static_cross_linker else: return self.build.static_linker - if target.is_cross: - compilers = self.build.cross_compilers - else: - compilers = self.build.compilers - if len(compilers) == 1: - return compilers[0] - # Currently a bit naive. C++ must - # be linked with a C++ compiler, but - # otherwise we don't care. This will - # become trickier if and when Fortran - # and the like become supported. - cpp = None - for c in compilers: - if c.get_language() == 'cpp': - cpp = c - break - if cpp is not None: - for s in src: - if c.can_compile(s): - return cpp - for c in compilers: - if c.get_language() == 'vala': - continue - for s in src: - if c.can_compile(s): - return c - raise AssertionError("BUG: Couldn't determine linker for sources {!r}".format(src)) + l = target.get_clike_dynamic_linker() + if not l: + m = "Couldn't determine linker for target {!r}" + raise MesonException(m.format(target.name)) + return l def object_filename_from_source(self, target, source): if isinstance(source, mesonlib.File): diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -299,6 +299,9 @@ def generate_target(self, target, outfile): self.generate_swift_target(target, outfile) return + # Now we handle the following languages: + # ObjC++, ObjC, C++, C, D, Fortran, Vala + # Pre-existing target C/C++ sources to be built; dict of full path to # source relative to build root and the original File object. target_sources = OrderedDict() @@ -332,7 +335,6 @@ def generate_target(self, target, outfile): unity_src = [] unity_deps = [] # Generated sources that must be built before compiling a Unity target. header_deps += self.get_generated_headers(target) - src_list = [] if is_unity: # Warn about incompatible sources if a unity build is enabled @@ -346,16 +348,12 @@ def generate_target(self, target, outfile): ''.format(langs_are, langs, target.name) mlog.log(mlog.red('FIXME'), msg) - # Get a list of all generated *sources* (sources files, headers, - # objects, etc). Needed to determine the linker. - generated_output_sources = [] # Get a list of all generated headers that will be needed while building # this target's sources (generated sources and pre-existing sources). # This will be set as dependencies of all the target's sources. At the # same time, also deal with generated sources that need to be compiled. generated_source_files = [] for rel_src, gensrc in generated_sources.items(): - generated_output_sources.append(rel_src) raw_src = RawFilename(rel_src) if self.environment.is_source(rel_src) and not self.environment.is_header(rel_src): if is_unity and self.get_target_source_can_unity(target, rel_src): @@ -377,12 +375,12 @@ def generate_target(self, target, outfile): # this target. We create the Ninja build file elements for this here # because we need `header_deps` to be fully generated in the above loop. for src in generated_source_files: - src_list.append(src) if self.environment.is_llvm_ir(src): - obj_list.append(self.generate_llvm_ir_compile(target, outfile, src)) - continue - obj_list.append(self.generate_single_compile(target, outfile, src, True, - header_deps=header_deps)) + o = self.generate_llvm_ir_compile(target, outfile, src) + else: + o = self.generate_single_compile(target, outfile, src, True, + header_deps=header_deps) + obj_list.append(o) # Generate compilation targets for C sources generated from Vala # sources. This can be extended to other $LANG->C compilers later if @@ -390,7 +388,6 @@ def generate_target(self, target, outfile): vala_generated_source_files = [] for src in vala_generated_sources: raw_src = RawFilename(src) - src_list.append(src) if is_unity: unity_src.append(os.path.join(self.environment.get_build_dir(), src)) header_deps.append(raw_src) @@ -415,7 +412,6 @@ def generate_target(self, target, outfile): # Generate compile targets for all the pre-existing sources for this target for f, src in target_sources.items(): if not self.environment.is_header(src): - src_list.append(src) if self.environment.is_llvm_ir(src): obj_list.append(self.generate_llvm_ir_compile(target, outfile, src)) elif is_unity and self.get_target_source_can_unity(target, src): @@ -428,7 +424,7 @@ def generate_target(self, target, outfile): if is_unity: for src in self.generate_unity_files(target, unity_src): obj_list.append(self.generate_single_compile(target, outfile, RawFilename(src), True, unity_deps + header_deps)) - linker = self.determine_linker(target, src_list + generated_output_sources) + linker = self.determine_linker(target) elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) self.generate_shlib_aliases(target, self.get_target_dir(target)) elem.write(outfile) @@ -970,7 +966,8 @@ def generate_vala_compile(self, target, outfile): (vala_src, vapi_src, other_src) = self.split_vala_sources(target) extra_dep_files = [] if len(vala_src) == 0: - raise InvalidArguments('Vala library has no Vala source files.') + msg = 'Vala library {!r} has no Vala source files.' + raise InvalidArguments(msg.format(target.name)) valac = target.compilers['vala'] c_out_dir = self.get_target_private_dir(target) @@ -1210,7 +1207,7 @@ def generate_swift_target(self, target, outfile): raise MesonException('Swift supports only executable and static library targets.') def generate_static_link_rules(self, is_cross, outfile): - if self.build.has_language('java'): + if 'java' in self.build.compilers: if not is_cross: self.generate_java_link(outfile) if is_cross: @@ -1251,8 +1248,7 @@ def generate_dynamic_link_rules(self, outfile): else: ctypes.append((self.build.cross_compilers, True)) for (complist, is_cross) in ctypes: - for compiler in complist: - langname = compiler.get_language() + for langname, compiler in complist.items(): if langname == 'java' or langname == 'vala' or\ langname == 'rust' or langname == 'cs': continue @@ -1511,8 +1507,7 @@ def generate_pch_rule_for(self, langname, compiler, qstr, is_cross, outfile): def generate_compile_rules(self, outfile): qstr = quote_char + "%s" + quote_char - for compiler in self.build.compilers: - langname = compiler.get_language() + for langname, compiler in self.build.compilers.items(): if compiler.get_id() == 'clang': self.generate_llvm_ir_compile_rule(compiler, False, outfile) self.generate_compile_rule_for(langname, compiler, qstr, False, outfile) @@ -1524,8 +1519,7 @@ def generate_compile_rules(self, outfile): cclist = self.build.cross_compilers else: cclist = self.build.compilers - for compiler in cclist: - langname = compiler.get_language() + for langname, compiler in cclist.items(): if compiler.get_id() == 'clang': self.generate_llvm_ir_compile_rule(compiler, True, outfile) self.generate_compile_rule_for(langname, compiler, qstr, True, outfile) @@ -1588,8 +1582,8 @@ def generate_genlist_for_target(self, genlist, target, outfile): def scan_fortran_module_outputs(self, target): compiler = None - for c in self.build.compilers: - if c.get_language() == 'fortran': + for lang, c in self.build.compilers.items(): + if lang == 'fortran': compiler = c break if compiler is None: diff --git a/mesonbuild/build.py b/mesonbuild/build.py --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -19,6 +19,7 @@ import copy, os, re from .mesonlib import File, flatten, MesonException, stringlistify, classify_unity_sources from .environment import for_windows, for_darwin +from .compilers import is_object, clike_langs, lang_suffixes known_basic_kwargs = {'install' : True, 'c_pch' : True, @@ -62,17 +63,6 @@ 'pic' : True, # Only for static libs }) -def compilers_are_msvc(compilers): - """ - Check if all the listed compilers are MSVC. Used by Executable, - StaticLibrary, and SharedLibrary for deciding when to use MSVC-specific - file naming. - """ - for compiler in compilers.values(): - if compiler.get_id() != 'msvc': - return False - return True - class InvalidArguments(MesonException): pass @@ -88,8 +78,8 @@ def __init__(self, environment): self.environment = environment self.projects = {} self.targets = {} - self.compilers = [] - self.cross_compilers = [] + self.compilers = {} + self.cross_compilers = {} self.global_args = {} self.projects_args = {} self.global_link_args = {} @@ -109,26 +99,19 @@ def __init__(self, environment): self.dep_manifest = {} self.cross_stdlibs = {} - def has_language(self, language): - for i in self.compilers: - if i.get_language() == language: - return True - return False - def add_compiler(self, compiler): if self.static_linker is None and compiler.needs_static_linker(): self.static_linker = self.environment.detect_static_linker(compiler) - if self.has_language(compiler.get_language()): - return - self.compilers.append(compiler) + lang = compiler.get_language() + if lang not in self.compilers: + self.compilers[lang] = compiler def add_cross_compiler(self, compiler): if len(self.cross_compilers) == 0: self.static_cross_linker = self.environment.detect_static_linker(compiler) - for i in self.cross_compilers: - if i.get_language() == compiler.get_language(): - return - self.cross_compilers.append(compiler) + lang = compiler.get_language() + if lang not in self.cross_compilers: + self.cross_compilers[lang] = compiler def get_project(self): return self.projects[''] @@ -204,6 +187,10 @@ def __init__(self, target, srclist, is_unity): if is_unity: self.check_unity_compatible() + def __repr__(self): + r = '<{0} {1!r}: {2}>' + return r.format(self.__class__.__name__, self.target.name, self.srclist) + def check_unity_compatible(self): # Figure out if the extracted object list is compatible with a Unity # build. When we're doing a Unified build, we go through the sources, @@ -290,7 +277,14 @@ def __init__(self, name, subdir, subproject, is_cross, sources, objects, environ self.extra_args = {} self.generated = [] self.extra_files = [] + # Sources can be: + # 1. Pre-existing source files in the source tree + # 2. Pre-existing sources generated by configure_file in the build tree + # 3. Sources files generated by another target or a Generator self.process_sourcelist(sources) + # Objects can be: + # 1. Pre-existing objects provided by the user with the `objects:` kwarg + # 2. Compiled objects created by and extracted from another target self.process_objectlist(objects) self.process_kwargs(kwargs, environment) self.check_unknown_kwargs(kwargs) @@ -333,7 +327,7 @@ def process_objectlist(self, objects): for s in objects: if hasattr(s, 'held_object'): s = s.held_object - if isinstance(s, (str, ExtractedObjects)): + if isinstance(s, (str, File, ExtractedObjects)): self.objects.append(s) elif isinstance(s, (GeneratedList, CustomTarget)): msg = 'Generated files are not allowed in the \'objects\' kwarg ' + \ @@ -380,19 +374,56 @@ def can_compile_remove_sources(compiler, sources): return removed def process_compilers(self): - if len(self.sources) + len(self.generated) == 0: + ''' + Populate self.compilers, which is the list of compilers that this + target will use for compiling all its sources. + We also add compilers that were used by extracted objects to simplify + dynamic linker determination. + ''' + if len(self.sources) + len(self.generated) + len(self.objects) == 0: return - sources = list(self.sources) - for gensrc in self.generated: - sources += gensrc.get_outputs() # Populate list of compilers if self.is_cross: compilers = self.environment.coredata.cross_compilers else: compilers = self.environment.coredata.compilers - for lang, compiler in compilers.items(): - if self.can_compile_sources(compiler, sources): - self.compilers[lang] = compiler + # Pre-existing sources + sources = list(self.sources) + # All generated sources + for gensrc in self.generated: + for s in gensrc.get_outputs(): + # Generated objects can't be compiled, so don't use them for + # compiler detection. If our target only has generated objects, + # we will fall back to using the first c-like compiler we find, + # which is what we need. + if not is_object(s): + sources.append(s) + # Sources that were used to create our extracted objects + for o in self.objects: + if not isinstance(o, ExtractedObjects): + continue + for s in o.srclist: + # Don't add Vala sources since that will pull in the Vala + # compiler even though we will never use it since we are + # dealing with compiled C code. + if not s.endswith(lang_suffixes['vala']): + sources.append(s) + if sources: + # Add compilers based on the above sources + for lang, compiler in compilers.items(): + # We try to be conservative because sometimes people add files + # in the list of sources that we can't determine the type based + # just on the suffix. + if self.can_compile_sources(compiler, sources): + self.compilers[lang] = compiler + else: + # No source files, target consists of only object files of unknown + # origin. Just add the first clike compiler that we have and hope + # that it can link these objects + for lang in clike_langs: + if lang in compilers: + self.compilers[lang] = compilers[lang] + break # If all our sources are Vala, our target also needs the C compiler but # it won't get added above. if 'vala' in self.compilers and 'c' not in self.compilers: @@ -766,6 +797,43 @@ def add_compiler_args(self, language, args): def get_aliaslist(self): return [] + def get_clike_dynamic_linker(self): + ''' + We use the order of languages in `clike_langs` to determine which + linker to use in case the target has sources compiled with multiple + compilers. All languages other than those in this list have their own + linker. + Note that Vala outputs C code, so Vala sources can use any linker + that can link compiled C. We don't actually need to add an exception + for Vala here because of that. + ''' + for l in clike_langs: + if l in self.compilers: + return self.compilers[l] + + def get_using_msvc(self): + ''' + Check if the dynamic linker is MSVC. Used by Executable, StaticLibrary, + and SharedLibrary for deciding when to use MSVC-specific file naming + and debug filenames. + + If at least some code is built with MSVC and the final library is + linked with MSVC, we can be sure that some debug info will be + generated. We only check the dynamic linker here because the static + linker is guaranteed to be of the same type. + + Interesting cases: + 1. The Vala compiler outputs C code to be compiled by whatever + C compiler we're using, so all objects will still be created by the + MSVC compiler. + 2. If the target contains only objects, process_compilers guesses and + picks the first compiler that smells right. + ''' + linker = self.get_clike_dynamic_linker() + if linker and linker.get_id() == 'msvc': + return True + return False + class Generator(): def __init__(self, args, kwargs): @@ -890,7 +958,7 @@ def __init__(self, name, subdir, subproject, is_cross, sources, objects, environ self.filename += '.' + self.suffix # See determine_debug_filenames() in build.SharedLibrary buildtype = environment.coredata.get_builtin_option('buildtype') - if compilers_are_msvc(self.compilers) and buildtype.startswith('debug'): + if self.get_using_msvc() and buildtype.startswith('debug'): self.debug_filename = self.prefix + self.name + '.pdb' def type_suffix(self): @@ -921,7 +989,7 @@ def __init__(self, name, subdir, subproject, is_cross, sources, objects, environ self.filename = self.prefix + self.name + '.' + self.suffix # See determine_debug_filenames() in build.SharedLibrary buildtype = environment.coredata.get_builtin_option('buildtype') - if compilers_are_msvc(self.compilers) and buildtype.startswith('debug'): + if self.get_using_msvc() and buildtype.startswith('debug'): self.debug_filename = self.prefix + self.name + '.pdb' def type_suffix(self): @@ -997,7 +1065,7 @@ def determine_filenames(self, is_cross, env): suffix = 'dll' self.vs_import_filename = '{0}.lib'.format(self.name) self.gcc_import_filename = 'lib{0}.dll.a'.format(self.name) - if compilers_are_msvc(self.compilers): + if self.get_using_msvc(): # Shared library is of the form foo.dll prefix = '' # Import library is called foo.lib @@ -1044,7 +1112,7 @@ def determine_debug_filenames(self, is_cross, env): determine_filenames() above. """ buildtype = env.coredata.get_builtin_option('buildtype') - if compilers_are_msvc(self.compilers) and buildtype.startswith('debug'): + if self.get_using_msvc() and buildtype.startswith('debug'): # Currently we only implement separate debug symbol files for MSVC # since the toolchain does it for us. Other toolchains embed the # debugging symbols in the file itself by default. diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -45,8 +45,15 @@ } cpp_suffixes = lang_suffixes['cpp'] + ('h',) c_suffixes = lang_suffixes['c'] + ('h',) -clike_suffixes = lang_suffixes['c'] + lang_suffixes['cpp'] + ('h',) - +# List of languages that can be linked with C code directly by the linker +# used in build.py:process_compilers() and build.py:get_dynamic_linker() +clike_langs = ('objcpp', 'objc', 'd', 'cpp', 'c', 'fortran',) +clike_suffixes = () +for l in clike_langs: + clike_suffixes += lang_suffixes[l] +clike_suffixes += ('h',) + +# These are used in backend/backends.py:generated_target() def is_header(fname): if hasattr(fname, 'fname'): fname = fname.fname diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1074,9 +1074,8 @@ def get_compiler_method(self, args, kwargs): clist = self.build.compilers else: clist = self.build.cross_compilers - for c in clist: - if c.get_language() == cname: - return CompilerHolder(c, self.build.environment) + if cname in clist: + return CompilerHolder(clist[cname], self.build.environment) raise InterpreterException('Tried to access compiler for unspecified language "%s".' % cname) def is_unity_method(self, args, kwargs): @@ -1254,8 +1253,7 @@ def get_variables(self): def check_cross_stdlibs(self): if self.build.environment.is_cross_build(): cross_info = self.build.environment.cross_info - for c in self.build.cross_compilers: - l = c.language + for l, c in self.build.cross_compilers.items(): try: di = mesonlib.stringlistify(cross_info.get_stdlib(l)) if len(di) != 2: @@ -2287,9 +2285,9 @@ def build_target(self, node, args, kwargs, targetholder): def get_used_languages(self, target): result = {} for i in target.sources: - for c in self.build.compilers: + for lang, c in self.build.compilers.items(): if c.can_compile(i): - result[c.language] = True + result[lang] = True break return result diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -526,7 +526,7 @@ def reduce_arguments(self, args): def flatten(self, args): if isinstance(args, mparser.StringNode): return args.value - if isinstance(args, (int, str, InterpreterObject)): + if isinstance(args, (int, str, mesonlib.File, InterpreterObject)): return args result = [] for a in args: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -433,11 +433,11 @@ def generate_gir(self, state, args, kwargs): cflags += state.global_args['c'] if state.project_args.get('c'): cflags += state.project_args['c'] - for compiler in state.compilers: - if compiler.get_language() == 'c': - sanitize = compiler.get_options().get('b_sanitize') - if sanitize: - cflags += compilers.sanitizer_compile_args(sanitize) + if 'c' in state.compilers: + compiler = state.compilers['c'] + sanitize = compiler.get_options().get('b_sanitize') + if sanitize: + cflags += compilers.sanitizer_compile_args(sanitize) if cflags: scan_command += ['--cflags-begin'] scan_command += cflags diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py --- a/mesonbuild/modules/rpm.py +++ b/mesonbuild/modules/rpm.py @@ -27,7 +27,7 @@ class RPMModule: def generate_spec_template(self, state, args, kwargs): compiler_deps = set() - for compiler in state.compilers: + for compiler in state.compilers.values(): if isinstance(compiler, compilers.GnuCCompiler): compiler_deps.add('gcc') elif isinstance(compiler, compilers.GnuCPPCompiler): diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py --- a/mesonbuild/modules/windows.py +++ b/mesonbuild/modules/windows.py @@ -19,9 +19,9 @@ class WindowsModule: def detect_compiler(self, compilers): - for c in compilers: - if c.language == 'c' or c.language == 'cpp': - return c + for l in ('c', 'cpp'): + if l in compilers: + return compilers[l] raise MesonException('Resource compilation requires a C or C++ compiler.') def compile_resources(self, state, args, kwargs):
Install target fails with foo.extract_all_objects() on debug builds due to missing pdb files Hey `ninja install` fails on linux due to missing `.pdb` files if I use `foo.extract_all_objects()`. See the following meson.build file: ``` project('foobar', 'c', default_options: [ 'buildtype=debug' ]) foo = static_library('foo', ['foo.c'], pic: true) bar = shared_library('bar', objects: foo.extract_all_objects(), install: true) ``` The foo.c source file can be an empty file (or just some dummy). Building this works fine, but a `ninja install` fails (see the log below). If I use a non-debug buildtype it works (i.e., `debug` and `debugoptimized` fail). Same result on git-master. I only tested on linux. If I specify the source files in the shared-lib directly, rather than using the object-files from the static-lib, then it works. Thanks David ``` $ DESTDIR=foo ninja -C build/ install ninja: Entering directory `build/' [0/1] Installing files. Installing libbar.pdb to foo/usr/local/lib/libbar.pdb Traceback (most recent call last): File "/usr/bin/meson", line 26, in <module> sys.exit(main()) File "/usr/bin/meson", line 23, in main return mesonmain.run(launcher, sys.argv[1:]) File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 249, in run sys.exit(run_script_command(args[1:])) File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 239, in run_script_command return cmdfunc(cmdargs) File "/usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py", line 251, in run do_install(datafilename) File "/usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py", line 54, in do_install install_targets(d) File "/usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py", line 205, in install_targets do_copy(fname, outname) File "/usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py", line 36, in do_copy shutil.copyfile(from_file, to_file) File "/usr/lib/python3.5/shutil.py", line 114, in copyfile with open(src, 'rb') as fsrc: FileNotFoundError: [Errno 2] No such file or directory: 'libbar.pdb' FAILED: install '/usr/bin/python3' '/usr/bin/meson' '--internal' 'install' '/home/FOOBAR/build/meson-private/install.dat' ninja: build stopped: subcommand failed. ```
Pdb files should only be used when compiling with Visual Studio so this is strange. Are you cross compiling or is this a native Linux build? Native build. This is hilarious and probably my fault. I can reproduce it. I guess object extraction has been totally broken since 0.36. I can see what the problem is, and there's a lot of breakage in here. Working on a PR.
2016-12-09T08:15:46Z
[]
[]
Traceback (most recent call last): File "/usr/bin/meson", line 26, in <module> sys.exit(main()) File "/usr/bin/meson", line 23, in main return mesonmain.run(launcher, sys.argv[1:]) File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 249, in run sys.exit(run_script_command(args[1:])) File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 239, in run_script_command return cmdfunc(cmdargs) File "/usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py", line 251, in run do_install(datafilename) File "/usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py", line 54, in do_install install_targets(d) File "/usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py", line 205, in install_targets do_copy(fname, outname) File "/usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py", line 36, in do_copy shutil.copyfile(from_file, to_file) File "/usr/lib/python3.5/shutil.py", line 114, in copyfile with open(src, 'rb') as fsrc: FileNotFoundError: [Errno 2] No such file or directory: 'libbar.pdb'
8,848
mesonbuild/meson
mesonbuild__meson-11982
b92858a5beba687478e56850269bc89bc61b3954
diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py --- a/mesonbuild/interpreter/compiler.py +++ b/mesonbuild/interpreter/compiler.py @@ -448,9 +448,12 @@ def get_define_method(self, args: T.Tuple[str], kwargs: 'CommonKW') -> str: def compiles_method(self, args: T.Tuple['mesonlib.FileOrString'], kwargs: 'CompileKW') -> bool: code = args[0] if isinstance(code, mesonlib.File): + if code.is_built: + FeatureNew.single_use('compiler.compiles with file created at setup time', '1.2.0', self.subproject, + 'It was broken and either errored or returned false.', self.current_node) self.interpreter.add_build_def_file(code) code = mesonlib.File.from_absolute_file( - code.rel_to_builddir(self.environment.source_dir)) + code.absolute_path(self.environment.source_dir, self.environment.build_dir)) testname = kwargs['name'] extra_args = functools.partial(self._determine_args, kwargs['no_builtin_args'], kwargs['include_directories'], kwargs['args']) deps, msg = self._determine_dependencies(kwargs['dependencies'], endl=None) @@ -472,9 +475,12 @@ def links_method(self, args: T.Tuple['mesonlib.FileOrString'], kwargs: 'CompileK code = args[0] compiler = None if isinstance(code, mesonlib.File): + if code.is_built: + FeatureNew.single_use('compiler.links with file created at setup time', '1.2.0', self.subproject, + 'It was broken and either errored or returned false.', self.current_node) self.interpreter.add_build_def_file(code) code = mesonlib.File.from_absolute_file( - code.rel_to_builddir(self.environment.source_dir)) + code.absolute_path(self.environment.source_dir, self.environment.build_dir)) suffix = code.suffix if suffix not in self.compiler.file_suffixes: for_machine = self.compiler.for_machine
compiler.compiles and compiler.links do not accept files generated by configure_file **Describe the bug** Trying to use a file generated by `configure_file` with `compiler.compiles` or `compiler.links` results in the following wall: ``` Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/mesonbuild/mesonmain.py", line 194, in run return options.run_func(options) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/msetup.py", line 318, in run app.generate() File "/usr/local/lib/python3.11/site-packages/mesonbuild/msetup.py", line 194, in generate self._generate(env) File "/usr/local/lib/python3.11/site-packages/mesonbuild/msetup.py", line 239, in _generate intr.run() File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreter/interpreter.py", line 2971, in run super().run() File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 164, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 190, in evaluate_codeblock raise e File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 228, in evaluate_statement self.evaluate_foreach(cur) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 472, in evaluate_foreach self.evaluate_codeblock(node.block) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 190, in evaluate_codeblock raise e File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 206, in evaluate_statement return self.evaluate_if(cur) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 301, in evaluate_if self.evaluate_codeblock(i.block) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 190, in evaluate_codeblock raise e File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 200, in evaluate_statement return self.method_call(cur) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 537, in method_call (h_args, h_kwargs) = self.reduce_arguments(node.args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 593, in reduce_arguments reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 593, in <listcomp> reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 200, in evaluate_statement return self.method_call(cur) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 550, in method_call res = obj.method_call(method_name, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/baseobjects.py", line 94, in method_call return method(args, kwargs) ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper return f(*nargs, **wrapped_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/decorators.py", line 596, in wrapper return f(*wrapped_args, **wrapped_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreter/compiler.py", line 457, in compiles_method result, cached = self.compiler.compiles(code, self.environment, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/compilers/compilers.py", line 1287, in compiles with self._build_wrapper(code, env, extra_args, dependencies, mode, disable_cache=disable_cache) as p: File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/compilers/compilers.py", line 1279, in _build_wrapper with self.cached_compile(code, env.coredata, extra_args=args, mode=mode, temp_dir=env.scratch_dir) as r: File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/compilers/compilers.py", line 887, in cached_compile with self.compile(code, extra_args=extra_args, mode=mode, want_output=False, temp_dir=temp_dir) as p: File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/compilers/compilers.py", line 826, in compile with open(code.fname, encoding='utf-8') as f: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'armv8_external.S' ``` **To Reproduce** ```meson project('test', 'c') python3 = import('python').find_installation() cc = meson.get_compiler('c') f = configure_file( command: [python3, '-c', 'import sys; print(sys.argv[1])', '@0@'.format('prfm pldl1strm, [x0]')], input: 'meson.build', output: 'armv8_external.S', capture: true, ) cc.compiles( f, args: ['-x', 'assembler'], name: 'should succeed under arm64' ) ``` This should be easy to fix by replacing the following: https://github.com/mesonbuild/meson/blob/b92858a5beba687478e56850269bc89bc61b3954/mesonbuild/interpreter/compiler.py#L288-L291 with ```py if isinstance(code, mesonlib.File): self.interpreter.add_build_def_file(code) code = mesonlib.File.from_absolute_file( code.absolute_path(self.environment.source_dir, self.environment.build_dir)) ``` **Expected behavior** The check should run against the supplied file. **system parameters** * Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)? **Cross build** * what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) **macOS Big Sur 11.7.8** * what Python version are you using e.g. 3.8.0 **3.8.11** * what `meson --version` **1.1.1** * what `ninja --version` if it's a Ninja build **1.11.1** cc @eli-schwartz for reference
2023-07-13T23:57:20Z
[]
[]
Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/mesonbuild/mesonmain.py", line 194, in run return options.run_func(options) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/msetup.py", line 318, in run app.generate() File "/usr/local/lib/python3.11/site-packages/mesonbuild/msetup.py", line 194, in generate self._generate(env) File "/usr/local/lib/python3.11/site-packages/mesonbuild/msetup.py", line 239, in _generate intr.run() File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreter/interpreter.py", line 2971, in run super().run() File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 164, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 190, in evaluate_codeblock raise e File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 228, in evaluate_statement self.evaluate_foreach(cur) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 472, in evaluate_foreach self.evaluate_codeblock(node.block) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 190, in evaluate_codeblock raise e File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 206, in evaluate_statement return self.evaluate_if(cur) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 301, in evaluate_if self.evaluate_codeblock(i.block) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 190, in evaluate_codeblock raise e File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 200, in evaluate_statement return self.method_call(cur) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 537, in method_call (h_args, h_kwargs) = self.reduce_arguments(node.args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 593, in reduce_arguments reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 593, in <listcomp> reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 200, in evaluate_statement return self.method_call(cur) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 550, in method_call res = obj.method_call(method_name, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/baseobjects.py", line 94, in method_call return method(args, kwargs) ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper return f(*nargs, **wrapped_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreterbase/decorators.py", line 596, in wrapper return f(*wrapped_args, **wrapped_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/interpreter/compiler.py", line 457, in compiles_method result, cached = self.compiler.compiles(code, self.environment, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/compilers/compilers.py", line 1287, in compiles with self._build_wrapper(code, env, extra_args, dependencies, mode, disable_cache=disable_cache) as p: File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/compilers/compilers.py", line 1279, in _build_wrapper with self.cached_compile(code, env.coredata, extra_args=args, mode=mode, temp_dir=env.scratch_dir) as r: File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/compilers/compilers.py", line 887, in cached_compile with self.compile(code, extra_args=extra_args, mode=mode, want_output=False, temp_dir=temp_dir) as p: File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mesonbuild/compilers/compilers.py", line 826, in compile with open(code.fname, encoding='utf-8') as f: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'armv8_external.S'
8,869
mesonbuild/meson
mesonbuild__meson-12038
1a182ab59919d4838613f9d1962623447636663e
diff --git a/packaging/hook-mesonbuild.py b/packaging/hook-mesonbuild.py --- a/packaging/hook-mesonbuild.py +++ b/packaging/hook-mesonbuild.py @@ -25,7 +25,11 @@ def get_all_modules_from_dir(dirname): datas += collect_data_files('mesonbuild.cmake.data') datas += collect_data_files('mesonbuild.dependencies.data') +# lazy-loaded +hiddenimports += get_all_modules_from_dir('mesonbuild/dependencies') +# imported by meson.build files hiddenimports += get_all_modules_from_dir('mesonbuild/modules') +# executed when named on CLI hiddenimports += get_all_modules_from_dir('mesonbuild/scripts') # Python packagers want to be minimal and only copy the things
Regression: "No module named 'mesonbuild.dependencies.ui'" in Windows MSI version **Describe the bug** Using the 1.2.0 MSI, the module 'mesonbuild.dependencies.ui' is missing, while it seems to be available in 1.1.1 **To Reproduce** Minimal meson.build (bug also appears if there is an actual `executable()` line): ```meson project('bug', 'c') dependency('sdl2') ``` ```cmd > md subprojects > meson wrap install sdl2 > meson setup build The Meson build system Version: 1.2.0 Source dir: F:\bug Build dir: F:\bug\build Build type: native build Project name: bug Project version: undefined C compiler for the host machine: cl (msvc 19.36.32537 "Microsoft (R) C/C++-Optimierungscompiler Version 19.36.32537 f�r x64") C linker for the host machine: link link 14.36.32537.0 Host machine cpu family: x86_64 Host machine cpu: x86_64 Traceback (most recent call last): File "mesonbuild\mesonmain.py", line 194, in run File "mesonbuild\msetup.py", line 358, in run File "mesonbuild\msetup.py", line 183, in generate File "mesonbuild\msetup.py", line 228, in _generate File "mesonbuild\interpreter\interpreter.py", line 2997, in run File "mesonbuild\interpreterbase\interpreterbase.py", line 164, in run File "mesonbuild\interpreterbase\interpreterbase.py", line 190, in evaluate_codeblock File "mesonbuild\interpreterbase\interpreterbase.py", line 182, in evaluate_codeblock File "mesonbuild\interpreterbase\interpreterbase.py", line 196, in evaluate_statement File "mesonbuild\interpreterbase\interpreterbase.py", line 521, in function_call File "mesonbuild\interpreterbase\decorators.py", line 826, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 826, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 826, in wrapped [Previous line repeated 4 more times] File "mesonbuild\interpreterbase\decorators.py", line 109, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 127, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 277, in wrapper File "mesonbuild\interpreterbase\decorators.py", line 596, in wrapper File "mesonbuild\interpreter\interpreter.py", line 1774, in func_dependency File "mesonbuild\interpreter\dependencyfallbacks.py", line 355, in lookup File "mesonbuild\interpreter\dependencyfallbacks.py", line 87, in _do_dependency File "mesonbuild\dependencies\detect.py", line 115, in find_external_dependency File "mesonbuild\dependencies\detect.py", line 193, in _build_external_dependency_list File "collections\__init__.py", line 1123, in __getitem__ File "mesonbuild\dependencies\detect.py", line 39, in __missing__ File "importlib\__init__.py", line 126, in import_module File "<frozen importlib._bootstrap>", line 1204, in _gcd_import File "<frozen importlib._bootstrap>", line 1176, in _find_and_load File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked ModuleNotFoundError: No module named 'mesonbuild.dependencies.ui' meson.build:3:0: ERROR: Unhandled python exception This is a Meson bug and should be reported! ``` **Expected behavior** setup step should complete successfully, like it does with 1.1.1 **system parameters** * Plain native build * Windows 10 * System Python is 3.11.0, * meson 1.2.0 * ninja 1.11.1
2023-07-25T17:30:04Z
[]
[]
Traceback (most recent call last): File "mesonbuild\mesonmain.py", line 194, in run File "mesonbuild\msetup.py", line 358, in run File "mesonbuild\msetup.py", line 183, in generate File "mesonbuild\msetup.py", line 228, in _generate File "mesonbuild\interpreter\interpreter.py", line 2997, in run File "mesonbuild\interpreterbase\interpreterbase.py", line 164, in run File "mesonbuild\interpreterbase\interpreterbase.py", line 190, in evaluate_codeblock File "mesonbuild\interpreterbase\interpreterbase.py", line 182, in evaluate_codeblock File "mesonbuild\interpreterbase\interpreterbase.py", line 196, in evaluate_statement File "mesonbuild\interpreterbase\interpreterbase.py", line 521, in function_call File "mesonbuild\interpreterbase\decorators.py", line 826, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 826, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 826, in wrapped [Previous line repeated 4 more times] File "mesonbuild\interpreterbase\decorators.py", line 109, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 127, in wrapped File "mesonbuild\interpreterbase\decorators.py", line 277, in wrapper File "mesonbuild\interpreterbase\decorators.py", line 596, in wrapper File "mesonbuild\interpreter\interpreter.py", line 1774, in func_dependency File "mesonbuild\interpreter\dependencyfallbacks.py", line 355, in lookup File "mesonbuild\interpreter\dependencyfallbacks.py", line 87, in _do_dependency File "mesonbuild\dependencies\detect.py", line 115, in find_external_dependency File "mesonbuild\dependencies\detect.py", line 193, in _build_external_dependency_list File "collections\__init__.py", line 1123, in __getitem__ File "mesonbuild\dependencies\detect.py", line 39, in __missing__ File "importlib\__init__.py", line 126, in import_module File "<frozen importlib._bootstrap>", line 1204, in _gcd_import File "<frozen importlib._bootstrap>", line 1176, in _find_and_load File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked ModuleNotFoundError: No module named 'mesonbuild.dependencies.ui'
8,872
mesonbuild/meson
mesonbuild__meson-1205
411e88a5ab06dfdc6817c03f7dc96defc3a5d6aa
diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py --- a/mesonbuild/scripts/meson_install.py +++ b/mesonbuild/scripts/meson_install.py @@ -28,16 +28,55 @@ def append_to_log(line): install_log_file.write('\n') install_log_file.flush() -def do_copy(from_file, to_file): - try: - # Python's copyfile fails if the target file already exists. +def do_copyfile(from_file, to_file): + if not os.path.isfile(from_file): + raise RuntimeError('Tried to install something that isn\'t a file:' + '{!r}'.format(from_file)) + # copyfile fails if the target file already exists, so remove it to + # allow overwriting a previous install. If the target is not a file, we + # want to give a readable error. + if os.path.exists(to_file): + if not os.path.isfile(to_file): + raise RuntimeError('Destination {!r} already exists and is not ' + 'a file'.format(to_file)) os.unlink(to_file) - except FileNotFoundError: - pass shutil.copyfile(from_file, to_file) shutil.copystat(from_file, to_file) append_to_log(to_file) +def do_copydir(src_prefix, src_dir, dst_dir): + ''' + Copies the directory @src_prefix (full path) into @dst_dir + + @src_dir is simply the parent directory of @src_prefix + ''' + for root, dirs, files in os.walk(src_prefix): + for d in dirs: + abs_src = os.path.join(src_dir, root, d) + filepart = abs_src[len(src_dir)+1:] + abs_dst = os.path.join(dst_dir, filepart) + if os.path.isdir(abs_dst): + continue + if os.path.exists(abs_dst): + print('Tried to copy directory %s but a file of that name already exists.' % abs_dst) + sys.exit(1) + os.makedirs(abs_dst) + shutil.copystat(abs_src, abs_dst) + for f in files: + abs_src = os.path.join(src_dir, root, f) + filepart = abs_src[len(src_dir)+1:] + abs_dst = os.path.join(dst_dir, filepart) + if os.path.isdir(abs_dst): + print('Tried to copy file %s but a directory of that name already exists.' % abs_dst) + if os.path.exists(abs_dst): + os.unlink(abs_dst) + parent_dir = os.path.split(abs_dst)[0] + if not os.path.isdir(parent_dir): + os.mkdir(parent_dir) + shutil.copystat(os.path.split(abs_src)[0], parent_dir) + shutil.copy2(abs_src, abs_dst, follow_symlinks=False) + append_to_log(abs_dst) + def get_destdir_path(d, path): if os.path.isabs(path): output = destdir_join(d.destdir, path) @@ -67,32 +106,7 @@ def install_subdirs(data): dst_dir = get_destdir_path(data, dst_dir) if not os.path.exists(dst_dir): os.makedirs(dst_dir) - for root, dirs, files in os.walk(src_prefix): - for d in dirs: - abs_src = os.path.join(src_dir, root, d) - filepart = abs_src[len(src_dir)+1:] - abs_dst = os.path.join(dst_dir, filepart) - if os.path.isdir(abs_dst): - continue - if os.path.exists(abs_dst): - print('Tried to copy directory %s but a file of that name already exists.' % abs_dst) - sys.exit(1) - os.makedirs(abs_dst) - shutil.copystat(abs_src, abs_dst) - for f in files: - abs_src = os.path.join(src_dir, root, f) - filepart = abs_src[len(src_dir)+1:] - abs_dst = os.path.join(dst_dir, filepart) - if os.path.isdir(abs_dst): - print('Tried to copy file %s but a directory of that name already exists.' % abs_dst) - if os.path.exists(abs_dst): - os.unlink(abs_dst) - parent_dir = os.path.split(abs_dst)[0] - if not os.path.isdir(parent_dir): - os.mkdir(parent_dir) - shutil.copystat(os.path.split(abs_src)[0], parent_dir) - shutil.copy2(abs_src, abs_dst, follow_symlinks=False) - append_to_log(abs_dst) + do_copydir(src_prefix, src_dir, dst_dir) def install_data(d): for i in d.data: @@ -101,7 +115,7 @@ def install_data(d): outdir = os.path.split(outfilename)[0] os.makedirs(outdir, exist_ok=True) print('Installing %s to %s.' % (fullfilename, outdir)) - do_copy(fullfilename, outfilename) + do_copyfile(fullfilename, outfilename) def install_man(d): for m in d.man: @@ -117,7 +131,7 @@ def install_man(d): shutil.copystat(full_source_filename, outfilename) append_to_log(outfilename) else: - do_copy(full_source_filename, outfilename) + do_copyfile(full_source_filename, outfilename) def install_headers(d): for t in d.headers: @@ -127,7 +141,7 @@ def install_headers(d): outfilename = os.path.join(outdir, fname) print('Installing %s to %s' % (fname, outdir)) os.makedirs(outdir, exist_ok=True) - do_copy(fullfilename, outfilename) + do_copyfile(fullfilename, outfilename) def run_install_script(d): env = {'MESON_SOURCE_ROOT' : d.source_dir, @@ -203,15 +217,23 @@ def install_targets(d): install_rpath = t[4] print('Installing %s to %s' % (fname, outname)) os.makedirs(outdir, exist_ok=True) - do_copy(fname, outname) - if should_strip: - print('Stripping target') - ps, stdo, stde = Popen_safe(['strip', outname]) - if ps.returncode != 0: - print('Could not strip file.\n') - print('Stdout:\n%s\n' % stdo) - print('Stderr:\n%s\n' % stde) - sys.exit(1) + if not os.path.exists(fname): + raise RuntimeError('File {!r} could not be found'.format(fname)) + elif os.path.isfile(fname): + do_copyfile(fname, outname) + if should_strip: + print('Stripping target {!r}'.format(fname)) + ps, stdo, stde = Popen_safe(['strip', outname]) + if ps.returncode != 0: + print('Could not strip file.\n') + print('Stdout:\n%s\n' % stdo) + print('Stderr:\n%s\n' % stde) + sys.exit(1) + elif os.path.isdir(fname): + fname = os.path.join(d.build_dir, fname.rstrip('/')) + do_copydir(fname, os.path.dirname(fname), outdir) + else: + raise RuntimeError('Unknown file type for {!r}'.format(fname)) printed_symlink_error = False for alias in aliases: try: @@ -224,9 +246,10 @@ def install_targets(d): append_to_log(symlinkfilename) except (NotImplementedError, OSError): if not printed_symlink_error: - print("Symlink creation does not work on this platform.") + print("Symlink creation does not work on this platform. " + "Skipping all symlinking.") printed_symlink_error = True - if is_elf_platform(): + if is_elf_platform() and os.path.isfile(outname): try: e = depfixer.Elf(outname, False) e.fix_rpath(install_rpath)
Allow custom_target outputs to be directories Currently we allow this, but that directory can then not be installed: ``` Traceback (most recent call last): File "/home/nirbheek/projects/repositories/github/meson.git/meson.py", line 25, in <module> sys.exit(mesonmain.run(launcher, sys.argv[1:])) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/mesonmain.py", line 242, in run sys.exit(run_script_command(args[1:])) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/mesonmain.py", line 232, in run_script_command return cmdfunc(cmdargs) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/scripts/meson_install.py", line 251, in run do_install(datafilename) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/scripts/meson_install.py", line 54, in do_install install_targets(d) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/scripts/meson_install.py", line 205, in install_targets do_copy(fname, outname) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/scripts/meson_install.py", line 36, in do_copy shutil.copyfile(from_file, to_file) File "/usr/lib64/python3.5/shutil.py", line 114, in copyfile with open(src, 'rb') as fsrc: IsADirectoryError: [Errno 21] Is a directory: 'devhelp' FAILED: install ``` I can't think of a reason to not allow this. Found while investigating #890
wait. that's not all. as i wrote, valadoc will not only output the folder devhelp, but it will output `<outputdir>/<modulename>/<modulename>/` the deepest folder in the tree is the folder that then has to be installed to e.g. `/usr/local/share/devhelp/books/`, so it looks like `/usr/local/share/devhelp/books/<modulename>` in order to work. so it's not only that folders must be allowed, it would be nice to be able to pick a specific subfolder to be installed. For the specific case of valadoc, ideally we'd like to get native support for it (#894).
2016-12-16T22:07:04Z
[]
[]
Traceback (most recent call last): File "/home/nirbheek/projects/repositories/github/meson.git/meson.py", line 25, in <module> sys.exit(mesonmain.run(launcher, sys.argv[1:])) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/mesonmain.py", line 242, in run sys.exit(run_script_command(args[1:])) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/mesonmain.py", line 232, in run_script_command return cmdfunc(cmdargs) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/scripts/meson_install.py", line 251, in run do_install(datafilename) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/scripts/meson_install.py", line 54, in do_install install_targets(d) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/scripts/meson_install.py", line 205, in install_targets do_copy(fname, outname) File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/scripts/meson_install.py", line 36, in do_copy shutil.copyfile(from_file, to_file) File "/usr/lib64/python3.5/shutil.py", line 114, in copyfile with open(src, 'rb') as fsrc: IsADirectoryError: [Errno 21] Is a directory: 'devhelp'
8,873
mesonbuild/meson
mesonbuild__meson-12053
1cd16a7cc5a19b1d694f66d80f36f6ec4e119dcb
diff --git a/mesonbuild/build.py b/mesonbuild/build.py --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -2383,7 +2383,7 @@ def process_kwargs(self, kwargs): elif isinstance(path, File): # When passing a generated file. self.vs_module_defs = path - elif hasattr(path, 'get_filename'): + elif isinstance(path, CustomTarget): # When passing output of a Custom Target self.vs_module_defs = File.from_built_file(path.subdir, path.get_filename()) else: diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -807,7 +807,7 @@ def update_project_options(self, options: 'MutableKeyedOptionDictType') -> None: continue oldval = self.options[key] - if type(oldval) != type(value): + if type(oldval) is not type(value): self.options[key] = value elif oldval.choices != value.choices: # If the choices have changed, use the new value, but attempt diff --git a/mesonbuild/interpreterbase/baseobjects.py b/mesonbuild/interpreterbase/baseobjects.py --- a/mesonbuild/interpreterbase/baseobjects.py +++ b/mesonbuild/interpreterbase/baseobjects.py @@ -119,12 +119,12 @@ def op_equals(self, other: TYPE_var) -> bool: # We use `type(...) == type(...)` here to enforce an *exact* match for comparison. We # don't want comparisons to be possible where `isinstance(derived_obj, type(base_obj))` # would pass because this comparison must never be true: `derived_obj == base_obj` - if type(self) != type(other): + if type(self) is not type(other): self._throw_comp_exception(other, '==') return self == other def op_not_equals(self, other: TYPE_var) -> bool: - if type(self) != type(other): + if type(self) is not type(other): self._throw_comp_exception(other, '!=') return self != other @@ -157,12 +157,12 @@ def display_name(self) -> str: # Override default comparison operators for the held object def op_equals(self, other: TYPE_var) -> bool: # See the comment from InterpreterObject why we are using `type()` here. - if type(self.held_object) != type(other): + if type(self.held_object) is not type(other): self._throw_comp_exception(other, '==') return self.held_object == other def op_not_equals(self, other: TYPE_var) -> bool: - if type(self.held_object) != type(other): + if type(self.held_object) is not type(other): self._throw_comp_exception(other, '!=') return self.held_object != other
"AttributeError: 'CustomTargetIndex' object has no attribute 'subdir'" **Describe the bug** Generated automatically. Please see #9646 for a detailed description. A minimal working example can be found below. .. ``` Traceback (most recent call last): File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\mesonmain.py", line 138, in run return options.run_func(options) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 294, in run app.generate() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 185, in generate self._generate(env) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 229, in _generate intr.run() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2484, in run super().run() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 148, in run self.evaluate_codeblock(self.ast, start=1) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 173, in evaluate_codeblock raise e File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 166, in evaluate_codeblock self.evaluate_statement(cur) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 179, in evaluate_statement return self.function_call(cur) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 454, in function_call res = func(node, func_args, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\decorators.py", line 621, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\decorators.py", line 115, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 1571, in func_shared_module return self.build_target(node, args, kwargs, build.SharedModule) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2686, in build_target target = targetclass(name, self.subdir, self.subproject, for_machine, sources, objs, self.environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 2236, in __init__ super().__init__(name, subdir, subproject, for_machine, sources, objects, environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 1925, in __init__ super().__init__(name, subdir, subproject, for_machine, sources, objects, environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 707, in __init__ self.process_kwargs(kwargs, environment) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 2152, in process_kwargs self.vs_module_defs = File.from_built_file(path.subdir, path.get_filename()) AttributeError: 'CustomTargetIndex' object has no attribute 'subdir' ``` **To Reproduce** ```meson project('generated', ['c', 'java']) obj = files('foo.c')[0] SCErwTxojo = [obj] owYpeLYJaV = 'RaUCqxQvxw' OzHKmfiEbV = 'foo.c' HJenacuQlf = true igLwJgLIMP = 'String' pNLTMorXKd = [ declare_dependency(), declare_dependency() ] wsDTRXXCuW = [ 'foo', 'bar' ] DEklHIyXjm = 'c' BbSaKXXoSz = [ static_library('iVWqkeOjpd', 'foo.c') ] mefgHKWUbM = [ static_library('AGatFiRJIT', 'foo.c') ] eYRZBVLjMH = true qINDilHqAD = [ include_directories('include'), 'include' ] XGosHGWDeM = true lkPXKnlfpa = 'String' DAaPAYFiet = 'rwxr-xr-x' yMJYBNXJNp = 'String' tmGrlmIhey = [ 'key1=value1', 'key2=value2' ] qzqWlSVXOg = '' arJsMzlRxh = include_directories('include') XstgqsLWrw = true GGFNMDOXTs = [ 'foo', 'bar' ] xZsaRyTkpe = [ 'foo', 'bar' ] NZlyPeunaG = true cqxMxAwohh = 'String' HKZcgqTUaA = 'String' YkKZtxuzAa = 'String' fKKGApxvZV = 'bar.txt' shared_module(owYpeLYJaV,OzHKmfiEbV,build_by_default : HJenacuQlf,build_rpath : igLwJgLIMP,dependencies : pNLTMorXKd,extra_files : SCErwTxojo,link_args : wsDTRXXCuW,link_depends : SCErwTxojo,link_language : DEklHIyXjm,link_whole : BbSaKXXoSz,link_with : mefgHKWUbM,implicit_include_directories : eYRZBVLjMH,include_directories : qINDilHqAD,install : XGosHGWDeM,install_dir : lkPXKnlfpa,install_mode : DAaPAYFiet,install_rpath : yMJYBNXJNp,objects : SCErwTxojo,override_options : tmGrlmIhey,gnu_symbol_visibility : qzqWlSVXOg,d_import_dirs : arJsMzlRxh,d_unittest : XstgqsLWrw,d_module_versions : GGFNMDOXTs,d_debug : xZsaRyTkpe,native : NZlyPeunaG,name_prefix : cqxMxAwohh,name_suffix : HKZcgqTUaA,rust_crate_type : YkKZtxuzAa,vs_module_defs : fKKGApxvZV) xWCTgZNWFX = 'LjRiXUeKGE' xkITHlZxbx = 'foo.c' mVpLXPaCvq = true GuCQVWhugn = 'String' CgHhsaQJKC = [ declare_dependency(), declare_dependency() ] LyXppJnWxD = [ 'foo', 'bar' ] kRsyjsZSoU = 'c' LjSdCduhlB = [ static_library('QkSswOgScq', 'foo.c') ] ckVMXFQRMh = [ static_library('raHNdVfmZd', 'foo.c') ] UdNJMcTLgI = true GfyRFcSCuR = [ include_directories('include'), 'include' ] VeikIWoWUs = true UbaLMOUbOR = 'String' ZidvAJilmj = 'rwxr-xr-x' OyLXbjMMnZ = 'String' QPTIxbRmKU = [ 'key1=value1', 'key2=value2' ] CpZxTVkllL = '' wiinCQwsLY = include_directories('include') OxwKOPCyrc = true SCrAKgYTYJ = [ 'foo', 'bar' ] XiZrTGChEQ = [ 'foo', 'bar' ] IBTrBtFnkV = true NRadNNUhEJ = 'String' QMlInPcLuM = 'String' nCNSabDmFm = 'String' shared_module(xWCTgZNWFX,xkITHlZxbx,build_by_default : mVpLXPaCvq,build_rpath : GuCQVWhugn,dependencies : CgHhsaQJKC,extra_files : SCErwTxojo,link_args : LyXppJnWxD,link_depends : SCErwTxojo,link_language : kRsyjsZSoU,link_whole : LjSdCduhlB,link_with : ckVMXFQRMh,implicit_include_directories : UdNJMcTLgI,include_directories : GfyRFcSCuR,install : VeikIWoWUs,install_dir : UbaLMOUbOR,install_mode : ZidvAJilmj,install_rpath : OyLXbjMMnZ,objects : SCErwTxojo,override_options : QPTIxbRmKU,gnu_symbol_visibility : CpZxTVkllL,d_import_dirs : wiinCQwsLY,d_unittest : OxwKOPCyrc,d_module_versions : SCrAKgYTYJ,d_debug : XiZrTGChEQ,native : IBTrBtFnkV,name_prefix : NRadNNUhEJ,name_suffix : QMlInPcLuM,rust_crate_type : nCNSabDmFm,vs_module_defs : obj) YYCbfTfLZs = 'BqujggRPqq' IEYbXUXyyN = 'foo.c' JyRyZMCblO = true cNhlYoraDn = 'String' tzJhCSIQYg = [ declare_dependency(), declare_dependency() ] mxaFTGdPwE = [ 'foo', 'bar' ] bNRjezazVQ = 'c' VpqsLAXRee = [ static_library('RhaOjDwNgT', 'foo.c') ] SjERxREaaw = [ static_library('BktGxYXOWZ', 'foo.c') ] vQrjRYsmXs = true LdYqzsfnwE = [ include_directories('include'), 'include' ] aDESLXiTVE = true MmfsxQOLuS = 'String' liujuYvNAB = 'rwxr-xr-x' LclIGiQWwm = 'String' FRrswrLOyG = [ 'key1=value1', 'key2=value2' ] DFxsgppoCt = '' YUasDynIZp = include_directories('include') KbwyupSByc = true rfSitiqUpt = [ 'foo', 'bar' ] mkPYqcXuCD = [ 'foo', 'bar' ] oHVSKRQoKN = true koUhemvYEU = 'String' LywHtZTrhN = 'String' QhCRsgCTin = 'String' AmgUPAqzqO = custom_target('jdJGNtajNB', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@']) shared_module(YYCbfTfLZs,IEYbXUXyyN,build_by_default : JyRyZMCblO,build_rpath : cNhlYoraDn,dependencies : tzJhCSIQYg,extra_files : SCErwTxojo,link_args : mxaFTGdPwE,link_depends : SCErwTxojo,link_language : bNRjezazVQ,link_whole : VpqsLAXRee,link_with : SjERxREaaw,implicit_include_directories : vQrjRYsmXs,include_directories : LdYqzsfnwE,install : aDESLXiTVE,install_dir : MmfsxQOLuS,install_mode : liujuYvNAB,install_rpath : LclIGiQWwm,objects : SCErwTxojo,override_options : FRrswrLOyG,gnu_symbol_visibility : DFxsgppoCt,d_import_dirs : YUasDynIZp,d_unittest : KbwyupSByc,d_module_versions : rfSitiqUpt,d_debug : mkPYqcXuCD,native : oHVSKRQoKN,name_prefix : koUhemvYEU,name_suffix : LywHtZTrhN,rust_crate_type : QhCRsgCTin,vs_module_defs : AmgUPAqzqO) YVFHdNKTFE = 'OFTNyipJTR' sXFKHfKYyN = 'foo.c' WevxOvVhYl = true HWYqrgJQJK = 'String' yTyMlOhXoT = [ declare_dependency(), declare_dependency() ] rWjZXDkcvl = [ 'foo', 'bar' ] GshhewVgrV = 'c' zfHdSfLtKo = [ static_library('RcHwnbZeRe', 'foo.c') ] aNCzEVbxod = [ static_library('xrVyXfLMuD', 'foo.c') ] zymHCULlMH = true NBJCrwAhbU = [ include_directories('include'), 'include' ] XoygHCWYOb = true OguPGiKUmI = 'String' lOFVPFROUI = 'rwxr-xr-x' RvVzwkfaOE = 'String' hRLUjIvMXK = [ 'key1=value1', 'key2=value2' ] QFMhCQbLCr = '' uegpmxFwcv = include_directories('include') bdSOwREUoW = true lFivNzyREv = [ 'foo', 'bar' ] XKbSMULKzs = [ 'foo', 'bar' ] rOvSyxTWQs = true waNJfKGBRZ = 'String' QjpNIPBdnY = 'String' xYEGtotSMN = 'String' KygXhWyqyC = custom_target('fVHufuNdLS', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] shared_module(YVFHdNKTFE,sXFKHfKYyN,build_by_default : WevxOvVhYl,build_rpath : HWYqrgJQJK,dependencies : yTyMlOhXoT,extra_files : SCErwTxojo,link_args : rWjZXDkcvl,link_depends : SCErwTxojo,link_language : GshhewVgrV,link_whole : zfHdSfLtKo,link_with : aNCzEVbxod,implicit_include_directories : zymHCULlMH,include_directories : NBJCrwAhbU,install : XoygHCWYOb,install_dir : OguPGiKUmI,install_mode : lOFVPFROUI,install_rpath : RvVzwkfaOE,objects : SCErwTxojo,override_options : hRLUjIvMXK,gnu_symbol_visibility : QFMhCQbLCr,d_import_dirs : uegpmxFwcv,d_unittest : bdSOwREUoW,d_module_versions : lFivNzyREv,d_debug : XKbSMULKzs,native : rOvSyxTWQs,name_prefix : waNJfKGBRZ,name_suffix : QjpNIPBdnY,rust_crate_type : xYEGtotSMN,vs_module_defs : KygXhWyqyC) SkslMXHPMv = 'rBabXNPsfa' cyfyhYdQHR = 'foo.c' njkfDioEaZ = true llBcEsvqwB = 'String' HeIHQKSFuF = [ declare_dependency(), declare_dependency() ] DDKPXzIrqG = [ 'foo', 'bar' ] wgrmHtmjBI = 'c' JBhohrdmGh = [ static_library('gWezZwvrmH', 'foo.c') ] xJTNiYrOHx = [ static_library('ivFrMOUKbE', 'foo.c') ] PgHwbfWalU = true fGiluJEneG = [ include_directories('include'), 'include' ] dphpPDOPXk = true IFeNHoaoec = 'String' QzCmpQujdA = 'rwxr-xr-x' zEyoMuYzcQ = 'String' mfAvXuUhUO = [ 'key1=value1', 'key2=value2' ] yhIiDfCeCp = '' GgjKLsDzRa = [ include_directories('include'), 'include' ] rzsQFrwNpG = true jFMTMvdvvI = [ 'foo', 'bar' ] dMAfxHqHLv = [ 'foo', 'bar' ] ZERIfjzcXm = true PsBiePFxtC = 'String' fPSRyIUBXg = 'String' iwwMfxYqMk = 'String' SAQRDkPhJl = 'bar.txt' shared_module(SkslMXHPMv,cyfyhYdQHR,build_by_default : njkfDioEaZ,build_rpath : llBcEsvqwB,dependencies : HeIHQKSFuF,extra_files : SCErwTxojo,link_args : DDKPXzIrqG,link_depends : SCErwTxojo,link_language : wgrmHtmjBI,link_whole : JBhohrdmGh,link_with : xJTNiYrOHx,implicit_include_directories : PgHwbfWalU,include_directories : fGiluJEneG,install : dphpPDOPXk,install_dir : IFeNHoaoec,install_mode : QzCmpQujdA,install_rpath : zEyoMuYzcQ,objects : SCErwTxojo,override_options : mfAvXuUhUO,gnu_symbol_visibility : yhIiDfCeCp,d_import_dirs : GgjKLsDzRa,d_unittest : rzsQFrwNpG,d_module_versions : jFMTMvdvvI,d_debug : dMAfxHqHLv,native : ZERIfjzcXm,name_prefix : PsBiePFxtC,name_suffix : fPSRyIUBXg,rust_crate_type : iwwMfxYqMk,vs_module_defs : SAQRDkPhJl) tvudvDVlGm = 'BKcmnkqAxX' vXXIOBAxzq = 'foo.c' tTORTMaRtu = true EbHqzpRhkI = 'String' WEtRgVEdxH = [ declare_dependency(), declare_dependency() ] utFMZSvPKS = [ 'foo', 'bar' ] VTvGaTvVhk = 'c' HLhwPbFGxK = [ static_library('OlCbLvkpnL', 'foo.c') ] oFqfFgSUwq = [ static_library('GfCmYviTGs', 'foo.c') ] deHTQCFPqf = true BlyFQoHKOB = [ include_directories('include'), 'include' ] qEpOiryWBL = true flqZmWdwiH = 'String' WleOgcYafk = 'rwxr-xr-x' POuVRdadsy = 'String' QEsOjkZuLY = [ 'key1=value1', 'key2=value2' ] aHpAIearjO = '' QIjvWdbKcd = [ include_directories('include'), 'include' ] YViOwcPsPZ = true arQeQBZFHh = [ 'foo', 'bar' ] YFTOWUZCdH = [ 'foo', 'bar' ] zYSWqOWrbB = true ZYlcilXRRJ = 'String' LJEtwHCUYP = 'String' llTlpRHrcs = 'String' shared_module(tvudvDVlGm,vXXIOBAxzq,build_by_default : tTORTMaRtu,build_rpath : EbHqzpRhkI,dependencies : WEtRgVEdxH,extra_files : SCErwTxojo,link_args : utFMZSvPKS,link_depends : SCErwTxojo,link_language : VTvGaTvVhk,link_whole : HLhwPbFGxK,link_with : oFqfFgSUwq,implicit_include_directories : deHTQCFPqf,include_directories : BlyFQoHKOB,install : qEpOiryWBL,install_dir : flqZmWdwiH,install_mode : WleOgcYafk,install_rpath : POuVRdadsy,objects : SCErwTxojo,override_options : QEsOjkZuLY,gnu_symbol_visibility : aHpAIearjO,d_import_dirs : QIjvWdbKcd,d_unittest : YViOwcPsPZ,d_module_versions : arQeQBZFHh,d_debug : YFTOWUZCdH,native : zYSWqOWrbB,name_prefix : ZYlcilXRRJ,name_suffix : LJEtwHCUYP,rust_crate_type : llTlpRHrcs,vs_module_defs : obj) dJrfMwOiJr = 'BXTSCDicRF' MicUrTxbTj = 'foo.c' tWicdaDgwh = true zPJJKWegkj = 'String' coxHZActkK = [ declare_dependency(), declare_dependency() ] gyezKdTIQt = [ 'foo', 'bar' ] tmMlzlznbr = 'c' MWfZomlcwh = [ static_library('MTAdwGVRCv', 'foo.c') ] HAiHLVwDBl = [ static_library('wQkDZhyWpM', 'foo.c') ] WpTUTGxdZS = true yVjwVTpCIf = [ include_directories('include'), 'include' ] EYqTmGlCRE = true rVqwfWbQSv = 'String' bBGFJlvFOR = 'rwxr-xr-x' LoTSClorXP = 'String' qhITyecMki = [ 'key1=value1', 'key2=value2' ] KVHWdibvGd = '' SKxdXEiZqS = [ include_directories('include'), 'include' ] ZgAyaGLMhX = true sscsIugzMK = [ 'foo', 'bar' ] EnFsGCkZWW = [ 'foo', 'bar' ] CrErYHybks = true ucPEwjmudK = 'String' WQuNykLAqe = 'String' JiibKKTtbJ = 'String' MzqukjvKXm = custom_target('VKbshoJmRR', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@']) shared_module(dJrfMwOiJr,MicUrTxbTj,build_by_default : tWicdaDgwh,build_rpath : zPJJKWegkj,dependencies : coxHZActkK,extra_files : SCErwTxojo,link_args : gyezKdTIQt,link_depends : SCErwTxojo,link_language : tmMlzlznbr,link_whole : MWfZomlcwh,link_with : HAiHLVwDBl,implicit_include_directories : WpTUTGxdZS,include_directories : yVjwVTpCIf,install : EYqTmGlCRE,install_dir : rVqwfWbQSv,install_mode : bBGFJlvFOR,install_rpath : LoTSClorXP,objects : SCErwTxojo,override_options : qhITyecMki,gnu_symbol_visibility : KVHWdibvGd,d_import_dirs : SKxdXEiZqS,d_unittest : ZgAyaGLMhX,d_module_versions : sscsIugzMK,d_debug : EnFsGCkZWW,native : CrErYHybks,name_prefix : ucPEwjmudK,name_suffix : WQuNykLAqe,rust_crate_type : JiibKKTtbJ,vs_module_defs : MzqukjvKXm) eDskfktvho = 'hNwwHvVmeL' umwFVkfDbD = 'foo.c' vtvBQAJlld = true QpBvzFzKLA = 'String' dvDUvCyKuh = [ declare_dependency(), declare_dependency() ] VjCcjNxbEj = [ 'foo', 'bar' ] siZzLSHAch = 'c' qDVsWDHYGT = [ static_library('lbWEVakuWR', 'foo.c') ] MyAZreKDIw = [ static_library('rVWMpgjlZj', 'foo.c') ] Krpckzduvo = true tBPqunzzjn = [ include_directories('include'), 'include' ] LxrZYsnzTv = true UJoQxJvjRV = 'String' jxicQRpEQO = 'rwxr-xr-x' vuVpZAHyNJ = 'String' vesMDqsFuC = [ 'key1=value1', 'key2=value2' ] FPYtgkdete = '' VumvALPRKs = [ include_directories('include'), 'include' ] fBIpcvAhSn = true rlmvNtKEij = [ 'foo', 'bar' ] wusciYtnpe = [ 'foo', 'bar' ] jlLsPyxiyf = true ykCyrLNEPE = 'String' ZhyHGHZDhI = 'String' IkezrzqSxC = 'String' tMcEYhNWRD = custom_target('LwbcRLEqJu', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] shared_module(eDskfktvho,umwFVkfDbD,build_by_default : vtvBQAJlld,build_rpath : QpBvzFzKLA,dependencies : dvDUvCyKuh,extra_files : SCErwTxojo,link_args : VjCcjNxbEj,link_depends : SCErwTxojo,link_language : siZzLSHAch,link_whole : qDVsWDHYGT,link_with : MyAZreKDIw,implicit_include_directories : Krpckzduvo,include_directories : tBPqunzzjn,install : LxrZYsnzTv,install_dir : UJoQxJvjRV,install_mode : jxicQRpEQO,install_rpath : vuVpZAHyNJ,objects : SCErwTxojo,override_options : vesMDqsFuC,gnu_symbol_visibility : FPYtgkdete,d_import_dirs : VumvALPRKs,d_unittest : fBIpcvAhSn,d_module_versions : rlmvNtKEij,d_debug : wusciYtnpe,native : jlLsPyxiyf,name_prefix : ykCyrLNEPE,name_suffix : ZhyHGHZDhI,rust_crate_type : IkezrzqSxC,vs_module_defs : tMcEYhNWRD) RRTkVXWCma = 'HckEycjfcB' JJDqlhpTHU = true LSpqKjHeUj = 'String' fVppFxLjXv = [ declare_dependency(), declare_dependency() ] KYtXQcBwjH = [ 'foo', 'bar' ] NJyQJpXuIN = 'c' FCNyNBUVgu = [ static_library('juAuxlrwkx', 'foo.c') ] hDzZmwjrYT = [ static_library('psCfJPrplv', 'foo.c') ] QvDggaXgGf = true UBvBONnkKm = [ include_directories('include'), 'include' ] ZkenWuHdDY = true GTwlOsnEUW = 'String' WxCrWaUvwP = 'rwxr-xr-x' DOwBKvJNZn = 'String' HkCRJyHuTz = [ 'key1=value1', 'key2=value2' ] uOnAxbpXQQ = '' hFdwnJMFoe = include_directories('include') mOMCPdFfMH = true tLAhojVFqy = [ 'foo', 'bar' ] qWseQslxHa = [ 'foo', 'bar' ] bXNHuQrSRD = true NJWrzsbTBA = 'String' YNAboqxzVM = 'String' ndYniJoEWm = 'String' dWDSUXqxuJ = 'bar.txt' shared_module(RRTkVXWCma,SCErwTxojo,build_by_default : JJDqlhpTHU,build_rpath : LSpqKjHeUj,dependencies : fVppFxLjXv,extra_files : SCErwTxojo,link_args : KYtXQcBwjH,link_depends : SCErwTxojo,link_language : NJyQJpXuIN,link_whole : FCNyNBUVgu,link_with : hDzZmwjrYT,implicit_include_directories : QvDggaXgGf,include_directories : UBvBONnkKm,install : ZkenWuHdDY,install_dir : GTwlOsnEUW,install_mode : WxCrWaUvwP,install_rpath : DOwBKvJNZn,objects : SCErwTxojo,override_options : HkCRJyHuTz,gnu_symbol_visibility : uOnAxbpXQQ,d_import_dirs : hFdwnJMFoe,d_unittest : mOMCPdFfMH,d_module_versions : tLAhojVFqy,d_debug : qWseQslxHa,native : bXNHuQrSRD,name_prefix : NJWrzsbTBA,name_suffix : YNAboqxzVM,rust_crate_type : ndYniJoEWm,vs_module_defs : dWDSUXqxuJ) EAkvBphrKd = 'WYrYCVBkcc' bNSSqzEILb = true SOlGnLfXSn = 'String' fuHvwxtZpd = [ declare_dependency(), declare_dependency() ] PpJSqMsVrB = [ 'foo', 'bar' ] HrCkSOVHrV = 'c' nEYMdJGLzt = [ static_library('FQcDukXWwc', 'foo.c') ] VZjpSjtnQW = [ static_library('sWHKwVnUwZ', 'foo.c') ] gAHBNaKnsr = true UCRMDmDbLG = [ include_directories('include'), 'include' ] ZBTqcQMKKU = true GxKdTbyuye = 'String' aDIHvBSBdu = 'rwxr-xr-x' NoENbJefvr = 'String' BdjlVwjIAn = [ 'key1=value1', 'key2=value2' ] cUnRsfLGDz = '' BrXOkclNYK = include_directories('include') wDUYeURmuL = true UyyYzPBvUb = [ 'foo', 'bar' ] pRjMnVqDxS = [ 'foo', 'bar' ] VEHtNwRbas = true VIaEXLsAZY = 'String' nxchIJIyYW = 'String' tCosIIetKz = 'String' shared_module(EAkvBphrKd,SCErwTxojo,build_by_default : bNSSqzEILb,build_rpath : SOlGnLfXSn,dependencies : fuHvwxtZpd,extra_files : SCErwTxojo,link_args : PpJSqMsVrB,link_depends : SCErwTxojo,link_language : HrCkSOVHrV,link_whole : nEYMdJGLzt,link_with : VZjpSjtnQW,implicit_include_directories : gAHBNaKnsr,include_directories : UCRMDmDbLG,install : ZBTqcQMKKU,install_dir : GxKdTbyuye,install_mode : aDIHvBSBdu,install_rpath : NoENbJefvr,objects : SCErwTxojo,override_options : BdjlVwjIAn,gnu_symbol_visibility : cUnRsfLGDz,d_import_dirs : BrXOkclNYK,d_unittest : wDUYeURmuL,d_module_versions : UyyYzPBvUb,d_debug : pRjMnVqDxS,native : VEHtNwRbas,name_prefix : VIaEXLsAZY,name_suffix : nxchIJIyYW,rust_crate_type : tCosIIetKz,vs_module_defs : obj) PeSecERYJW = 'zDTxNSfZCh' rBUOHFdABG = true OZClnNOYxj = 'String' ZAKsMKSApS = [ declare_dependency(), declare_dependency() ] WewHmymHAT = [ 'foo', 'bar' ] KuYShjXTlG = 'c' TypzUXpHQK = [ static_library('yftftLOaow', 'foo.c') ] LfNTzOusUS = [ static_library('BzMWMHgviI', 'foo.c') ] QEKbrmdjFO = true WwUbahOPKa = [ include_directories('include'), 'include' ] vXQfenBxVW = true yjEhqJSdfA = 'String' MuTMqjoyzi = 'rwxr-xr-x' uIwdHxbZUd = 'String' ozIPukBXCO = [ 'key1=value1', 'key2=value2' ] IEdjWnfQGp = '' heWUFnpcby = include_directories('include') qdAkHfnZSn = true DClkIMrUDV = [ 'foo', 'bar' ] EqmfoOZpKh = [ 'foo', 'bar' ] rWKjHYlxVu = true mWDVYkYVZJ = 'String' cLjAsFlFEn = 'String' ZPyJJSbZOD = 'String' GiFXfGdwcu = custom_target('KbkFDPEgJj', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@']) shared_module(PeSecERYJW,SCErwTxojo,build_by_default : rBUOHFdABG,build_rpath : OZClnNOYxj,dependencies : ZAKsMKSApS,extra_files : SCErwTxojo,link_args : WewHmymHAT,link_depends : SCErwTxojo,link_language : KuYShjXTlG,link_whole : TypzUXpHQK,link_with : LfNTzOusUS,implicit_include_directories : QEKbrmdjFO,include_directories : WwUbahOPKa,install : vXQfenBxVW,install_dir : yjEhqJSdfA,install_mode : MuTMqjoyzi,install_rpath : uIwdHxbZUd,objects : SCErwTxojo,override_options : ozIPukBXCO,gnu_symbol_visibility : IEdjWnfQGp,d_import_dirs : heWUFnpcby,d_unittest : qdAkHfnZSn,d_module_versions : DClkIMrUDV,d_debug : EqmfoOZpKh,native : rWKjHYlxVu,name_prefix : mWDVYkYVZJ,name_suffix : cLjAsFlFEn,rust_crate_type : ZPyJJSbZOD,vs_module_defs : GiFXfGdwcu) gSxcFkrWna = 'SpWHZtlmEz' yjqkoHsNir = true kgyXbLZmsx = 'String' TuXYqPUOcZ = [ declare_dependency(), declare_dependency() ] tCiaQzJCpp = [ 'foo', 'bar' ] FUbgrfJAWG = 'c' OUGUFmWADX = [ static_library('cOLbymmvJn', 'foo.c') ] FkGADOhfsT = [ static_library('sFIhwjvQBO', 'foo.c') ] udtJcpdTKA = true IfMgdJPsNv = [ include_directories('include'), 'include' ] zSYNiCdcqh = true AOkeFxBBUL = 'String' RlwKwHDvQz = 'rwxr-xr-x' rlzECHwFHp = 'String' kbBaLIPSKN = [ 'key1=value1', 'key2=value2' ] QttAiXWwBw = '' ovzZoXPXkT = include_directories('include') ELhiIfaeEH = true IctKCFhyYG = [ 'foo', 'bar' ] LelAHcKKmx = [ 'foo', 'bar' ] CNfFwcLmrP = true AbcOtbvQuP = 'String' VYzWTmXMhO = 'String' HNdmJFoUTO = 'String' xBXCOmmwld = custom_target('bxFGVtSxUp', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] shared_module(gSxcFkrWna,SCErwTxojo,build_by_default : yjqkoHsNir,build_rpath : kgyXbLZmsx,dependencies : TuXYqPUOcZ,extra_files : SCErwTxojo,link_args : tCiaQzJCpp,link_depends : SCErwTxojo,link_language : FUbgrfJAWG,link_whole : OUGUFmWADX,link_with : FkGADOhfsT,implicit_include_directories : udtJcpdTKA,include_directories : IfMgdJPsNv,install : zSYNiCdcqh,install_dir : AOkeFxBBUL,install_mode : RlwKwHDvQz,install_rpath : rlzECHwFHp,objects : SCErwTxojo,override_options : kbBaLIPSKN,gnu_symbol_visibility : QttAiXWwBw,d_import_dirs : ovzZoXPXkT,d_unittest : ELhiIfaeEH,d_module_versions : IctKCFhyYG,d_debug : LelAHcKKmx,native : CNfFwcLmrP,name_prefix : AbcOtbvQuP,name_suffix : VYzWTmXMhO,rust_crate_type : HNdmJFoUTO,vs_module_defs : xBXCOmmwld) vLKUKzbigI = 'HuiVfFRpwZ' JbfffWvhSO = true rxATOixDdu = 'String' CJdHljhRXc = [ declare_dependency(), declare_dependency() ] FsxHaSXauN = [ 'foo', 'bar' ] gViwbhHOkY = 'c' MxFOMDpWqa = [ static_library('sswgBoTNVB', 'foo.c') ] rRmKsMYFkb = [ static_library('yyVMclkmfd', 'foo.c') ] IomPnPsFXw = true nygtllBGfP = [ include_directories('include'), 'include' ] XmGQaENCSw = true yHOeJtSBdj = 'String' NBxLOpuNnw = 'rwxr-xr-x' QDXpENDHAk = 'String' QXFedfYsyN = [ 'key1=value1', 'key2=value2' ] rCnFUzreQZ = '' DnTxzCUtaZ = [ include_directories('include'), 'include' ] ZUrTQqWYZc = true juHQgufpve = [ 'foo', 'bar' ] xnybzaCzlM = [ 'foo', 'bar' ] KkCHiaQlal = true gnqXkaaBPo = 'String' dnJhNLKIRO = 'String' FislFZQEsz = 'String' xwoilesCPy = 'bar.txt' shared_module(vLKUKzbigI,SCErwTxojo,build_by_default : JbfffWvhSO,build_rpath : rxATOixDdu,dependencies : CJdHljhRXc,extra_files : SCErwTxojo,link_args : FsxHaSXauN,link_depends : SCErwTxojo,link_language : gViwbhHOkY,link_whole : MxFOMDpWqa,link_with : rRmKsMYFkb,implicit_include_directories : IomPnPsFXw,include_directories : nygtllBGfP,install : XmGQaENCSw,install_dir : yHOeJtSBdj,install_mode : NBxLOpuNnw,install_rpath : QDXpENDHAk,objects : SCErwTxojo,override_options : QXFedfYsyN,gnu_symbol_visibility : rCnFUzreQZ,d_import_dirs : DnTxzCUtaZ,d_unittest : ZUrTQqWYZc,d_module_versions : juHQgufpve,d_debug : xnybzaCzlM,native : KkCHiaQlal,name_prefix : gnqXkaaBPo,name_suffix : dnJhNLKIRO,rust_crate_type : FislFZQEsz,vs_module_defs : xwoilesCPy) FFrJiDMZqK = 'EXxqGPpVtz' WrLvaJFzHq = true rPKNfPsDcy = 'String' bDwcKsfYkD = [ declare_dependency(), declare_dependency() ] wwZqtZeCda = [ 'foo', 'bar' ] QsjLcZKZsu = 'c' VGVzBOMrnJ = [ static_library('DoQDEsYneN', 'foo.c') ] KCavfsXVWv = [ static_library('TOAaiMtVeA', 'foo.c') ] TCdsWVaByA = true tPTnjoMXOK = [ include_directories('include'), 'include' ] celQbERQQO = true mnpRptrSru = 'String' QclLQLdlpY = 'rwxr-xr-x' dUrlKFfonh = 'String' iaVRIDyuqO = [ 'key1=value1', 'key2=value2' ] FpQKnvjxxT = '' XgktmFxVxR = [ include_directories('include'), 'include' ] HqzpXwGPhG = true WZYDkXBGFB = [ 'foo', 'bar' ] LscCECfpIp = [ 'foo', 'bar' ] sTxdajnnHY = true ZWLcXuKPOv = 'String' dBNwPYrFcY = 'String' HEsXAzyQKY = 'String' shared_module(FFrJiDMZqK,SCErwTxojo,build_by_default : WrLvaJFzHq,build_rpath : rPKNfPsDcy,dependencies : bDwcKsfYkD,extra_files : SCErwTxojo,link_args : wwZqtZeCda,link_depends : SCErwTxojo,link_language : QsjLcZKZsu,link_whole : VGVzBOMrnJ,link_with : KCavfsXVWv,implicit_include_directories : TCdsWVaByA,include_directories : tPTnjoMXOK,install : celQbERQQO,install_dir : mnpRptrSru,install_mode : QclLQLdlpY,install_rpath : dUrlKFfonh,objects : SCErwTxojo,override_options : iaVRIDyuqO,gnu_symbol_visibility : FpQKnvjxxT,d_import_dirs : XgktmFxVxR,d_unittest : HqzpXwGPhG,d_module_versions : WZYDkXBGFB,d_debug : LscCECfpIp,native : sTxdajnnHY,name_prefix : ZWLcXuKPOv,name_suffix : dBNwPYrFcY,rust_crate_type : HEsXAzyQKY,vs_module_defs : obj) MUGAuJUbFt = 'BVRrpabZUC' WEWtBPVfNW = true rZcDhBsabk = 'String' BqVmObgIpB = [ declare_dependency(), declare_dependency() ] AiLiHdFdcV = [ 'foo', 'bar' ] MIoxVEvJRz = 'c' OXrfaNGuTx = [ static_library('MkCWLYACmA', 'foo.c') ] lyheHioYsQ = [ static_library('AovJQHRbsK', 'foo.c') ] qeTHLtFiis = true taIYagPhJb = [ include_directories('include'), 'include' ] TQrDgSQCvm = true uVaLHrOxUa = 'String' hhRFcCbYNk = 'rwxr-xr-x' XwDowiLiPO = 'String' aAkeddARZM = [ 'key1=value1', 'key2=value2' ] cDdlclLijO = '' VoHWGgUway = [ include_directories('include'), 'include' ] WGWEERsTqB = true xcmGrBTHYx = [ 'foo', 'bar' ] jOrytCFbbr = [ 'foo', 'bar' ] sNXSmxnsUo = true UgVtvEmeMR = 'String' ByXssxaPJy = 'String' fQzQVtPWNU = 'String' kuszVVdQOX = custom_target('sRhSEFFsNA', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@']) shared_module(MUGAuJUbFt,SCErwTxojo,build_by_default : WEWtBPVfNW,build_rpath : rZcDhBsabk,dependencies : BqVmObgIpB,extra_files : SCErwTxojo,link_args : AiLiHdFdcV,link_depends : SCErwTxojo,link_language : MIoxVEvJRz,link_whole : OXrfaNGuTx,link_with : lyheHioYsQ,implicit_include_directories : qeTHLtFiis,include_directories : taIYagPhJb,install : TQrDgSQCvm,install_dir : uVaLHrOxUa,install_mode : hhRFcCbYNk,install_rpath : XwDowiLiPO,objects : SCErwTxojo,override_options : aAkeddARZM,gnu_symbol_visibility : cDdlclLijO,d_import_dirs : VoHWGgUway,d_unittest : WGWEERsTqB,d_module_versions : xcmGrBTHYx,d_debug : jOrytCFbbr,native : sNXSmxnsUo,name_prefix : UgVtvEmeMR,name_suffix : ByXssxaPJy,rust_crate_type : fQzQVtPWNU,vs_module_defs : kuszVVdQOX) JTFiarMHbG = 'hvzTdZUjeV' aiHIGdjncE = true yQGRPfaFSx = 'String' cISrGyhMkC = [ declare_dependency(), declare_dependency() ] efHJuPiXnw = [ 'foo', 'bar' ] jQsibJTMNL = 'c' BuiNVZuuNA = [ static_library('ToDXxfWyly', 'foo.c') ] vuPLjTAwzU = [ static_library('LUQGkiVZEI', 'foo.c') ] dgbHeMfeaV = true dLmEABarFH = [ include_directories('include'), 'include' ] gzlYBfnCto = true bzjqKrOIiK = 'String' uteGnRHkOG = 'rwxr-xr-x' bXlgfbJiUu = 'String' YelZfDNlvc = [ 'key1=value1', 'key2=value2' ] urCAMNWAUj = '' wryxSTsnJE = [ include_directories('include'), 'include' ] XyVhdnpORE = true kEggaOdryE = [ 'foo', 'bar' ] OXbgmGgsrd = [ 'foo', 'bar' ] AsJqrUBwlA = true WrrhjnvuXY = 'String' wOoFYlUKeR = 'String' GGIQDcPtjt = 'String' mnOpfefLCK = custom_target('tczCzOUYqj', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] shared_module(JTFiarMHbG,SCErwTxojo,build_by_default : aiHIGdjncE,build_rpath : yQGRPfaFSx,dependencies : cISrGyhMkC,extra_files : SCErwTxojo,link_args : efHJuPiXnw,link_depends : SCErwTxojo,link_language : jQsibJTMNL,link_whole : BuiNVZuuNA,link_with : vuPLjTAwzU,implicit_include_directories : dgbHeMfeaV,include_directories : dLmEABarFH,install : gzlYBfnCto,install_dir : bzjqKrOIiK,install_mode : uteGnRHkOG,install_rpath : bXlgfbJiUu,objects : SCErwTxojo,override_options : YelZfDNlvc,gnu_symbol_visibility : urCAMNWAUj,d_import_dirs : wryxSTsnJE,d_unittest : XyVhdnpORE,d_module_versions : kEggaOdryE,d_debug : OXbgmGgsrd,native : AsJqrUBwlA,name_prefix : WrrhjnvuXY,name_suffix : wOoFYlUKeR,rust_crate_type : GGIQDcPtjt,vs_module_defs : mnOpfefLCK) error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` **Expected behaviour** No crash. **System parameters** ``` The Meson build system Version: 0.60.1 Build type: native build C compiler for the host machine: gcc (gcc 8.3.0 "gcc (x86_64-posix-seh, Built by strawberryperl.com project) 8.3.0") C linker for the host machine: gcc ld.bfd 2.32 Java compiler for the host machine: javac (unknown 17.0.1) Host machine cpu family: x86_64 Host machine cpu: x86_64 ```
The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) lOZRiiTxhE = 'rEdGFiyQxC' ajWXCFHNzJ = 'foo.c' sZOKcLWCZP = true nDYKPnDhJE = 'String' UgHRlmluER = [ declare_dependency(), declare_dependency() ] LGemLMDuRB = files('foo.c', 'bar.c') cfkxnaXSaF = [ 'foo', 'bar' ] ICERYIVQGu = [ files('foo.c')[0], 'bar.c' ] VhAACcnqsi = 'c' jIdcRzLiyQ = [ static_library('LmlSkwPsNW', 'foo.c') ] tEiVDnobSZ = [ static_library('jxpmwFsZwJ', 'foo.c') ] ldacnVBURp = true LwqhlxQQjZ = [ include_directories('include'), 'include' ] gTAlkEwQUH = true FFdzylsJcM = 'String' rOyrmbPiCj = 'rwxr-xr-x' iMJUzsFDbU = 'String' cvaMVDLbfI = files('foo.c', 'bar.c') pdqolhQBuQ = 'String' MzWdwZJSTs = [ 'key1=value1', 'key2=value2' ] DfLZHsxMKJ = '' bgWLwtGbSX = include_directories('include') hbRdGGJACx = true VwusymDpEA = [ 'foo', 'bar' ] gOPqTXdmJW = [ 'foo', 'bar' ] SKPPksEKEA = true IoWOOLqXMY = 'String' jrKACSLlFD = 'String' iqzUfDOUxe = '0' iiKhFuLpmJ = '1.0.0' PiDGzPWcQZ = 1 ZjOjgegbYp = custom_target('LvzAYtycpo', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] LUFvjDWdCX = shared_library(lOZRiiTxhE,ajWXCFHNzJ,build_by_default : sZOKcLWCZP,build_rpath : nDYKPnDhJE,dependencies : UgHRlmluER,extra_files : LGemLMDuRB,link_args : cfkxnaXSaF,link_depends : ICERYIVQGu,link_language : VhAACcnqsi,link_whole : jIdcRzLiyQ,link_with : tEiVDnobSZ,implicit_include_directories : ldacnVBURp,include_directories : LwqhlxQQjZ,install : gTAlkEwQUH,install_dir : FFdzylsJcM,install_mode : rOyrmbPiCj,install_rpath : iMJUzsFDbU,objects : cvaMVDLbfI,name_suffix : pdqolhQBuQ,override_options : MzWdwZJSTs,gnu_symbol_visibility : DfLZHsxMKJ,d_import_dirs : bgWLwtGbSX,d_unittest : hbRdGGJACx,d_module_versions : VwusymDpEA,d_debug : gOPqTXdmJW,native : SKPPksEKEA,name_prefix : IoWOOLqXMY,rust_crate_type : jrKACSLlFD,soversion : iqzUfDOUxe,version : iiKhFuLpmJ,darwin_versions : PiDGzPWcQZ,vs_module_defs : ZjOjgegbYp) HtayHlQebW = true LUFvjDWdCX.extract_all_objects(recursive : HtayHlQebW) oUGVrpAuZF = [] LUFvjDWdCX.extract_objects(oUGVrpAuZF) mVHBrrQnOm = [] LUFvjDWdCX.extract_objects(mVHBrrQnOm) LUFvjDWdCX.found() LUFvjDWdCX.full_path() LUFvjDWdCX.name() LUFvjDWdCX.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson [...] ``` The following buildfile results in the same last trace line: ```meson [...] ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) ZUTbxYssNm = 'MbJDjeoTXi' kXDJXmWOLw = [ files('foo.c')[0], 'bar.c' ] oTsWZWFSGg = true gXHwQoczNQ = 'String' kjzmviFbVW = [ declare_dependency(), declare_dependency() ] lpJVWBPtfp = files('foo.c', 'bar.c') XPDTsjVnCL = [ 'foo', 'bar' ] zLntFeIEyb = [ files('foo.c')[0], 'bar.c' ] uBbXcwPhbJ = 'c' pOvzpsNBha = [ static_library('sRewokXHnt', 'foo.c') ] uDgCVtRgOc = [ static_library('jxuSrGojgT', 'foo.c') ] BmQnfnzXol = true XOxpUDFane = [ include_directories('include'), 'include' ] ZBYRWtgdfv = true gSNzcSTtaa = 'String' FqEHQGyCMP = 'rwxr-xr-x' JiKbwWIXpW = 'String' CLjCkMYmJw = files('foo.c', 'bar.c') kzriGFYtpf = 'String' JFZcOynnUE = [ 'key1=value1', 'key2=value2' ] vecQAsGtOX = '' DVVQzkZFTu = include_directories('include') HHJFjKpYXC = true eOnGEzeLBB = [ 'foo', 'bar' ] YYWfdUfmNF = [ 'foo', 'bar' ] nANKSbqHYD = true DjNAvoFglD = 'String' xpyuFWKLWJ = 'String' uGQutPtAuv = '0' LjpcQiAANX = '1.0.0' cAzLSRXLqm = [ '1' ] PypLblRnpr = custom_target('GrAWJDsYoK', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] yJpgRNEiUR = shared_library(ZUTbxYssNm,kXDJXmWOLw,build_by_default : oTsWZWFSGg,build_rpath : gXHwQoczNQ,dependencies : kjzmviFbVW,extra_files : lpJVWBPtfp,link_args : XPDTsjVnCL,link_depends : zLntFeIEyb,link_language : uBbXcwPhbJ,link_whole : pOvzpsNBha,link_with : uDgCVtRgOc,implicit_include_directories : BmQnfnzXol,include_directories : XOxpUDFane,install : ZBYRWtgdfv,install_dir : gSNzcSTtaa,install_mode : FqEHQGyCMP,install_rpath : JiKbwWIXpW,objects : CLjCkMYmJw,name_suffix : kzriGFYtpf,override_options : JFZcOynnUE,gnu_symbol_visibility : vecQAsGtOX,d_import_dirs : DVVQzkZFTu,d_unittest : HHJFjKpYXC,d_module_versions : eOnGEzeLBB,d_debug : YYWfdUfmNF,native : nANKSbqHYD,name_prefix : DjNAvoFglD,rust_crate_type : xpyuFWKLWJ,soversion : uGQutPtAuv,version : LjpcQiAANX,darwin_versions : cAzLSRXLqm,vs_module_defs : PypLblRnpr) qDUHuiwqLa = true yJpgRNEiUR.extract_all_objects(recursive : qDUHuiwqLa) LXUPBXmlML = [] yJpgRNEiUR.extract_objects(LXUPBXmlML) mAYfJECWos = [] yJpgRNEiUR.extract_objects(mAYfJECWos) yJpgRNEiUR.found() yJpgRNEiUR.full_path() yJpgRNEiUR.name() yJpgRNEiUR.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson [...] ``` The following buildfile results in the same last trace line: ```meson [...] # blockbuster 1409 lines ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) dDBvrhHHQv = 'KhFFlndrvF' tarXgMhqui = 'foo.c' tjFtNxisoD = true fAnbIPYsFQ = 'String' QqqqqxgCCc = [ declare_dependency(), declare_dependency() ] PMTJIioaqb = files('foo.c', 'bar.c') skTKAxAryk = [ 'foo', 'bar' ] yvjhbGYxdw = [ files('foo.c')[0], 'bar.c' ] rZCSAkJZIc = 'c' CZVpXBpFke = [ static_library('ZTGLvqOOud', 'foo.c') ] SsQsPTKUJj = [ static_library('WjLMrXkSYz', 'foo.c') ] VnStafDqNW = true rkGkGyBrnY = [ include_directories('include'), 'include' ] HIkVvTipBh = true fHmoHJFywA = 'String' kiZAsoDugD = 'rwxr-xr-x' RJHKczEjDC = 'String' jgGfZYCCnN = files('foo.c', 'bar.c') mrXmaHrmPg = 'String' kWdVBWzhFB = [ 'key1=value1', 'key2=value2' ] glrWyeGglH = '' bzBILFmQYy = include_directories('include') vSsAsUEyLW = true xNbApIzggZ = [ 'foo', 'bar' ] xzJKySAXcI = [ 'foo', 'bar' ] pzzMZpBeIE = true lEizXWUcEg = 'String' HIjiWjBnns = 'String' KvhpEabDdt = '0' urTwtiXpei = '1.0.0' wkHMViumpz = '1' RDQDayUODv = custom_target('xmvGbOSaHh', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] GcljXldcwd = shared_library(dDBvrhHHQv,tarXgMhqui,build_by_default : tjFtNxisoD,build_rpath : fAnbIPYsFQ,dependencies : QqqqqxgCCc,extra_files : PMTJIioaqb,link_args : skTKAxAryk,link_depends : yvjhbGYxdw,link_language : rZCSAkJZIc,link_whole : CZVpXBpFke,link_with : SsQsPTKUJj,implicit_include_directories : VnStafDqNW,include_directories : rkGkGyBrnY,install : HIkVvTipBh,install_dir : fHmoHJFywA,install_mode : kiZAsoDugD,install_rpath : RJHKczEjDC,objects : jgGfZYCCnN,name_suffix : mrXmaHrmPg,override_options : kWdVBWzhFB,gnu_symbol_visibility : glrWyeGglH,d_import_dirs : bzBILFmQYy,d_unittest : vSsAsUEyLW,d_module_versions : xNbApIzggZ,d_debug : xzJKySAXcI,native : pzzMZpBeIE,name_prefix : lEizXWUcEg,rust_crate_type : HIjiWjBnns,soversion : KvhpEabDdt,version : urTwtiXpei,darwin_versions : wkHMViumpz,vs_module_defs : RDQDayUODv) YgQkeNaSkB = true GcljXldcwd.extract_all_objects(recursive : YgQkeNaSkB) vIlCAtRgPb = [] GcljXldcwd.extract_objects(vIlCAtRgPb) UvrIlDsaoN = [] GcljXldcwd.extract_objects(UvrIlDsaoN) GcljXldcwd.found() GcljXldcwd.full_path() GcljXldcwd.name() GcljXldcwd.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) ylPdIkSozA = 'AxjoxRPRcg' IopucgZKNs = [ files('foo.c')[0], 'bar.c' ] GimRlsKVfU = true leZSwaFwPE = 'String' HtxHxHPpgR = [ declare_dependency(), declare_dependency() ] uytUBHcuPQ = files('foo.c', 'bar.c') ObKQFnRdau = [ 'foo', 'bar' ] DeFKWFvANH = [ files('foo.c')[0], 'bar.c' ] NIKAsUIJtI = 'c' GZJaABhkJJ = [ static_library('VPiYijuIcd', 'foo.c') ] FKirEPDUJW = [ static_library('OhpxnVAIlz', 'foo.c') ] JPpdPBkTgY = true XYppuOOnmG = [ include_directories('include'), 'include' ] uHvmWzkNIh = true FUqiJluKKP = 'String' VDleCvVzrw = 'rwxr-xr-x' uvtWaBfwFi = 'String' awpSFSVSHN = files('foo.c', 'bar.c') hqwKMLpPvt = [ 'key1=value1', 'key2=value2' ] OkqwYDOGDl = '' WwbwjqTaPT = include_directories('include') ckCuDNsWaW = true CusnaNcBCM = [ 'foo', 'bar' ] TGZHlRXSWn = [ 'foo', 'bar' ] vRSgebGcYe = true fyLNoFuDYx = 'String' JrJTCqolcZ = 'String' KebutrOSFe = 'String' jAtLTqlUIT = custom_target('gwYVWZxOGo', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] ImgwjMRoLM = shared_module(ylPdIkSozA,IopucgZKNs,build_by_default : GimRlsKVfU,build_rpath : leZSwaFwPE,dependencies : HtxHxHPpgR,extra_files : uytUBHcuPQ,link_args : ObKQFnRdau,link_depends : DeFKWFvANH,link_language : NIKAsUIJtI,link_whole : GZJaABhkJJ,link_with : FKirEPDUJW,implicit_include_directories : JPpdPBkTgY,include_directories : XYppuOOnmG,install : uHvmWzkNIh,install_dir : FUqiJluKKP,install_mode : VDleCvVzrw,install_rpath : uvtWaBfwFi,objects : awpSFSVSHN,override_options : hqwKMLpPvt,gnu_symbol_visibility : OkqwYDOGDl,d_import_dirs : WwbwjqTaPT,d_unittest : ckCuDNsWaW,d_module_versions : CusnaNcBCM,d_debug : TGZHlRXSWn,native : vRSgebGcYe,name_prefix : fyLNoFuDYx,name_suffix : JrJTCqolcZ,rust_crate_type : KebutrOSFe,vs_module_defs : jAtLTqlUIT) usEolLEHmW = true ImgwjMRoLM.extract_all_objects(recursive : usEolLEHmW) hkJtaucyJU = [] ImgwjMRoLM.extract_objects(hkJtaucyJU) bmjHoxjqvW = [] ImgwjMRoLM.extract_objects(bmjHoxjqvW) ImgwjMRoLM.found() ImgwjMRoLM.full_path() ImgwjMRoLM.name() ImgwjMRoLM.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) kXqHgQVybV = 'KAoKeCrdzV' jWIwaKPKBW = 'foo.c' AnUWQhUkuU = true FdprKqcjfh = 'String' DwkOTdGrWM = [ declare_dependency(), declare_dependency() ] SvxSczAidE = files('foo.c', 'bar.c') vkOPXBSNhF = [ 'foo', 'bar' ] jgoSeHUjxY = [ files('foo.c')[0], 'bar.c' ] plcufwkvNY = 'c' JSkSCghUUe = [ static_library('zLiDUnUzeH', 'foo.c') ] qasmVHSLqO = [ static_library('DZUyLZaNwk', 'foo.c') ] jlMNgEoOjy = true qxQVeiPCoB = [ include_directories('include'), 'include' ] DKENuaDvIg = true cCfeLCjiNw = 'String' NUEvcEpXiT = 'rwxr-xr-x' IgNUJSpobW = 'String' bfZeVwCvjs = files('foo.c', 'bar.c') BmCNcmnHTW = [ 'key1=value1', 'key2=value2' ] LHVuSnqqJm = '' rGeefKXDoQ = include_directories('include') KlMRJPhGVs = true TVVJqwyLbP = [ 'foo', 'bar' ] thLQflrGUQ = [ 'foo', 'bar' ] wpDtfLzogf = true SVNIXbUjeH = 'String' MkNejqTyPx = 'String' lTBhaKdycF = 'String' BvWadigGZk = custom_target('xHsoEOzrkk', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] GPnorltunE = shared_module(kXqHgQVybV,jWIwaKPKBW,build_by_default : AnUWQhUkuU,build_rpath : FdprKqcjfh,dependencies : DwkOTdGrWM,extra_files : SvxSczAidE,link_args : vkOPXBSNhF,link_depends : jgoSeHUjxY,link_language : plcufwkvNY,link_whole : JSkSCghUUe,link_with : qasmVHSLqO,implicit_include_directories : jlMNgEoOjy,include_directories : qxQVeiPCoB,install : DKENuaDvIg,install_dir : cCfeLCjiNw,install_mode : NUEvcEpXiT,install_rpath : IgNUJSpobW,objects : bfZeVwCvjs,override_options : BmCNcmnHTW,gnu_symbol_visibility : LHVuSnqqJm,d_import_dirs : rGeefKXDoQ,d_unittest : KlMRJPhGVs,d_module_versions : TVVJqwyLbP,d_debug : thLQflrGUQ,native : wpDtfLzogf,name_prefix : SVNIXbUjeH,name_suffix : MkNejqTyPx,rust_crate_type : lTBhaKdycF,vs_module_defs : BvWadigGZk) aMdIjwOeRZ = true GPnorltunE.extract_all_objects(recursive : aMdIjwOeRZ) yBnpyQKZgb = [] GPnorltunE.extract_objects(yBnpyQKZgb) HosSfrIaTv = [] GPnorltunE.extract_objects(HosSfrIaTv) GPnorltunE.found() GPnorltunE.full_path() GPnorltunE.name() GPnorltunE.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson [...] ``` The following buildfile results in the same last trace line: ```meson [...] ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) ZZHDXDSQow = 'imeZTadInP' HPvfeRQOdu = 'foo.c' wqCTZPXlKW = true eGogabovCZ = 'String' oIxGUywikD = [ declare_dependency(), declare_dependency() ] VlJeVyOfZA = files('foo.c', 'bar.c') vPGpgXxbJA = [ 'foo', 'bar' ] tRoYyOzAyl = [ files('foo.c')[0], 'bar.c' ] rcyGhdXfXU = 'c' vmnEmWXRxX = [ static_library('weNOFHsdgN', 'foo.c') ] QVJInIffEY = [ static_library('mcEIeUooRf', 'foo.c') ] SQrTaFZTiY = true adVsosHhrM = [ include_directories('include'), 'include' ] jAxtEuPJOr = true sIAKstIsvV = 'String' AnxhneqobF = 'rwxr-xr-x' zxEqasOyyp = 'String' gLaLepTQIR = files('foo.c', 'bar.c') QFZxXOwWKo = 'String' orpaWDcBLv = [ 'key1=value1', 'key2=value2' ] QxoINQVbQm = '' TeYLVjRlwB = include_directories('include') JFpkGJKAwa = true yYzfAKLkAS = [ 'foo', 'bar' ] dUVItfZEYn = [ 'foo', 'bar' ] qdOxBrnuHJ = true dsBngSRSSa = 'String' TrdsUujxAx = 'String' JzswRpJfCy = '0' lubxlsCIMz = '1.0.0' uvwtFkiqen = [ '1' ] wUtzLHQsAz = custom_target('MvbSLjCerQ', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] UPLlwQFXno = shared_library(ZZHDXDSQow,HPvfeRQOdu,build_by_default : wqCTZPXlKW,build_rpath : eGogabovCZ,dependencies : oIxGUywikD,extra_files : VlJeVyOfZA,link_args : vPGpgXxbJA,link_depends : tRoYyOzAyl,link_language : rcyGhdXfXU,link_whole : vmnEmWXRxX,link_with : QVJInIffEY,implicit_include_directories : SQrTaFZTiY,include_directories : adVsosHhrM,install : jAxtEuPJOr,install_dir : sIAKstIsvV,install_mode : AnxhneqobF,install_rpath : zxEqasOyyp,objects : gLaLepTQIR,name_suffix : QFZxXOwWKo,override_options : orpaWDcBLv,gnu_symbol_visibility : QxoINQVbQm,d_import_dirs : TeYLVjRlwB,d_unittest : JFpkGJKAwa,d_module_versions : yYzfAKLkAS,d_debug : dUVItfZEYn,native : qdOxBrnuHJ,name_prefix : dsBngSRSSa,rust_crate_type : TrdsUujxAx,soversion : JzswRpJfCy,version : lubxlsCIMz,darwin_versions : uvwtFkiqen,vs_module_defs : wUtzLHQsAz) lcDskjnyvR = true UPLlwQFXno.extract_all_objects(recursive : lcDskjnyvR) xffhdmhxtX = [] UPLlwQFXno.extract_objects(xffhdmhxtX) JzXcyntDAl = [] UPLlwQFXno.extract_objects(JzXcyntDAl) UPLlwQFXno.found() UPLlwQFXno.full_path() UPLlwQFXno.name() UPLlwQFXno.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson [...] ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) ZoVkxrCTZI = 'ejiHmqYkqB' AwcRaJxVkf = [ files('foo.c')[0], 'bar.c' ] rGrWeCZorN = true JHYXTcUMef = 'String' eCTJMyoyWa = [ declare_dependency(), declare_dependency() ] exQlaLVNJm = files('foo.c', 'bar.c') UwqnPADWsj = [ 'foo', 'bar' ] CdrtLlnAdA = [ files('foo.c')[0], 'bar.c' ] yvlZCplAKY = 'c' okMlgqUjpz = [ static_library('VoxOdmXzbB', 'foo.c') ] RlOejXRynl = [ static_library('HOFtrtoacJ', 'foo.c') ] DqtjykBVsQ = true rFgHbsQKyQ = [ include_directories('include'), 'include' ] dbNXooSNvL = true KcGxQrFVFj = 'String' GBasRZtCiO = 'rwxr-xr-x' ZNyaEdewME = 'String' gUxqHFQAtf = files('foo.c', 'bar.c') KNwkdSaTsd = 'String' JCpUMiSsEY = [ 'key1=value1', 'key2=value2' ] bGDzsSRGjj = '' JisRYPNBNt = include_directories('include') QHfViaGsjL = true ECfUyQvjPG = [ 'foo', 'bar' ] bleyVVmVlG = [ 'foo', 'bar' ] PZyoaCllLU = true QscpvCJHht = 'String' HEvpWXFMKy = 'String' ZGlOdEFgnj = '0' PGTuaWcJNJ = '1.0.0' RBguBcBsTu = 1 GSQLIyUBGk = custom_target('XycNIbupdu', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] VbYsIPGoaA = shared_library(ZoVkxrCTZI,AwcRaJxVkf,build_by_default : rGrWeCZorN,build_rpath : JHYXTcUMef,dependencies : eCTJMyoyWa,extra_files : exQlaLVNJm,link_args : UwqnPADWsj,link_depends : CdrtLlnAdA,link_language : yvlZCplAKY,link_whole : okMlgqUjpz,link_with : RlOejXRynl,implicit_include_directories : DqtjykBVsQ,include_directories : rFgHbsQKyQ,install : dbNXooSNvL,install_dir : KcGxQrFVFj,install_mode : GBasRZtCiO,install_rpath : ZNyaEdewME,objects : gUxqHFQAtf,name_suffix : KNwkdSaTsd,override_options : JCpUMiSsEY,gnu_symbol_visibility : bGDzsSRGjj,d_import_dirs : JisRYPNBNt,d_unittest : QHfViaGsjL,d_module_versions : ECfUyQvjPG,d_debug : bleyVVmVlG,native : PZyoaCllLU,name_prefix : QscpvCJHht,rust_crate_type : HEvpWXFMKy,soversion : ZGlOdEFgnj,version : PGTuaWcJNJ,darwin_versions : RBguBcBsTu,vs_module_defs : GSQLIyUBGk) ccDSfBQgBx = true VbYsIPGoaA.extract_all_objects(recursive : ccDSfBQgBx) RsNjfDxKYO = [] VbYsIPGoaA.extract_objects(RsNjfDxKYO) CWYYgZTrBV = [] VbYsIPGoaA.extract_objects(CWYYgZTrBV) VbYsIPGoaA.found() VbYsIPGoaA.full_path() VbYsIPGoaA.name() VbYsIPGoaA.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` The following buildfile results in the same last trace line: ```meson project('generated', ['c', 'java']) qLkpsINFxL = 'bSzDypNIuu' umEXCEdCMI = [ files('foo.c')[0], 'bar.c' ] pDMOqArnuL = true RqicJgtbbF = 'String' okkMrEBeqP = [ declare_dependency(), declare_dependency() ] wEQnFnYDJJ = files('foo.c', 'bar.c') znXXvHkZpj = [ 'foo', 'bar' ] JHdLisFfdg = [ files('foo.c')[0], 'bar.c' ] sdgAswDSnP = 'c' pGcZEaCJTE = [ static_library('juJBNUENSZ', 'foo.c') ] VxzuOaxkxb = [ static_library('qFrhnQZaLP', 'foo.c') ] OPulvXMxza = true pikMKJWhaG = [ include_directories('include'), 'include' ] WVcyPlHfvY = true tDlZBOVbDG = 'String' prggWTvqYn = 'rwxr-xr-x' wyUawQxWSU = 'String' vVeAOLnyWB = files('foo.c', 'bar.c') QzzEEPVFXA = 'String' soZkwKOHNG = [ 'key1=value1', 'key2=value2' ] JWHoDtVsIa = '' bTwfFBfMnO = include_directories('include') bKaROBShuc = true hoUhOnPdiF = [ 'foo', 'bar' ] KzncPCHoxL = [ 'foo', 'bar' ] wmTEXRrdvX = true XhvuNbRfYf = 'String' sCAIvPRSIb = 'String' QljppNQlLI = '0' uqTfuFxxzX = '1.0.0' YhjtuIXsen = '1' IQEkRvJFcg = custom_target('LSvoSohYvl', output : 'bar.c', input : 'bar.txt', command : [ find_program('script.py'), '@INPUT@', '@OUTPUT@'])[0] RkiyXfsiXt = shared_library(qLkpsINFxL,umEXCEdCMI,build_by_default : pDMOqArnuL,build_rpath : RqicJgtbbF,dependencies : okkMrEBeqP,extra_files : wEQnFnYDJJ,link_args : znXXvHkZpj,link_depends : JHdLisFfdg,link_language : sdgAswDSnP,link_whole : pGcZEaCJTE,link_with : VxzuOaxkxb,implicit_include_directories : OPulvXMxza,include_directories : pikMKJWhaG,install : WVcyPlHfvY,install_dir : tDlZBOVbDG,install_mode : prggWTvqYn,install_rpath : wyUawQxWSU,objects : vVeAOLnyWB,name_suffix : QzzEEPVFXA,override_options : soZkwKOHNG,gnu_symbol_visibility : JWHoDtVsIa,d_import_dirs : bTwfFBfMnO,d_unittest : bKaROBShuc,d_module_versions : hoUhOnPdiF,d_debug : KzncPCHoxL,native : wmTEXRrdvX,name_prefix : XhvuNbRfYf,rust_crate_type : sCAIvPRSIb,soversion : QljppNQlLI,version : uqTfuFxxzX,darwin_versions : YhjtuIXsen,vs_module_defs : IQEkRvJFcg) zIpAIxUYQS = true RkiyXfsiXt.extract_all_objects(recursive : zIpAIxUYQS) DvhvZTJZnF = [] RkiyXfsiXt.extract_objects(DvhvZTJZnF) UEhiIxYMWX = [] RkiyXfsiXt.extract_objects(UEhiIxYMWX) RkiyXfsiXt.found() RkiyXfsiXt.full_path() RkiyXfsiXt.name() RkiyXfsiXt.private_dir_include() error('This error is produced to speed up checks and can be ignored ($IGNORE$)') ``` Minimal reproducer: ```meson project('generated', 'c') vs_def = custom_target( output: 'bar.def', input: 'bar.txt', command: [find_program('script.py')], )[0] shared_library('foo', 'foo.c', vs_module_defs: vs_def) ``` ``` self.vs_module_defs = File.from_built_file(path.subdir, path.get_filename()) AttributeError: 'CustomTargetIndex' object has no attribute 'subdir' t/meson.build:9:0: ERROR: Unhandled python exception This is a Meson bug and should be reported! ```
2023-07-31T00:08:02Z
[]
[]
Traceback (most recent call last): File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\mesonmain.py", line 138, in run return options.run_func(options) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 294, in run app.generate() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 185, in generate self._generate(env) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\msetup.py", line 229, in _generate intr.run() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2484, in run super().run() File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 148, in run self.evaluate_codeblock(self.ast, start=1) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 173, in evaluate_codeblock raise e File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 166, in evaluate_codeblock self.evaluate_statement(cur) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 179, in evaluate_statement return self.function_call(cur) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\interpreterbase.py", line 454, in function_call res = func(node, func_args, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\decorators.py", line 621, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreterbase\decorators.py", line 115, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 1571, in func_shared_module return self.build_target(node, args, kwargs, build.SharedModule) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\interpreter\interpreter.py", line 2686, in build_target target = targetclass(name, self.subdir, self.subproject, for_machine, sources, objs, self.environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 2236, in __init__ super().__init__(name, subdir, subproject, for_machine, sources, objects, environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 1925, in __init__ super().__init__(name, subdir, subproject, for_machine, sources, objects, environment, kwargs) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 707, in __init__ self.process_kwargs(kwargs, environment) File "c:\users\paulo\appdata\local\programs\python\python39\lib\site-packages\mesonbuild\build.py", line 2152, in process_kwargs self.vs_module_defs = File.from_built_file(path.subdir, path.get_filename()) AttributeError: 'CustomTargetIndex' object has no attribute 'subdir'
8,874
mesonbuild/meson
mesonbuild__meson-1221
534066af1a1a970e51f11fd7ed013aeacbdf0192
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -859,11 +859,11 @@ def cross_sizeof(self, element, prefix, env, extra_args=None, dependencies=None) %s int temparray[%d-sizeof(%s)]; ''' - if not self.compiles(element_exists_templ.format(prefix, element), env, args, dependencies): + if not self.compiles(element_exists_templ.format(prefix, element), env, extra_args, dependencies): return -1 for i in range(1, 1024): code = templ % (prefix, i, element) - if self.compiles(code, env, args, dependencies): + if self.compiles(code, env, extra_args, dependencies): if self.id == 'msvc': # MSVC refuses to construct an array of zero size, so # the test only succeeds when i is sizeof(element) + 1 @@ -907,11 +907,11 @@ def cross_alignment(self, typename, env, extra_args=None, dependencies=None): int testarray[%d-offsetof(struct tmp, target)]; ''' - if not self.compiles(type_exists_templ.format(typename), env, args, dependencies): + if not self.compiles(type_exists_templ.format(typename), env, extra_args, dependencies): return -1 for i in range(1, 1024): code = templ % (typename, i) - if self.compiles(code, env, args, dependencies): + if self.compiles(code, env, extra_args, dependencies): if self.id == 'msvc': # MSVC refuses to construct an array of zero size, so # the test only succeeds when i is sizeof(element) + 1 diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -113,11 +113,11 @@ def __init__(self, name, environment, kwargs): # When finding dependencies for cross-compiling, we don't care about # the 'native' pkg-config if want_cross: - if 'pkgconfig' not in env.cross_info.config['binaries']: + if 'pkgconfig' not in environment.cross_info.config['binaries']: if self.required: raise DependencyException('Pkg-config binary missing from cross file') else: - pkgbin = environment.cross_info.config['binaries']['pkgconfig'] + PkgConfigDependency.pkgbin = environment.cross_info.config['binaries']['pkgconfig'] # Only search for the native pkg-config the first time and # store the result in the class definition elif PkgConfigDependency.pkgbin is None:
Error in cross_sizeof when cross compiling with 0.37.0 For example, ```pytb $ ./meson.py --cross-file cross/ubuntu-mingw.txt test\ cases/common/35\ sizeof/ work\ area/ The Meson build system Version: 0.37.0 Source dir: /home/elliott/code/meson/test cases/common/35 sizeof Build dir: /home/elliott/code/meson/work area Build type: cross build Project name: sizeof fixme:winediag:start_process Wine Staging 1.9.22 is a testing version containing experimental patches. fixme:winediag:start_process Please mention your exact version when filing bug reports on winehq.org. Native c compiler: ccache cc (gcc 6.2.1) Cross c compiler: /usr/bin/i686-w64-mingw32-gcc (gcc 6.2.0) Native cpp compiler: ccache c++ (gcc 6.2.1) Cross cpp compiler: /usr/bin/i686-w64-mingw32-g++ (gcc 6.2.0) Host machine cpu family: x86 Host machine cpu: i686 Target machine cpu family: arm Target machine cpu: armv7h Build machine cpu family: x86_64 Build machine cpu: x86_64 Traceback (most recent call last): File "/home/elliott/code/meson/mesonbuild/mesonmain.py", line 289, in run app.generate() File "/home/elliott/code/meson/mesonbuild/mesonmain.py", line 177, in generate intr.run() File "/home/elliott/code/meson/mesonbuild/interpreter.py", line 2215, in run super().run() File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 124, in run self.evaluate_codeblock(self.ast, start=1) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 145, in evaluate_codeblock raise e File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 139, in evaluate_codeblock self.evaluate_statement(cur) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 152, in evaluate_statement return self.assignment(cur) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 547, in assignment value = self.evaluate_statement(node.value) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 154, in evaluate_statement return self.method_call(cur) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 399, in method_call return obj.method_call(method_name, self.flatten(args), kwargs) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 74, in method_call return self.methods[method_name](args, kwargs) File "/home/elliott/code/meson/mesonbuild/interpreter.py", line 803, in sizeof_method esize = self.compiler.sizeof(element, prefix, self.environment, extra_args, deps) File "/home/elliott/code/meson/mesonbuild/compilers.py", line 878, in sizeof return self.cross_sizeof(element, prefix, env, extra_args, dependencies) File "/home/elliott/code/meson/mesonbuild/compilers.py", line 862, in cross_sizeof if not self.compiles(element_exists_templ.format(prefix, element), env, args, dependencies): NameError: name 'args' is not defined ```
2016-12-19T06:03:48Z
[]
[]
Traceback (most recent call last): File "/home/elliott/code/meson/mesonbuild/mesonmain.py", line 289, in run app.generate() File "/home/elliott/code/meson/mesonbuild/mesonmain.py", line 177, in generate intr.run() File "/home/elliott/code/meson/mesonbuild/interpreter.py", line 2215, in run super().run() File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 124, in run self.evaluate_codeblock(self.ast, start=1) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 145, in evaluate_codeblock raise e File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 139, in evaluate_codeblock self.evaluate_statement(cur) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 152, in evaluate_statement return self.assignment(cur) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 547, in assignment value = self.evaluate_statement(node.value) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 154, in evaluate_statement return self.method_call(cur) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 399, in method_call return obj.method_call(method_name, self.flatten(args), kwargs) File "/home/elliott/code/meson/mesonbuild/interpreterbase.py", line 74, in method_call return self.methods[method_name](args, kwargs) File "/home/elliott/code/meson/mesonbuild/interpreter.py", line 803, in sizeof_method esize = self.compiler.sizeof(element, prefix, self.environment, extra_args, deps) File "/home/elliott/code/meson/mesonbuild/compilers.py", line 878, in sizeof return self.cross_sizeof(element, prefix, env, extra_args, dependencies) File "/home/elliott/code/meson/mesonbuild/compilers.py", line 862, in cross_sizeof if not self.compiles(element_exists_templ.format(prefix, element), env, args, dependencies): NameError: name 'args' is not defined
8,880
mesonbuild/meson
mesonbuild__meson-127
0ba1d545afe021e09090f434d5242ae942e7d5b4
diff --git a/wrap.py b/wrap.py --- a/wrap.py +++ b/wrap.py @@ -15,6 +15,7 @@ import mlog import urllib.request, os, hashlib, shutil import subprocess +import sys class PackageDefinition: def __init__(self, fname): @@ -121,6 +122,13 @@ def download(self, p, packagename): open(ofname, 'wb').write(srcdata) def extract_package(self, package): + if sys.version_info < (3, 5): + try: + import lzma + del lzma + shutil.register_unpack_format('xztar', ['.tar.xz', '.txz'], shutil._unpack_tarfile, [], "xz'ed tar-file") + except ImportError: + pass if os.path.isdir(os.path.join(self.subdir_root, package.get('directory'))): return shutil.unpack_archive(os.path.join(self.cachedir, package.get('source_filename')), self.subdir_root)
shutil.ReadError: Unknown archive format (tar.xz) ``` Dowloading enet from http://enet.bespin.org/download/enet-1.3.13.tar.gz Downloading patch from https://github.com/ignatenkobrain/meson_wrap_example/raw/master/subprojects/enet-meson.tar.xz Traceback (most recent call last): File "/home/brain/git/meson/meson.py", line 188, in run app.generate() File "/home/brain/git/meson/meson.py", line 129, in generate intr.run() File "/home/brain/git/meson/interpreter.py", line 871, in run self.evaluate_codeblock(self.ast) File "/home/brain/git/meson/interpreter.py", line 893, in evaluate_codeblock raise e File "/home/brain/git/meson/interpreter.py", line 887, in evaluate_codeblock self.evaluate_statement(cur) File "/home/brain/git/meson/interpreter.py", line 951, in evaluate_statement return self.evaluate_if(cur) File "/home/brain/git/meson/interpreter.py", line 1757, in evaluate_if self.evaluate_codeblock(node.elseblock) File "/home/brain/git/meson/interpreter.py", line 893, in evaluate_codeblock raise e File "/home/brain/git/meson/interpreter.py", line 887, in evaluate_codeblock self.evaluate_statement(cur) File "/home/brain/git/meson/interpreter.py", line 943, in evaluate_statement return self.assignment(cur) File "/home/brain/git/meson/interpreter.py", line 1637, in assignment value = self.evaluate_statement(node.value) File "/home/brain/git/meson/interpreter.py", line 941, in evaluate_statement return self.function_call(cur) File "/home/brain/git/meson/interpreter.py", line 1618, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/home/brain/git/meson/interpreter.py", line 60, in wrapped return f(self, node, args, kwargs) File "/home/brain/git/meson/interpreter.py", line 52, in wrapped return f(self, node, args, kwargs) File "/home/brain/git/meson/interpreter.py", line 1071, in func_subproject resolved = r.resolve(dirname) File "/home/brain/git/meson/wrap.py", line 64, in resolve self.extract_package(p) File "/home/brain/git/meson/wrap.py", line 128, in extract_package shutil.unpack_archive(os.path.join(self.cachedir, package.get('patch_filename')), self.subdir_root) File "/usr/lib64/python3.4/shutil.py", line 953, in unpack_archive raise ReadError("Unknown archive format '{0}'".format(filename)) shutil.ReadError: Unknown archive format '/home/brain/meson_wrap/subprojects/packagecache/enet-meson.tar.xz' ```
This works for me on py3: ``` python import tarfile with tarfile.open('test.tar.xz') as f: f.extractall('.') ``` Looks like it's fixed in python 3.5: https://hg.python.org/cpython/rev/e57db221b6c4 I think we need workaround on python 3.4
2015-05-21T16:54:29Z
[]
[]
Traceback (most recent call last): File "/home/brain/git/meson/meson.py", line 188, in run app.generate() File "/home/brain/git/meson/meson.py", line 129, in generate intr.run() File "/home/brain/git/meson/interpreter.py", line 871, in run self.evaluate_codeblock(self.ast) File "/home/brain/git/meson/interpreter.py", line 893, in evaluate_codeblock raise e File "/home/brain/git/meson/interpreter.py", line 887, in evaluate_codeblock self.evaluate_statement(cur) File "/home/brain/git/meson/interpreter.py", line 951, in evaluate_statement return self.evaluate_if(cur) File "/home/brain/git/meson/interpreter.py", line 1757, in evaluate_if self.evaluate_codeblock(node.elseblock) File "/home/brain/git/meson/interpreter.py", line 893, in evaluate_codeblock raise e File "/home/brain/git/meson/interpreter.py", line 887, in evaluate_codeblock self.evaluate_statement(cur) File "/home/brain/git/meson/interpreter.py", line 943, in evaluate_statement return self.assignment(cur) File "/home/brain/git/meson/interpreter.py", line 1637, in assignment value = self.evaluate_statement(node.value) File "/home/brain/git/meson/interpreter.py", line 941, in evaluate_statement return self.function_call(cur) File "/home/brain/git/meson/interpreter.py", line 1618, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/home/brain/git/meson/interpreter.py", line 60, in wrapped return f(self, node, args, kwargs) File "/home/brain/git/meson/interpreter.py", line 52, in wrapped return f(self, node, args, kwargs) File "/home/brain/git/meson/interpreter.py", line 1071, in func_subproject resolved = r.resolve(dirname) File "/home/brain/git/meson/wrap.py", line 64, in resolve self.extract_package(p) File "/home/brain/git/meson/wrap.py", line 128, in extract_package shutil.unpack_archive(os.path.join(self.cachedir, package.get('patch_filename')), self.subdir_root) File "/usr/lib64/python3.4/shutil.py", line 953, in unpack_archive raise ReadError("Unknown archive format '{0}'".format(filename)) shutil.ReadError: Unknown archive format '/home/brain/meson_wrap/subprojects/packagecache/enet-meson.tar.xz'
8,887
mesonbuild/meson
mesonbuild__meson-1342
380b9157b8a282552e1463ca9a0e486e5b6319e2
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -13,7 +13,8 @@ # limitations under the License. import pickle, os, uuid -from .mesonlib import MesonException, default_libdir, default_libexecdir, default_prefix +from .mesonlib import MesonException, commonpath +from .mesonlib import default_libdir, default_libexecdir, default_prefix version = '0.38.0.dev1' backendlist = ['ninja', 'vs2010', 'vs2015', 'xcode'] @@ -158,7 +159,7 @@ def sanitize_dir_option_value(self, prefix, option, value): if option.endswith('dir') and os.path.isabs(value) and \ option not in builtin_dir_noprefix_options: # Value must be a subdir of the prefix - if os.path.commonpath([value, prefix]) != prefix: + if commonpath([value, prefix]) != prefix: m = 'The value of the {!r} option is {!r} which must be a ' \ 'subdir of the prefix {!r}.\nNote that if you pass a ' \ 'relative path, it is assumed to be a subdir of prefix.' @@ -194,9 +195,9 @@ def set_builtin_option(self, optname, value): elif optname in self.builtins: prefix = self.builtins['prefix'].value value = self.sanitize_dir_option_value(prefix, optname, value) - self.builtins[optname].set_value(value) else: raise RuntimeError('Tried to set unknown builtin option %s.' % optname) + self.builtins[optname].set_value(value) def load(filename): load_fail_msg = 'Coredata file {!r} is corrupted. Try with a fresh build tree.'.format(filename) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -496,3 +496,28 @@ def Popen_safe(args, write=None, stderr=subprocess.PIPE, **kwargs): stderr=stderr, **kwargs) o, e = p.communicate(write) return p, o, e + +def commonpath(paths): + ''' + For use on Python 3.4 where os.path.commonpath is not available. + We currently use it everywhere so this receives enough testing. + ''' + # XXX: Replace me with os.path.commonpath when we start requiring Python 3.5 + import pathlib + if not paths: + raise ValueError('arg is an empty sequence') + common = pathlib.PurePath(paths[0]) + for path in paths[1:]: + new = [] + path = pathlib.PurePath(path) + for c, p in zip(common.parts, path.parts): + if c != p: + break + new.append(c) + # Don't convert '' into '.' + if not new: + common = '' + break + new = os.path.join(*new) + common = pathlib.PurePath(new) + return str(common) diff --git a/run_unittests.py b/run_unittests.py --- a/run_unittests.py +++ b/run_unittests.py @@ -153,6 +153,23 @@ def test_compiler_args_class(self): a = ['-Ldir', '-Lbah'] + a self.assertEqual(a, ['-Ibar', '-Ifoo', '-Ibaz', '-I..', '-I.', '-Ldir', '-Lbah', '-Werror', '-O3', '-O2', '-Wall']) + def test_commonpath(self): + from os.path import sep + commonpath = mesonbuild.mesonlib.commonpath + self.assertRaises(ValueError, commonpath, []) + self.assertEqual(commonpath(['/usr', '/usr']), sep + 'usr') + self.assertEqual(commonpath(['/usr', '/usr/']), sep + 'usr') + self.assertEqual(commonpath(['/usr', '/usr/bin']), sep + 'usr') + self.assertEqual(commonpath(['/usr/', '/usr/bin']), sep + 'usr') + self.assertEqual(commonpath(['/usr/./', '/usr/bin']), sep + 'usr') + self.assertEqual(commonpath(['/usr/bin', '/usr/bin']), sep + 'usr' + sep + 'bin') + self.assertEqual(commonpath(['/usr//bin', '/usr/bin']), sep + 'usr' + sep + 'bin') + self.assertEqual(commonpath(['/usr/./bin', '/usr/bin']), sep + 'usr' + sep + 'bin') + self.assertEqual(commonpath(['/usr/local', '/usr/lib']), sep + 'usr') + self.assertEqual(commonpath(['/usr', '/bin']), sep) + self.assertEqual(commonpath(['/usr', 'bin']), '') + self.assertEqual(commonpath(['blam', 'bin']), '') + class LinuxlikeTests(unittest.TestCase): def setUp(self):
AttributeError: 'module' object has no attribute 'commonpath' ```python Traceback (most recent call last): File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/mesonmain.py", line 286, in run app.generate() File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/mesonmain.py", line 160, in generate intr = interpreter.Interpreter(b, g) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreter.py", line 1198, in __init__ self.parse_project() File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 111, in parse_project self.evaluate_codeblock(self.ast, end=1) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 372, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 55, in wrapped return f(self, node, args, kwargs) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreter.py", line 1581, in func_project self.parse_default_options(kwargs['default_options']) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreter.py", line 1549, in parse_default_options self.coredata.set_builtin_option(key, value) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/coredata.py", line 196, in set_builtin_option value = self.sanitize_dir_option_value(prefix, optname, value) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/coredata.py", line 161, in sanitize_dir_option_value if os.path.commonpath([value, prefix]) != prefix: AttributeError: 'module' object has no attribute 'commonpath' ``` I think it happened after one of tests failed
Actually, commonpath has been added in 3.5 while EL7 has 3.4....
2017-01-29T21:50:57Z
[]
[]
Traceback (most recent call last): File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/mesonmain.py", line 286, in run app.generate() File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/mesonmain.py", line 160, in generate intr = interpreter.Interpreter(b, g) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreter.py", line 1198, in __init__ self.parse_project() File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 111, in parse_project self.evaluate_codeblock(self.ast, end=1) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 372, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreterbase.py", line 55, in wrapped return f(self, node, args, kwargs) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreter.py", line 1581, in func_project self.parse_default_options(kwargs['default_options']) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/interpreter.py", line 1549, in parse_default_options self.coredata.set_builtin_option(key, value) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/coredata.py", line 196, in set_builtin_option value = self.sanitize_dir_option_value(prefix, optname, value) File "/builddir/build/BUILD/meson-0.38.0/mesonbuild/coredata.py", line 161, in sanitize_dir_option_value if os.path.commonpath([value, prefix]) != prefix: AttributeError: 'module' object has no attribute 'commonpath'
8,896
mesonbuild/meson
mesonbuild__meson-1396
7144b03fd412e9a441d9abaa615d90af348a9137
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -19,6 +19,7 @@ from .compilers import * from .mesonlib import EnvironmentException, Popen_safe import configparser +import shlex import shutil build_filename = 'meson.build' @@ -348,7 +349,9 @@ def get_gnu_compiler_type(defines): def detect_c_compiler(self, want_cross): evar = 'CC' if self.is_cross_build() and want_cross: - compilers = [self.cross_info.config['binaries']['c']] + compilers = self.cross_info.config['binaries']['c'] + if not isinstance(compilers, list): + compilers = [compilers] ccache = [] is_cross = True if self.cross_info.need_exe_wrapper(): @@ -356,7 +359,7 @@ def detect_c_compiler(self, want_cross): else: exe_wrap = [] elif evar in os.environ: - compilers = os.environ[evar].split() + compilers = shlex.split(os.environ[evar]) ccache = [] is_cross = False exe_wrap = None @@ -385,13 +388,13 @@ def detect_c_compiler(self, want_cross): continue gtype = self.get_gnu_compiler_type(defines) version = self.get_gnu_version_from_defines(defines) - return GnuCCompiler(ccache + [compiler], version, gtype, is_cross, exe_wrap, defines) + return GnuCCompiler(ccache + compilers, version, gtype, is_cross, exe_wrap, defines) if 'clang' in out: if 'Apple' in out or for_darwin(want_cross, self): cltype = CLANG_OSX else: cltype = CLANG_STANDARD - return ClangCCompiler(ccache + [compiler], version, cltype, is_cross, exe_wrap) + return ClangCCompiler(ccache + compilers, version, cltype, is_cross, exe_wrap) if 'Microsoft' in out or 'Microsoft' in err: # Visual Studio prints version number to stderr but # everything else to stdout. Why? Lord only knows. @@ -400,7 +403,7 @@ def detect_c_compiler(self, want_cross): if '(ICC)' in out: # TODO: add microsoft add check OSX inteltype = ICC_STANDARD - return IntelCCompiler(ccache + [compiler], version, inteltype, is_cross, exe_wrap) + return IntelCCompiler(ccache + compilers, version, inteltype, is_cross, exe_wrap) errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"' if popen_exceptions: errmsg += '\nThe follow exceptions were encountered:'
ccache isn't supported with --cross_file option To be able to use ccache with a cross compiler I've added the 'ccache' string in the cross_file: [binaries] c = ['ccache', '/usr/local/bin/mips-linux-gcc'] Meson fails using the above cross_file: The Meson build system Version: 0.38.1 Source dir: /ssd/lte/app-2/tcommon/src/oma-dm/kt_lib Build dir: /ssd/lte/app-2/tcommon/src/oma-dm/kt_lib/build Build type: cross build Project name: kt_lib Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 286, in run app.generate() File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 160, in generate intr = interpreter.Interpreter(b, g) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1198, in __init__ self.parse_project() File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 111, in parse_project self.evaluate_codeblock(self.ast, end=1) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 372, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 55, in wrapped return f(self, node, args, kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1611, in func_project self.add_languages(args[1:], True) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1727, in add_languages (comp, cross_comp) = self.detect_compilers(lang, need_cross_compiler) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1652, in detect_compilers cross_comp = self.environment.detect_c_compiler(True) File "/usr/lib/python3.5/site-packages/mesonbuild/environment.py", line 371, in detect_c_compiler basename = os.path.basename(compiler).lower() File "/usr/lib64/python3.5/posixpath.py", line 139, in basename i = p.rfind(sep) + 1 AttributeError: 'list' object has no attribute 'rfind' Any idea how to fix that? Thanks Fabio Porcedda
IMHO I've a working solution for this problem, tomorrow i will make a pull request. The basic issue, as I said on the PR, is that we expect a string there, and we don't actually check that it's a string, and throw a traceback if it's any other object. The solution would be to check if it's a string, and use it as a string, and if it's a list, use it as a list. If it's anything else, report a proper error instead of spewing traceback. The function you probably want to use is `mesonlib.stringlistify`.
2017-02-17T13:59:06Z
[]
[]
Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 286, in run app.generate() File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 160, in generate intr = interpreter.Interpreter(b, g) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1198, in __init__ self.parse_project() File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 111, in parse_project self.evaluate_codeblock(self.ast, end=1) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 372, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 55, in wrapped return f(self, node, args, kwargs) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1611, in func_project self.add_languages(args[1:], True) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1727, in add_languages (comp, cross_comp) = self.detect_compilers(lang, need_cross_compiler) File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1652, in detect_compilers cross_comp = self.environment.detect_c_compiler(True) File "/usr/lib/python3.5/site-packages/mesonbuild/environment.py", line 371, in detect_c_compiler basename = os.path.basename(compiler).lower() File "/usr/lib64/python3.5/posixpath.py", line 139, in basename i = p.rfind(sep) + 1 AttributeError: 'list' object has no attribute 'rfind'
8,900
mesonbuild/meson
mesonbuild__meson-1483
1aa940d8444e1f2452ee7b56ee03609f0536f8f7
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -93,9 +93,6 @@ def resolve_source_conflicts(self): def generate_custom_generator_commands(self, target, parent_node): generator_output_files = [] - commands = [] - inputs = [] - outputs = [] custom_target_include_dirs = [] custom_target_output_files = [] target_private_dir = self.relpath(self.get_target_private_dir(target), self.get_target_dir(target)) @@ -116,6 +113,7 @@ def generate_custom_generator_commands(self, target, parent_node): outfilelist = genlist.get_outputs() exe_arr = self.exe_object_to_cmd_array(exe) base_args = generator.get_arglist() + idgroup = ET.SubElement(parent_node, 'ItemGroup') for i in range(len(infilelist)): if len(infilelist) == len(outfilelist): sole_output = os.path.join(target_private_dir, outfilelist[i]) @@ -131,19 +129,10 @@ def generate_custom_generator_commands(self, target, parent_node): args = self.replace_outputs(args, target_private_dir, outfiles_rel) args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir()).replace("@BUILD_DIR@", target_private_dir) for x in args] - fullcmd = exe_arr + self.replace_extra_args(args, genlist) - commands.append(' '.join(self.special_quote(fullcmd))) - inputs.append(infilename) - outputs.extend(outfiles) - if len(commands) > 0: - idgroup = ET.SubElement(parent_node, 'ItemDefinitionGroup') - cbs = ET.SubElement(idgroup, 'CustomBuildStep') - ET.SubElement(cbs, 'Command').text = '\r\n'.join(commands) - ET.SubElement(cbs, 'Inputs').text = ";".join(inputs) - ET.SubElement(cbs, 'Outputs').text = ';'.join(outputs) - ET.SubElement(cbs, 'Message').text = 'Generating custom sources.' - pg = ET.SubElement(parent_node, 'PropertyGroup') - ET.SubElement(pg, 'CustomBuildBeforeTargets').text = 'ClCompile' + cmd = exe_arr + self.replace_extra_args(args, genlist) + cbs = ET.SubElement(idgroup, 'CustomBuild', Include=infilename) + ET.SubElement(cbs, 'Command').text = ' '.join(self.quote_arguments(cmd)) + ET.SubElement(cbs, 'Outputs').text = ';'.join(outfiles) return generator_output_files, custom_target_output_files, custom_target_include_dirs def generate(self, interp): @@ -205,8 +194,7 @@ def get_target_deps(self, t, recursive=False): for d in [target.command] + target.args: if isinstance(d, (build.BuildTarget, build.CustomTarget)): all_deps[d.get_id()] = d - # BuildTarget - else: + elif isinstance(target, build.BuildTarget): for ldep in target.link_targets: all_deps[ldep.get_id()] = ldep for obj_id, objdep in self.get_obj_target_deps(target.objects): @@ -218,6 +206,8 @@ def get_target_deps(self, t, recursive=False): gen_exe = gendep.generator.get_exe() if isinstance(gen_exe, build.Executable): all_deps[gen_exe.get_id()] = gen_exe + else: + raise MesonException('Unknown target type for target %s' % target) if not t or not recursive: return all_deps ret = self.get_target_deps(all_deps, recursive) @@ -340,8 +330,8 @@ def target_to_build_root(self, target): directories = os.path.normpath(target.subdir).split(os.sep) return os.sep.join(['..'] * len(directories)) - def special_quote(self, arr): - return ['&quot;%s&quot;' % i for i in arr] + def quote_arguments(self, arr): + return ['"%s"' % i for i in arr] def create_basic_crap(self, target): project_name = target.name @@ -413,11 +403,11 @@ def gen_custom_target_vcxproj(self, target, ofname, guid): # from the target dir, not the build root. target.absolute_paths = True (srcs, ofilenames, cmd) = self.eval_custom_target_command(target, True) - cmd_templ = '''"%s" ''' * len(cmd) - ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(cmd) + ET.SubElement(customstep, 'Command').text = ' '.join(self.quote_arguments(cmd)) ET.SubElement(customstep, 'Outputs').text = ';'.join(ofilenames) ET.SubElement(customstep, 'Inputs').text = ';'.join(srcs) ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets') + self.generate_custom_generator_commands(target, root) tree = ET.ElementTree(root) tree.write(ofname, encoding='utf-8', xml_declaration=True) @@ -467,14 +457,14 @@ def add_include_dirs(self, lang, parent_node, file_inc_dirs): @staticmethod def has_objects(objects, additional_objects, generated_objects): - # Ignore generated objects, those are automatically used by MSBuild for VS2010, because they are part of - # the CustomBuildStep Outputs. + # Ignore generated objects, those are automatically used by MSBuild because they are part of + # the CustomBuild Outputs. return len(objects) + len(additional_objects) > 0 @staticmethod def add_generated_objects(node, generated_objects): - # Do not add generated objects to project file. Those are automatically used by MSBuild for VS2010, because - # they are part of the CustomBuildStep Outputs. + # Do not add generated objects to project file. Those are automatically used by MSBuild, because + # they are part of the CustomBuild Outputs. return @staticmethod diff --git a/mesonbuild/backend/vs2015backend.py b/mesonbuild/backend/vs2015backend.py --- a/mesonbuild/backend/vs2015backend.py +++ b/mesonbuild/backend/vs2015backend.py @@ -23,14 +23,3 @@ def __init__(self, build): self.platform_toolset = 'v140' self.vs_version = '2015' - @staticmethod - def has_objects(objects, additional_objects, generated_objects): - # VS2015 requires generated objects to be added explicitly to the project file. - return len(objects) + len(additional_objects) + len(generated_objects) > 0 - - @staticmethod - def add_generated_objects(node, generated_objects): - # VS2015 requires generated objects to be added explicitly to the project file. - for s in generated_objects: - ET.SubElement(node, 'Object', Include=s) - return diff --git a/mesonbuild/build.py b/mesonbuild/build.py --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1277,7 +1277,7 @@ def get_target_dependencies(self): for c in self.sources: if hasattr(c, 'held_object'): c = c.held_object - if isinstance(c, (BuildTarget, CustomTarget, GeneratedList)): + if isinstance(c, (BuildTarget, CustomTarget)): deps.append(c) return deps @@ -1402,8 +1402,17 @@ def get_filename(self): def get_sources(self): return self.sources + def get_generated_lists(self): + genlists = [] + for c in self.sources: + if hasattr(c, 'held_object'): + c = c.held_object + if isinstance(c, GeneratedList): + genlists.append(c) + return genlists + def get_generated_sources(self): - return [] + return self.get_generated_lists() def type_suffix(self): return "@cus"
GeneratedList as input of CustomTarget is broken with VS backends Can be seen in the `common\113 generatorcustom` test: https://ci.appveyor.com/project/jpakkane/meson/build/1.0.925/job/p69h84wd9rtvkdns ``` Traceback (most recent call last): File "C:\projects\meson\mesonbuild\mesonmain.py", line 279, in run app.generate() File "C:\projects\meson\mesonbuild\mesonmain.py", line 169, in generate g.generate(intr) File "C:\projects\meson\mesonbuild\backend\vs2010backend.py", line 168, in generate self.generate_solution(sln_filename, projlist) File "C:\projects\meson\mesonbuild\backend\vs2010backend.py", line 233, in generate_solution all_deps = self.determine_deps(p) File "C:\projects\meson\mesonbuild\backend\vs2010backend.py", line 203, in determine_deps all_deps[d.get_id()] = True AttributeError: 'GeneratedList' object has no attribute 'get_id' ```
@nioncode I tried looking at the code for this and I thought you would be a much better person to tackle this. Do you think you can take a stab at fixing this? :) I'm currently on vacation, but I'll have a look at it after Christmas / New Year if it is not resolved by then. Thanks!
2017-03-20T13:42:01Z
[]
[]
Traceback (most recent call last): File "C:\projects\meson\mesonbuild\mesonmain.py", line 279, in run app.generate() File "C:\projects\meson\mesonbuild\mesonmain.py", line 169, in generate g.generate(intr) File "C:\projects\meson\mesonbuild\backend\vs2010backend.py", line 168, in generate self.generate_solution(sln_filename, projlist) File "C:\projects\meson\mesonbuild\backend\vs2010backend.py", line 233, in generate_solution all_deps = self.determine_deps(p) File "C:\projects\meson\mesonbuild\backend\vs2010backend.py", line 203, in determine_deps all_deps[d.get_id()] = True AttributeError: 'GeneratedList' object has no attribute 'get_id'
8,906
mesonbuild/meson
mesonbuild__meson-1692
f74f78dd89fb94923c5888246e319330bcb412a1
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -720,7 +720,19 @@ def generate_target_install(self, d): d.targets.append([f, outdir, {}, False, None]) def generate_custom_install_script(self, d): - d.install_scripts = self.build.install_scripts + result = [] + srcdir = self.environment.get_source_dir() + builddir = self.environment.get_build_dir() + for i in self.build.install_scripts: + exe = i['exe'] + args = i['args'] + fixed_args = [] + for a in args: + a = a.replace('@SOURCE_ROOT@', srcdir) + a = a.replace('@BUILD_ROOT@', builddir) + fixed_args.append(a) + result.append(build.RunScript(exe, fixed_args)) + d.install_scripts = result def generate_header_install(self, d): incroot = self.environment.get_includedir()
@BUILD_ROOT@ and @SOURCE_ROOT@ don't get replaced before running gtk-doc helper This happens when building gstreamer with gtk-doc enabled. Running `git bisect` shows it is caused by commit 976c9ab. ``` Running custom install script '/usr/local/bin/python3 /tmp/meson/meson.py --internal gtkdoc --sourcedir=/home/lantw44/gnome/source/gstreamer --builddir=/tmp/gstreamer-build --subdir=docs/gst --headerdirs=/home/lantw44/gnome/source/gstreamer/docs/gst/../../gst --mainfile=gstreamer-docs.sgml --modulename=gstreamer --mode=auto --scanargs=--deprecated-guards=GST_DISABLE_DEPRECATED@@--ignore-decorators=GST_EXPORT@@--ignore-headers=gettext.h glib-compat-private.h glib-compat.h gst-i18n-app.h gst-i18n-lib.h gst_private.h gstelementdetails.h gstmacros.h grammar.tab.h grammar.tab.pre.h math-compat.h types.h --gobjects-types-file=/tmp/gstreamer-build/docs/gst/gstreamer.types --content-files=building.xml@@running.xml@@/tmp/gstreamer-build/docs/version.entities --cflags=-I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread --ldflags=-lgstreamer-1.0 -L/tmp/gstreamer-build/gst -Wl,-rpath /tmp/gstreamer-build/gst -L/home/lantw44/gnome/devinstall/lib -lgobject-2.0 -lglib-2.0 -lintl -lgmodule-2.0 -pthread -lm -L/usr/local/lib -lunwind -lexecinfo --cc=clang -pedantic -std=c11 --ld=clang -pedantic -std=c11' Building documentation for gstreamer Error in gtkdoc helper script: 'gtkdoc-scangobj' failed with status 1 gstreamer-scan.c:7:10: fatal error: 'gst/gst.h' file not found #include <gst/gst.h> ^ 1 error generated. Traceback (most recent call last): File "/home/lantw44/gnome/devinstall/bin/gtkdoc-scangobj", line 69, in <module> sys.exit(scangobj.run(options)) File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/scangobj.py", line 1255, in run res = subprocess.check_call(command, shell=True) File "/usr/local/lib/python2.7/subprocess.py", line 186, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command 'clang -pedantic -std=c11 >/dev/null -I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread -c -o gstreamer-scan.o gstreamer-scan.c' returned non-zero exit status 1 ```
2017-04-27T16:09:01Z
[]
[]
Traceback (most recent call last): File "/home/lantw44/gnome/devinstall/bin/gtkdoc-scangobj", line 69, in <module> sys.exit(scangobj.run(options)) File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/scangobj.py", line 1255, in run res = subprocess.check_call(command, shell=True) File "/usr/local/lib/python2.7/subprocess.py", line 186, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command 'clang -pedantic -std=c11 >/dev/null -I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread -c -o gstreamer-scan.o gstreamer-scan.c' returned non-zero exit status 1
8,932
mesonbuild/meson
mesonbuild__meson-1694
f74f78dd89fb94923c5888246e319330bcb412a1
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -687,17 +687,37 @@ def get_filenames_templates_dict(inputs, outputs): values['@OUTDIR@'] = '.' return values -class OrderedSet(collections.OrderedDict): - ''' - A 'set' equivalent that preserves the order in which items are added. - - This is a hack implementation that wraps OrderedDict. It may not be the - most efficient solution and might need fixing to override more methods. - ''' +class OrderedSet(collections.MutableSet): + """A set that preserves the order in which items are added, by first + insertion. + """ def __init__(self, iterable=None): + self.__container = collections.OrderedDict() if iterable: self.update(iterable) + def __contains__(self, value): + return value in self.__container + + def __iter__(self): + return iter(self.__container.keys()) + + def __len__(self): + return len(self.__container) + + def __repr__(self): + # Don't print 'OrderedSet("")' for an empty set. + if self.__container: + return 'OrderedSet("{}")'.format('", "'.join(self.__container.keys())) + return 'OrderedSet()' + + def add(self, value): + self.__container[value] = None + + def discard(self, value): + if value in self.__container: + del self.__container[value] + def update(self, iterable): for item in iterable: - self[item] = True + self.__container[item] = None
New OrderedSet does not work with python 3.4 Here's a simple unit test: ``` diff --git a/run_unittests.py b/run_unittests.py index 1d80aac..1251517 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -24,7 +24,7 @@ from pathlib import PurePath import mesonbuild.compilers import mesonbuild.environment import mesonbuild.mesonlib -from mesonbuild.mesonlib import is_windows, is_osx, is_cygwin +from mesonbuild.mesonlib import is_windows, is_osx, is_cygwin, OrderedSet from mesonbuild.environment import Environment from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram @@ -316,6 +316,10 @@ class InternalTests(unittest.TestCase): cmd = ['@[email protected]', 'ordinary', 'strings'] self.assertRaises(ME, substfunc, cmd, d) + def test_ordered_set(self): + oset = OrderedSet() + oset.update(['foo']) + class BasePlatformTests(unittest.TestCase): def setUp(self): ``` This fails with: ``` ====================================================================== ERROR: test_ordered_set (__main__.InternalTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "./run_unittests.py", line 321, in test_ordered_set oset.update(['foo']) File "/home/meh/devel/sandbox/meson/mesonbuild/mesonlib.py", line 703, in update self[item] = True File "/usr/lib64/python3.4/collections/__init__.py", line 68, in __setitem__ self.__map[key] = link = Link() AttributeError: 'OrderedSet' object has no attribute '_OrderedDict__map' ``` My python version is 3.4.3. I'm a bit surprised at this OrderedSet implementation, I would suggest using something like: https://github.com/hotdoc/hotdoc/blob/master/hotdoc/utils/utils.py#L188
2017-04-27T18:58:56Z
[]
[]
Traceback (most recent call last): File "./run_unittests.py", line 321, in test_ordered_set oset.update(['foo']) File "/home/meh/devel/sandbox/meson/mesonbuild/mesonlib.py", line 703, in update self[item] = True File "/usr/lib64/python3.4/collections/__init__.py", line 68, in __setitem__ self.__map[key] = link = Link() AttributeError: 'OrderedSet' object has no attribute '_OrderedDict__map'
8,933
mesonbuild/meson
mesonbuild__meson-1879
6662f36ed36b9fbee700993fa24ca99250161873
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -1371,10 +1371,10 @@ def find_library(self, libname, env, extra_dirs): for suffix in suffixes: trial = os.path.join(d, 'lib' + libname + '.' + suffix) if os.path.isfile(trial): - return trial + return [trial] trial2 = os.path.join(d, libname + '.' + suffix) if os.path.isfile(trial2): - return trial2 + return [trial2] return None def thread_flags(self):
gmock dependency does not work if prebuilt version is found Hello all, I tried running test case `frameworks/3 gmock` and got the following result: ``` The Meson build system Version: 0.41.0.dev1 Source dir: /home/pauloalvarez/meson/test cases/frameworks/3 gmock Build dir: /home/pauloalvarez/meson/test cases/frameworks/3 gmock/build Build type: native build Project name: gmock test Native cpp compiler: c++ (gcc 5.4.0) Build machine cpu family: x86_64 Build machine cpu: x86_64 Dependency GTest found: YES (prebuilt) Dependency GMock found: YES (prebuilt) Build targets in project: 1 Traceback (most recent call last): File "/home/pauloalvarez/meson/mesonbuild/mesonmain.py", line 307, in run app.generate() File "/home/pauloalvarez/meson/mesonbuild/mesonmain.py", line 182, in generate g.generate(intr) File "/home/pauloalvarez/meson/mesonbuild/backend/ninjabackend.py", line 193, in generate self.generate_target(t, outfile) File "/home/pauloalvarez/meson/mesonbuild/backend/ninjabackend.py", line 444, in generate_target elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) File "/home/pauloalvarez/meson/mesonbuild/backend/ninjabackend.py", line 2297, in generate_link commands += dep.get_link_args() File "/home/pauloalvarez/meson/mesonbuild/compilers.py", line 462, in __iadd__ raise TypeError('can only concatenate list (not "{}") to list'.format(args)) TypeError: can only concatenate list (not "/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../lib64/libgmock.so") to list ``` Seems to me that the method find_library of class CCompiler, when it resorts to finding the library file itself, does not return the result as a list, but returns it as a string. When the generator class tries to append it to the command list, the concatenation fails and the error is shown. Indeed, the following patch fixes the error for me: ```diff diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index e7c02b27..a2fca417 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -1371,10 +1371,10 @@ class CCompiler(Compiler): for suffix in suffixes: trial = os.path.join(d, 'lib' + libname + '.' + suffix) if os.path.isfile(trial): - return trial + return [trial] trial2 = os.path.join(d, libname + '.' + suffix) if os.path.isfile(trial2): - return trial2 + return [trial2] return None def thread_flags(self): ``` I am not entirely sure if that is the correct solution though, @jpakkane @nirbheek do you have any ideas?
Sorry for the awful formatting. Use triple backticks...
2017-06-02T04:18:19Z
[]
[]
Traceback (most recent call last): File "/home/pauloalvarez/meson/mesonbuild/mesonmain.py", line 307, in run app.generate() File "/home/pauloalvarez/meson/mesonbuild/mesonmain.py", line 182, in generate g.generate(intr) File "/home/pauloalvarez/meson/mesonbuild/backend/ninjabackend.py", line 193, in generate self.generate_target(t, outfile) File "/home/pauloalvarez/meson/mesonbuild/backend/ninjabackend.py", line 444, in generate_target elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) File "/home/pauloalvarez/meson/mesonbuild/backend/ninjabackend.py", line 2297, in generate_link commands += dep.get_link_args() File "/home/pauloalvarez/meson/mesonbuild/compilers.py", line 462, in __iadd__ raise TypeError('can only concatenate list (not "{}") to list'.format(args)) TypeError: can only concatenate list (not "/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../lib64/libgmock.so") to list
8,942
mesonbuild/meson
mesonbuild__meson-190
8cdd4c0c3c74a1286be236a8d3e15cc171c194c4
diff --git a/compilers.py b/compilers.py --- a/compilers.py +++ b/compilers.py @@ -837,8 +837,9 @@ def sanity_check(self, work_dir): if pc.returncode != 0: raise EnvironmentException('Vala compiler %s can not compile programs.' % self.name_string()) - def can_compile(self, fname): - return fname.endswith('.vala') or fname.endswith('.vapi') + def can_compile(self, filename): + suffix = filename.split('.')[-1] + return suffix in ('vala', 'vapi') class RustCompiler(): def __init__(self, exelist, version):
vala: AttributeError: 'RawFilename' object has no attribute 'endswith' ``` python Traceback (most recent call last): File "/usr/share/meson/meson.py", line 188, in run app.generate() File "/usr/share/meson/meson.py", line 141, in generate g.generate() File "/usr/share/meson/ninjabackend.py", line 132, in generate [self.generate_target(t, outfile) for t in self.build.get_targets().values()] File "/usr/share/meson/ninjabackend.py", line 132, in <listcomp> [self.generate_target(t, outfile) for t in self.build.get_targets().values()] File "/usr/share/meson/ninjabackend.py", line 209, in generate_target header_deps)) File "/usr/share/meson/ninjabackend.py", line 1100, in generate_single_compile compiler = self.get_compiler_for_source(src) File "/usr/share/meson/backends.py", line 54, in get_compiler_for_source if i.can_compile(src): File "/usr/share/meson/compilers.py", line 824, in can_compile return fname.endswith('.vala') or fname.endswith('.vapi') AttributeError: 'RawFilename' object has no attribute 'endswith' ```
2015-07-01T18:27:13Z
[]
[]
Traceback (most recent call last): File "/usr/share/meson/meson.py", line 188, in run app.generate() File "/usr/share/meson/meson.py", line 141, in generate g.generate() File "/usr/share/meson/ninjabackend.py", line 132, in generate [self.generate_target(t, outfile) for t in self.build.get_targets().values()] File "/usr/share/meson/ninjabackend.py", line 132, in <listcomp> [self.generate_target(t, outfile) for t in self.build.get_targets().values()] File "/usr/share/meson/ninjabackend.py", line 209, in generate_target header_deps)) File "/usr/share/meson/ninjabackend.py", line 1100, in generate_single_compile compiler = self.get_compiler_for_source(src) File "/usr/share/meson/backends.py", line 54, in get_compiler_for_source if i.can_compile(src): File "/usr/share/meson/compilers.py", line 824, in can_compile return fname.endswith('.vala') or fname.endswith('.vapi') AttributeError: 'RawFilename' object has no attribute 'endswith'
8,943
mesonbuild/meson
mesonbuild__meson-1924
22cfd44221ada3219d9096e15dc8b00d32e0f9f6
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -598,7 +598,7 @@ def yelp(self, state, args, kwargs): langs = mesonlib.stringlistify(kwargs.pop('languages', [])) media = mesonlib.stringlistify(kwargs.pop('media', [])) - symlinks = kwargs.pop('symlink_media', False) + symlinks = kwargs.pop('symlink_media', True) if not isinstance(symlinks, bool): raise MesonException('symlink_media must be a boolean') diff --git a/mesonbuild/scripts/yelphelper.py b/mesonbuild/scripts/yelphelper.py --- a/mesonbuild/scripts/yelphelper.py +++ b/mesonbuild/scripts/yelphelper.py @@ -74,13 +74,24 @@ def install_help(srcdir, blddir, sources, media, langs, install_dir, destdir, pr if not os.path.exists(infile): if lang == 'C': mlog.warning('Media file "%s" did not exist in C directory' % m) + continue elif symlinks: srcfile = os.path.join(c_install_dir, m) mlog.log('Symlinking %s to %s.' % (outfile, srcfile)) if '/' in m or '\\' in m: os.makedirs(os.path.dirname(outfile), exist_ok=True) - os.symlink(srcfile, outfile) - continue + try: + try: + os.symlink(srcfile, outfile) + except FileExistsError: + os.remove(outfile) + os.symlink(srcfile, outfile) + continue + except (NotImplementedError, OSError): + mlog.warning('Symlinking not supported, falling back to copying') + else: + # Lang doesn't have media file so copy it over 'C' one + infile = os.path.join(srcdir, 'C', m) mlog.log('Installing %s to %s' % (infile, outfile)) if '/' in m or '\\' in m: os.makedirs(os.path.dirname(outfile), exist_ok=True)
gnome yelp: install fails with symlink_media if icon exists already Running `ninja install` twice will error out with gnome.yelp(): ```nstalling /tmp/nettool/help/ca/network-connectivity.page to /tmp/prefix/share/help/ca/gnome-nettool/network-connectivity.page Symlinking /tmp/prefix/share/help/ca/gnome-nettool/figures/gnome-nettool-trail.png to /tmp/prefix/share/help/C/gnome-nettool/figures/gnome-nettool-trail.png. Traceback (most recent call last): File "/home/tpm/Devel/meson/meson.py", line 37, in <module> sys.exit(main()) File "/home/tpm/Devel/meson/meson.py", line 34, in main return mesonmain.run(launcher, sys.argv[1:]) File "/home/tpm/Devel/meson/mesonbuild/mesonmain.py", line 269, in run sys.exit(run_script_command(args[1:])) File "/home/tpm/Devel/meson/mesonbuild/mesonmain.py", line 257, in run_script_command return cmdfunc(cmdargs) File "/home/tpm/Devel/meson/mesonbuild/scripts/yelphelper.py", line 114, in run destdir, options.project_id, options.symlinks) File "/home/tpm/Devel/meson/mesonbuild/scripts/yelphelper.py", line 82, in install_help os.symlink(srcfile, outfile) FileExistsError: [Errno 17] File exists: '/tmp/prefix/share/help/C/gnome-nettool/figures/gnome-nettool-trail.png' -> '/tmp/prefix/share/help/ca/gnome-nettool/figures/gnome-nettool-trail.png' Failed to run install script '/usr/bin/python3 /home/tpm/Devel/meson/meson.py --internal yelphelper install --subdir=help --id=gnome-nettool --installdir=share/help --sources=index.page@@introduction.page@@ip-information.page@@network-connectivity.page --symlinks=true --media=figures/gnome-nettool-trail.png@@figures/gnome-nettool.png --langs=ca@@cs@@da@@de@@el@@en_GB@@es@@fr@@hu@@ko@@oc@@pa@@pl@@pt_BR@@ru@@sv@@uk@@vi@@zh_CN' FAILED: install ```
2017-06-10T16:17:35Z
[]
[]
Traceback (most recent call last): File "/home/tpm/Devel/meson/meson.py", line 37, in <module> sys.exit(main()) File "/home/tpm/Devel/meson/meson.py", line 34, in main return mesonmain.run(launcher, sys.argv[1:]) File "/home/tpm/Devel/meson/mesonbuild/mesonmain.py", line 269, in run sys.exit(run_script_command(args[1:])) File "/home/tpm/Devel/meson/mesonbuild/mesonmain.py", line 257, in run_script_command return cmdfunc(cmdargs) File "/home/tpm/Devel/meson/mesonbuild/scripts/yelphelper.py", line 114, in run destdir, options.project_id, options.symlinks) File "/home/tpm/Devel/meson/mesonbuild/scripts/yelphelper.py", line 82, in install_help os.symlink(srcfile, outfile) FileExistsError: [Errno 17] File exists: '/tmp/prefix/share/help/C/gnome-nettool/figures/gnome-nettool-trail.png' -> '/tmp/prefix/share/help/ca/gnome-nettool/figures/gnome-nettool-trail.png'
8,945
mesonbuild/meson
mesonbuild__meson-1953
73c06780f93f7565a39def7ed08e404fbcaae358
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -312,7 +312,7 @@ def _framework_detect(self, qvars, modules, kwargs): fname = 'Qt' + m fwdep = ExtraFrameworkDependency(fname, False, libdir, self.env, self.language, kwargs) - self.cargs.append('-F' + libdir) + self.compile_args.append('-F' + libdir) if fwdep.found(): self.is_found = True self.compile_args += fwdep.get_compile_args()
AttributeError on switch from 0.40.1 to 0.41.0 On the switch from 0.40.1 to 0.41.1 on Mac OS (installed via brew) I now get the following error: ``` ... WARNING: rcc dependencies will not work reliably until this upstream issue is fixed: https://bugreports.qt.io/browse/QTBUG-45460 Found qmake: qmake (5.9.0) Dependency QtCore found: YES /usr/local/Cellar/qt/5.9.0/lib/QtCore.framework Traceback (most recent call last): File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 307, in run app.generate() File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 180, in generate intr.run() File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2544, in run super().run() File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 125, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 153, in evaluate_statement return self.assignment(cur) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 548, in assignment value = self.evaluate_statement(node.value) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 361, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 1922, in func_dependency dep = dependencies.find_external_dependency(name, self.environment, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/base.py", line 610, in find_external_dependency dep = packages[lname](env, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/ui.py", line 363, in __init__ QtBaseDependency.__init__(self, 'qt5', env, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/ui.py", line 183, in __init__ from_text = self._qmake_detect(mods, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/ui.py", line 283, in _qmake_detect return self._framework_detect(qvars, mods, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/ui.py", line 315, in _framework_detect self.cargs.append('-F' + libdir) AttributeError: 'Qt5Dependency' object has no attribute 'cargs' ``` the same meson.build works fine under Arch Linux using meson 0.41.0, so I cannot rule out either a packaging error in brew or a platform specific problem (or wrong usage on my side). With 0.40.1 and with 0.41.0 on other platforms code works as expected Qt dependencies are correctly found and build succeeds. Qt was installed using brew under Mac OS, too. The relevant part of the meson.build checking Qt dependencies is: ``` qt5 = import('qt5') qt5GuiDep = dependency('qt5', modules: [ 'Core', 'Gui'], required: false) qt5QmlDep = dependency('qt5', modules: 'Qml', required: false) qt5QuickDep = dependency('qt5', modules: 'Quick', required: false) qt5WidgetsDep = dependency('qt5', modules: 'Widgets', required: false) qt5SvgDep = dependency('qt5', modules: 'Svg', required: false) qt5NetworkDep = dependency('qt5', modules: 'Network', required: false) qt5LocationDep = dependency('qt5', modules: 'Location', required: false) ``` The error occurs on the first dependency check. The full meson.build can be found at https://github.com/Framstag/libosmscout If further information are needed just tell me.
2017-06-17T18:29:41Z
[]
[]
Traceback (most recent call last): File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 307, in run app.generate() File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 180, in generate intr.run() File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2544, in run super().run() File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 125, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 153, in evaluate_statement return self.assignment(cur) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 548, in assignment value = self.evaluate_statement(node.value) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 361, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 1922, in func_dependency dep = dependencies.find_external_dependency(name, self.environment, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/base.py", line 610, in find_external_dependency dep = packages[lname](env, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/ui.py", line 363, in __init__ QtBaseDependency.__init__(self, 'qt5', env, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/ui.py", line 183, in __init__ from_text = self._qmake_detect(mods, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/ui.py", line 283, in _qmake_detect return self._framework_detect(qvars, mods, kwargs) File "/usr/local/Cellar/meson/0.41.0/lib/python3.6/site-packages/mesonbuild/dependencies/ui.py", line 315, in _framework_detect self.cargs.append('-F' + libdir) AttributeError: 'Qt5Dependency' object has no attribute 'cargs'
8,948
mesonbuild/meson
mesonbuild__meson-1956
3bc7651907e81cacb93f2f160b720dc97b958f05
diff --git a/run_unittests.py b/run_unittests.py --- a/run_unittests.py +++ b/run_unittests.py @@ -1770,16 +1770,22 @@ def test_order_of_l_arguments(self): self.init(testdir) # NOTE: .pc file has -Lfoo -lfoo -Lbar -lbar but pkg-config reorders # the flags before returning them to -Lfoo -Lbar -lfoo -lbar - expected_order = ['-L/me/first', '-L/me/second','-lfoo1', '-lfoo2', - '-L/me/third', '-L/me/fourth', '-lfoo3', '-lfoo4'] + # but pkgconf seems to not do that. Sigh. Support both. + expected_order = [('-L/me/first', '-lfoo1'), + ('-L/me/second', '-lfoo2'), + ('-L/me/first', '-L/me/second'), + ('-lfoo1', '-lfoo2'), + ('-L/me/second', '-L/me/third'), + ('-L/me/third', '-L/me/fourth',), + ('-L/me/third', '-lfoo3'), + ('-L/me/fourth', '-lfoo4'), + ('-lfoo3', '-lfoo4'), + ] with open(os.path.join(self.builddir, 'build.ninja')) as ifile: for line in ifile: - if expected_order[0] in line: - previous_index = line.index(expected_order[0]) - for entry in expected_order[1:]: - current_index = line.index(entry) - self.assertLess(previous_index, current_index) - previous_index = current_index + if expected_order[0][0] in line: + for first, second in expected_order: + self.assertLess(line.index(first), line.index(second)) return raise RuntimeError('Linker entries not found in the Ninja file.')
test_order_of_l_arguments fails on Fedora Rawhide ```python ====================================================================== FAIL: test_order_of_l_arguments (__main__.LinuxlikeTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "run_unittests.py", line 1772, in test_order_of_l_arguments self.assertLess(previous_index, current_index) AssertionError: 85 not less than 78 Stdout: The Meson build system Version: 0.41.0 Source dir: /builddir/build/BUILD/meson-0.41.0/test cases/unit/9 -L -l order Build dir: /tmp/tmpxs97a85i Build type: native build Project name: jonne Native c compiler: cc (gcc 7.1.1) Build machine cpu family: ppc64le Build machine cpu: ppc64le Found pkg-config: /usr/bin/pkg-config (1.3.7) Native dependency first found: YES 1.0.0 Native dependency second found: YES 1.0.0 Build targets in project: 1 ---------------------------------------------------------------------- Ran 53 tests in 39.639s FAILED (failures=1, skipped=7) ```
Can you run the test manually and show us what the linker commandline looks like? You have to just run `PKG_CONFIG_PATH=$PWD meson build`. ``` build lprog: c_LINKER lprog@exe/prog.c.o LINK_ARGS = -Wl,--no-undefined -Wl,--as-needed -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/me/first -Wl,--start-group -lfoo1 -L/me/second -lfoo2 -L/me/third -lfoo3 -L/me/fourth -lfoo4 -Wl,--end-group ``` ``` $ pkg-config --version 1.3.7 ``` P.S. in Fedora we use [pkgconf](https://github.com/pkgconf/pkgconf) nowadays looks like it just finds `-L/me/second` and `-lfoo1` Comment in the unit test for this: # NOTE: .pc file has -Lfoo -lfoo -Lbar -lbar but pkg-config reorders # the flags before returning them to -Lfoo -Lbar -lfoo -lbar
2017-06-18T20:42:48Z
[]
[]
Traceback (most recent call last): File "run_unittests.py", line 1772, in test_order_of_l_arguments self.assertLess(previous_index, current_index) AssertionError: 85 not less than 78
8,949
mesonbuild/meson
mesonbuild__meson-1961
f8c46951ef7ffb26ff1cdc4aa7fb4d59586d76e7
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -510,12 +510,12 @@ def generate_custom_target(self, target, outfile): cmd_type = 'meson_exe.py custom' else: cmd_type = 'custom' - if target.depfile is not None: rel_dfile = os.path.join(self.get_target_dir(target), target.depfile) abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) os.makedirs(abs_pdir, exist_ok=True) elem.add_item('DEPFILE', rel_dfile) + cmd = self.replace_paths(target, cmd) elem.add_item('COMMAND', cmd) elem.add_item('description', desc.format(target.name, cmd_type)) elem.write(outfile) @@ -564,7 +564,9 @@ def generate_run_target(self, target, outfile): else: cmd.append(target.command) cmd += arg_strings + elem.add_dep(deps) + cmd = self.replace_paths(target, cmd) elem.add_item('COMMAND', cmd) elem.add_item('description', 'Running external command %s.' % target.name) elem.add_item('pool', 'console') @@ -1649,6 +1651,16 @@ def generate_generator_list_rules(self, target, outfile): continue self.generate_genlist_for_target(genlist, target, outfile) + def replace_paths(self, target, args): + source_target_dir = self.get_target_source_dir(target) + relout = self.get_target_private_dir(target) + args = [x.replace("@SOURCE_DIR@", self.build_to_src).replace("@BUILD_DIR@", relout) + for x in args] + args = [x.replace("@CURRENT_SOURCE_DIR@", source_target_dir) for x in args] + args = [x.replace("@SOURCE_ROOT@", self.build_to_src).replace("@BUILD_ROOT@", '.') + for x in args] + return args + def generate_genlist_for_target(self, genlist, target, outfile): generator = genlist.get_generator() exe = generator.get_exe() @@ -1682,11 +1694,7 @@ def generate_genlist_for_target(self, genlist, target, outfile): if sole_output == '': outfilelist = outfilelist[len(generator.outputs):] relout = self.get_target_private_dir(target) - args = [x.replace("@SOURCE_DIR@", self.build_to_src).replace("@BUILD_DIR@", relout) - for x in args] - args = [x.replace("@CURRENT_SOURCE_DIR@", source_target_dir) for x in args] - args = [x.replace("@SOURCE_ROOT@", self.build_to_src).replace("@BUILD_ROOT@", '.') - for x in args] + args = self.replace_paths(target, args) cmdlist = exe_arr + self.replace_extra_args(args, genlist) elem = NinjaBuildElement(self.all_outputs, outfiles, rulename, infilename) if generator.depfile is not None:
@BUILD_ROOT@ and @SOURCE_ROOT@ don't get replaced before running gtk-doc helper This happens when building gstreamer with gtk-doc enabled. Running `git bisect` shows it is caused by commit 976c9ab. ``` Running custom install script '/usr/local/bin/python3 /tmp/meson/meson.py --internal gtkdoc --sourcedir=/home/lantw44/gnome/source/gstreamer --builddir=/tmp/gstreamer-build --subdir=docs/gst --headerdirs=/home/lantw44/gnome/source/gstreamer/docs/gst/../../gst --mainfile=gstreamer-docs.sgml --modulename=gstreamer --mode=auto --scanargs=--deprecated-guards=GST_DISABLE_DEPRECATED@@--ignore-decorators=GST_EXPORT@@--ignore-headers=gettext.h glib-compat-private.h glib-compat.h gst-i18n-app.h gst-i18n-lib.h gst_private.h gstelementdetails.h gstmacros.h grammar.tab.h grammar.tab.pre.h math-compat.h types.h --gobjects-types-file=/tmp/gstreamer-build/docs/gst/gstreamer.types --content-files=building.xml@@running.xml@@/tmp/gstreamer-build/docs/version.entities --cflags=-I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread --ldflags=-lgstreamer-1.0 -L/tmp/gstreamer-build/gst -Wl,-rpath /tmp/gstreamer-build/gst -L/home/lantw44/gnome/devinstall/lib -lgobject-2.0 -lglib-2.0 -lintl -lgmodule-2.0 -pthread -lm -L/usr/local/lib -lunwind -lexecinfo --cc=clang -pedantic -std=c11 --ld=clang -pedantic -std=c11' Building documentation for gstreamer Error in gtkdoc helper script: 'gtkdoc-scangobj' failed with status 1 gstreamer-scan.c:7:10: fatal error: 'gst/gst.h' file not found #include <gst/gst.h> ^ 1 error generated. Traceback (most recent call last): File "/home/lantw44/gnome/devinstall/bin/gtkdoc-scangobj", line 69, in <module> sys.exit(scangobj.run(options)) File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/scangobj.py", line 1255, in run res = subprocess.check_call(command, shell=True) File "/usr/local/lib/python2.7/subprocess.py", line 186, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command 'clang -pedantic -std=c11 >/dev/null -I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread -c -o gstreamer-scan.o gstreamer-scan.c' returned non-zero exit status 1 ```
Apparently this is not fixed even in `0.40.1`: ``` ninja -C _build/ gtk4-doc ninja: Entering directory `_build/' [0/1] 'Running external command gtk4-doc.' Building documentation for gtk4 Error in gtkdoc helper script: 'gtkdoc-scangobj' failed with status 1 gtk4-scan.c:7:10: fatal error: gtk/gtkunixprint.h: No such file or directory #include <gtk/gtkunixprint.h> ^~~~~~~~~~~~~~~~~~~~ compilation terminated. Traceback (most recent call last): File "/home/ebassi/gnome/install/bin/gtkdoc-scangobj", line 69, in <module> sys.exit(scangobj.run(options)) File "/home/ebassi/gnome/install/share/gtk-doc/python/gtkdoc/scangobj.py", line 1255, in run res = subprocess.check_call(command, shell=True) File "/usr/lib64/python2.7/subprocess.py", line 186, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command 'gcc >/dev/null -I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I@BUILD_ROOT@/gtk -I@SOURCE_ROOT@/gtk -pthread -I/home/ebassi/gnome/install/include/glib-2.0 -I/home/ebassi/gnome/install/lib/glib-2.0/include -I/home/ebassi/gnome/install/include/gio-unix-2.0/ -I/home/ebassi/gnome/install/include/at-spi2-atk/2.0 -I/home/ebassi/gnome/install/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/home/ebassi/gnome/install/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/harfbuzz -I/home/ebassi/gnome/install/include/gdk-pixbuf-2.0 -I/home/ebassi/gnome/install/include/atk-1.0 -I/home/ebassi/gnome/install/include/graphene-1.0 -I/home/ebassi/gnome/install/lib/graphene-1.0/include -I@BUILD_ROOT@/gdk/x11 -I@SOURCE_ROOT@/gdk/x11 -I@BUILD_ROOT@/gdk/. -I@SOURCE_ROOT@/gdk/. -c -o gtk4-scan.o gtk4-scan.c' returned non-zero exit status 1 FAILED: gtk4-doc '/usr/bin/python3' '/usr/bin/meson' '--internal' 'commandrunner' '/home/ebassi/Sources/gtk+-meson' '/home/ebassi/Sources/gtk+-meson/_build' 'docs/reference/gtk' '/usr/bin/mesonintrospect' '/usr/bin/python3' '/usr/bin/meson' '--internal' 'gtkdoc' '--sourcedir=/home/ebassi/Sources/gtk+-meson' '--builddir=/home/ebassi/Sources/gtk+-meson/_build' '--subdir=docs/reference/gtk' '--headerdirs=/home/ebassi/Sources/gtk+-meson/gtk@@/home/ebassi/Sources/gtk+-meson/_build/gtk' '--mainfile=gtk4-docs.xml' '--modulename=gtk4' '--mode=auto' '--scanargs=--ignore-decorators=_GDK_EXTERN|G_GNUC_WARN_UNUSED_RESULT@@--ignore-headers=' '--gobjects-types-file=gtk4.types' '--fixxrefargs=--html-dir=/home/ebassi/gnome/install/share/gtk-doc/html@@--extra-dir=/home/ebassi/gnome/install/share/gtk-doc/html/glib@@--extra-dir=/home/ebassi/gnome/install/share/gtk-doc/html/gobject@@--extra-dir=/home/ebassi/gnome/install/share/gtk-doc/html/gio@@--extra-dir=/usr/share/gtk-doc/html/cairo@@--extra-dir=/home/ebassi/gnome/install/share/gtk-doc/html/gdk-pixbuf@@--extra-dir=../gdk@@--extra-dir=../gsk' '--cflags=-I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I@BUILD_ROOT@/gtk -I@SOURCE_ROOT@/gtk -pthread -I/home/ebassi/gnome/install/include/glib-2.0 -I/home/ebassi/gnome/install/lib/glib-2.0/include -I/home/ebassi/gnome/install/include/gio-unix-2.0/ -I/home/ebassi/gnome/install/include/at-spi2-atk/2.0 -I/home/ebassi/gnome/install/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/home/ebassi/gnome/install/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/harfbuzz -I/home/ebassi/gnome/install/include/gdk-pixbuf-2.0 -I/home/ebassi/gnome/install/include/atk-1.0 -I/home/ebassi/gnome/install/include/graphene-1.0 -I/home/ebassi/gnome/install/lib/graphene-1.0/include -I@BUILD_ROOT@/gdk/x11 -I@SOURCE_ROOT@/gdk/x11 -I@BUILD_ROOT@/gdk/. -I@SOURCE_ROOT@/gdk/.' '--ldflags=-lgtk-4 -L/home/ebassi/Sources/gtk+-meson/_build/gtk -Wl,-rpath /home/ebassi/Sources/gtk+-meson/_build/gtk -L/home/ebassi/gnome/install/lib -lgmodule-2.0 -pthread -lglib-2.0 -lgio-2.0 -lgobject-2.0 -latk-bridge-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lcairo-gobject -lfontconfig -lfreetype -lgdk_pixbuf-2.0 -latk-1.0 -lepoxy -lm -lgraphene-1.0 -lXi -lX11 -lpangoft2-1.0 -lvulkan -lrt -lxkbcommon -lwayland-client -lwayland-cursor -lwayland-egl -lXrender -lXext -lXcursor -lXdamage -lXfixes -lXcomposite -lXrandr -lXinerama' '--cc=ccache cc' '--ld=ccache cc' ninja: build stopped: subcommand failed. ``` Found by @ebassi. Can we please add a test while fixing it this time? ;) There is a test, we just can't run it until gtk-doc starts working with spaces in path. Is it expected that I still get occurances of `@BUILD_ROOT@` in the `ninja.build` file with git master? These should all have been resolved before writing the `ninja.build` file, right?
2017-06-19T15:53:06Z
[]
[]
Traceback (most recent call last): File "/home/lantw44/gnome/devinstall/bin/gtkdoc-scangobj", line 69, in <module> sys.exit(scangobj.run(options)) File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/scangobj.py", line 1255, in run res = subprocess.check_call(command, shell=True) File "/usr/local/lib/python2.7/subprocess.py", line 186, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command 'clang -pedantic -std=c11 >/dev/null -I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread -c -o gstreamer-scan.o gstreamer-scan.c' returned non-zero exit status 1
8,950
mesonbuild/meson
mesonbuild__meson-1964
cccb932f8f38222dffc6d487b6f7d2d1c648096f
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -158,7 +158,7 @@ def list_buildsystem_files(coredata, builddata): def list_deps(coredata): result = [] - for d in coredata.deps: + for d in coredata.deps.values(): if d.found(): args = {'compile_args': d.get_compile_args(), 'link_args': d.get_link_args()}
mesonintrospect --dependencies no longer works in 0.41.0 ``` Traceback (most recent call last): File "/usr/bin/mesonintrospect", line 20, in <module> sys.exit(mintro.run(sys.argv[1:])) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 245, in run list_deps(coredata) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 162, in list_deps if d.found(): AttributeError: 'tuple' object has no attribute 'found' ``` Broke with 8cf29bd288cb67008a42a5c9503042f975c04a43 in which CoreData.deps was changed to an OrderedDict?
2017-06-19T18:30:05Z
[]
[]
Traceback (most recent call last): File "/usr/bin/mesonintrospect", line 20, in <module> sys.exit(mintro.run(sys.argv[1:])) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 245, in run list_deps(coredata) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 162, in list_deps if d.found(): AttributeError: 'tuple' object has no attribute 'found'
8,951
mesonbuild/meson
mesonbuild__meson-2017
c0ab6e9d5b9cb5e98d3d17eca42b9d596b873b0a
diff --git a/mesonbuild/build.py b/mesonbuild/build.py --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -546,10 +546,14 @@ def unpack_holder(self, d): d = [d] newd = [] for i in d: - if hasattr(i, 'held_object'): - newd.append(i.held_object) - else: - newd.append(i) + if isinstance(i, list): + i = self.unpack_holder(i) + elif hasattr(i, 'held_object'): + i = i.held_object + for t in ['dependencies', 'link_with', 'include_directories', 'sources']: + if hasattr(i, t): + setattr(i, t, self.unpack_holder(getattr(i, t))) + newd.append(i) return newd def copy_kwargs(self, kwargs): @@ -557,10 +561,14 @@ def copy_kwargs(self, kwargs): # This sucks quite badly. Arguments # are holders but they can't be pickled # so unpack those known. - if 'dependencies' in self.kwargs: - self.kwargs['dependencies'] = self.unpack_holder(self.kwargs['dependencies']) - if 'link_with' in self.kwargs: - self.kwargs['link_with'] = self.unpack_holder(self.kwargs['link_with']) + for k, v in self.kwargs.items(): + if isinstance(v, list): + self.kwargs[k] = self.unpack_holder(v) + if hasattr(v, 'held_object'): + self.kwargs[k] = v.held_object + for t in ['dependencies', 'link_with', 'include_directories', 'sources']: + if t in self.kwargs: + self.kwargs[t] = self.unpack_holder(self.kwargs[t]) def extract_objects(self, srclist): obj_src = [] @@ -1490,8 +1498,12 @@ def flatten_command(self, cmd): def process_kwargs(self, kwargs): super().process_kwargs(kwargs) - self.sources = kwargs.get('input', []) - self.sources = flatten(self.sources) + sources = flatten(kwargs.get('input', [])) + self.sources = [] + for s in sources: + if hasattr(s, 'held_object'): + s = s.held_object + self.sources.append(s) if 'output' not in kwargs: raise InvalidArguments('Missing keyword argument "output".') self.outputs = kwargs['output'] diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1308,6 +1308,7 @@ class Interpreter(InterpreterBase): def __init__(self, build, backend, subproject='', subdir='', subproject_dir='subprojects', default_project_options=[]): super().__init__(build.environment.get_source_dir(), subdir) + self.an_unpicklable_object = mesonlib.an_unpicklable_object self.build = build self.environment = build.environment self.coredata = self.environment.get_coredata() @@ -1521,7 +1522,13 @@ def func_declare_dependency(self, node, args, kwargs): if not isinstance(d, (dependencies.Dependency, dependencies.ExternalLibrary, dependencies.InternalDependency)): raise InterpreterException('Dependencies must be external deps') final_deps.append(d) - dep = dependencies.InternalDependency(version, incs, compile_args, link_args, libs, sources, final_deps) + dep = dependencies.InternalDependency(version, + mesonlib.unholder_array(incs), + compile_args, + link_args, + mesonlib.unholder_array(libs), + mesonlib.unholder_array(sources), + final_deps) return DependencyHolder(dep) @noKwargs @@ -2288,6 +2295,7 @@ def add_test(self, node, args, kwargs, is_base_test): for i in cmd_args: if not isinstance(i, (str, mesonlib.File, TargetHolder)): raise InterpreterException('Command line arguments must be strings, files or targets.') + cmd_args = mesonlib.unholder_array(cmd_args) env = self.unpack_env_kwarg(kwargs) should_fail = kwargs.get('should_fail', False) if not isinstance(should_fail, bool): diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -61,6 +61,7 @@ def __init__(self, permitted): self.permitted = permitted def __call__(self, f): + @wraps(f) def wrapped(s, node, args, kwargs): for k in kwargs: if k not in self.permitted: diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -21,6 +21,11 @@ from glob import glob +# Put this in objects that should not get dumped to pickle files +# by accident. +import threading +an_unpicklable_object = threading.Lock() + class MesonException(Exception): '''Exceptions thrown by Meson''' @@ -704,6 +709,14 @@ def windows_proof_rmtree(f): # Try one last time and throw if it fails. shutil.rmtree(f) +def unholder_array(entries): + result = [] + for e in entries: + if hasattr(e, 'held_object'): + e = e.held_object + result.append(e) + return result + class OrderedSet(collections.MutableSet): """A set that preserves the order in which items are added, by first insertion. diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -328,8 +328,10 @@ def _get_dependencies_flags(self, deps, state, depends=None, include_rpath=False if isinstance(dep, InternalDependency): cflags.update(get_include_args(dep.include_directories)) for lib in dep.libraries: - ldflags.update(self._get_link_args(state, lib.held_object, depends, include_rpath)) - libdepflags = self._get_dependencies_flags(lib.held_object.get_external_deps(), state, depends, include_rpath, + if hasattr(lib, 'held_object'): + lib = lib.held_object + ldflags.update(self._get_link_args(state, lib, depends, include_rpath)) + libdepflags = self._get_dependencies_flags(lib.get_external_deps(), state, depends, include_rpath, use_gir_args) cflags.update(libdepflags[0]) ldflags.update(libdepflags[1]) @@ -340,9 +342,11 @@ def _get_dependencies_flags(self, deps, state, depends=None, include_rpath=False ldflags.update(extdepflags[1]) gi_includes.update(extdepflags[2]) for source in dep.sources: - if hasattr(source, 'held_object') and isinstance(source.held_object, GirTarget): + if hasattr(source, 'held_object'): + source = source.held_object + if isinstance(source, GirTarget): gi_includes.update([os.path.join(state.environment.get_build_dir(), - source.held_object.get_subdir())]) + source.get_subdir())]) # This should be any dependency other than an internal one. elif isinstance(dep, Dependency): cflags.update(dep.get_compile_args())
mesonconf traceback: AttributeError 'wrapped' Since commit https://github.com/mesonbuild/meson/commit/80ebc916f78ad736494ffee49f100134954acc2c , I get this python traceback using mesonconf: ``` Traceback (most recent call last): File "/usr/bin/mesonconf", line 20, in <module> sys.exit(mconf.run(sys.argv[1:])) File "/usr/lib/python3.6/site-packages/mesonbuild/mconf.py", line 263, in run c = Conf(builddir) File "/usr/lib/python3.6/site-packages/mesonbuild/mconf.py", line 41, in __init__ self.build = pickle.load(f) AttributeError: 'Interpreter' object has no attribute 'wrapped' ``` It's not for all projects, but I found at least one of your test cases can be used to trigger it: ``` cd "test cases/common/85 internal dependency" meson . bd mesonconf bd ``` Can you reproduce?
2017-06-30T23:14:18Z
[]
[]
Traceback (most recent call last): File "/usr/bin/mesonconf", line 20, in <module> sys.exit(mconf.run(sys.argv[1:])) File "/usr/lib/python3.6/site-packages/mesonbuild/mconf.py", line 263, in run c = Conf(builddir) File "/usr/lib/python3.6/site-packages/mesonbuild/mconf.py", line 41, in __init__ self.build = pickle.load(f) AttributeError: 'Interpreter' object has no attribute 'wrapped'
8,955
mesonbuild/meson
mesonbuild__meson-225
e3873e89d11aa92c41393d69791e8fc5b24328ce
diff --git a/build.py b/build.py --- a/build.py +++ b/build.py @@ -139,9 +139,10 @@ def __init__(self, target, srclist): self.srclist = srclist class BuildTarget(): - def __init__(self, name, subdir, is_cross, sources, objects, environment, kwargs): + def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): self.name = name self.subdir = subdir + self.subproject = subproject # Can not be calculated from subdir as subproject dirname can be changed per project. self.is_cross = is_cross self.sources = [] self.objects = [] @@ -165,6 +166,9 @@ def __init__(self, name, subdir, is_cross, sources, objects, environment, kwargs raise InvalidArguments('Build target %s has no sources.' % name) self.validate_sources() + def get_id(self): + return self.subproject + ':' + self.name + self.type_suffix() + def check_unknown_kwargs(self, kwargs): # Override this method in derived classes that have more # keywords. @@ -578,8 +582,8 @@ def get_generator(self): return self.generator class Executable(BuildTarget): - def __init__(self, name, subdir, is_cross, sources, objects, environment, kwargs): - super().__init__(name, subdir, is_cross, sources, objects, environment, kwargs) + def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): + super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs) self.prefix = '' self.suffix = environment.get_exe_suffix() suffix = environment.get_exe_suffix() @@ -594,8 +598,8 @@ def type_suffix(self): return "@exe" class StaticLibrary(BuildTarget): - def __init__(self, name, subdir, is_cross, sources, objects, environment, kwargs): - super().__init__(name, subdir, is_cross, sources, objects, environment, kwargs) + def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): + super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs) if len(self.sources) > 0 and self.sources[0].endswith('.cs'): raise InvalidArguments('Static libraries not supported for C#.') self.prefix = environment.get_static_lib_prefix() @@ -612,10 +616,10 @@ def type_suffix(self): return "@sta" class SharedLibrary(BuildTarget): - def __init__(self, name, subdir, is_cross, sources, objects, environment, kwargs): + def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): self.version = None self.soversion = None - super().__init__(name, subdir, is_cross, sources, objects, environment, kwargs); + super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs); if len(self.sources) > 0 and self.sources[0].endswith('.cs'): self.suffix = 'dll' self.prefix = 'lib' @@ -704,6 +708,9 @@ def __init__(self, name, subdir, kwargs): mlog.log(mlog.bold('Warning:'), 'Unknown keyword arguments in target %s: %s' % (self.name, ', '.join(unknowns))) + def get_id(self): + return self.name + self.type_suffix() + def process_kwargs(self, kwargs): self.sources = kwargs.get('input', []) if not isinstance(self.sources, list): @@ -811,6 +818,9 @@ def __init__(self, name, command, args, subdir): self.args = args self.subdir = subdir + def get_id(self): + return self.name + self.type_suffix() + def get_basename(self): return self.name @@ -836,8 +846,8 @@ def type_suffix(self): return "@run" class Jar(BuildTarget): - def __init__(self, name, subdir, is_cross, sources, objects, environment, kwargs): - super().__init__(name, subdir, is_cross, sources, objects, environment, kwargs); + def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): + super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs); for s in self.sources: if not s.endswith('.java'): raise InvalidArguments('Jar source %s is not a java file.' % s) diff --git a/interpreter.py b/interpreter.py --- a/interpreter.py +++ b/interpreter.py @@ -1663,7 +1663,7 @@ def add_target(self, name, tobj): % name) # To permit an executable and a shared library to have the # same name, such as "foo.exe" and "libfoo.a". - idname = name + tobj.type_suffix() + idname = tobj.get_id() if idname in self.build.targets: raise InvalidCode('Tried to create target "%s", but a target of that name already exists.' % name) self.build.targets[idname] = tobj @@ -1704,7 +1704,7 @@ def build_target(self, node, args, kwargs, targetholder): else: mlog.debug('Unknown target type:', str(targetholder)) raise RuntimeError('Unreachable code') - target = targetclass(name, self.subdir, is_cross, sources, objs, self.environment, kwargs) + target = targetclass(name, self.subdir, self.subproject, is_cross, sources, objs, self.environment, kwargs) l = targetholder(target) self.add_target(name, l.held_object) self.global_args_frozen = True diff --git a/mesonintrospect.py b/mesonintrospect.py --- a/mesonintrospect.py +++ b/mesonintrospect.py @@ -41,9 +41,10 @@ def list_targets(coredata, builddata): tlist = [] - for target in builddata.get_targets().values(): + for (idname, target) in builddata.get_targets().items(): t = {} t['name'] = target.get_basename() + t['id'] = idname fname = target.get_filename() if isinstance(fname, list): fname = [os.path.join(target.subdir, x) for x in fname] @@ -78,7 +79,7 @@ def list_target_files(target_name, coredata, builddata): except KeyError: print("Unknown target %s." % target_name) sys.exit(1) - sources = [os.path.join(subdir, i) for i in sources] + sources = [os.path.join(i.subdir, i.fname) for i in sources] print(json.dumps(sources)) def list_buildoptions(coredata, builddata): diff --git a/ninjabackend.py b/ninjabackend.py --- a/ninjabackend.py +++ b/ninjabackend.py @@ -162,7 +162,7 @@ def generate_target(self, target, outfile): self.generate_custom_target(target, outfile) if isinstance(target, build.RunTarget): self.generate_run_target(target, outfile) - name = target.get_basename() + target.type_suffix() + name = target.get_id() gen_src_deps = [] if name in self.processed_targets: return
Introspection of target's files is broken The mesonintrospection's --target-files is broken in 0.25.0. It can't find a target by a name that was given by --targets, and, if you change the name to what it really could find it bails out with an exception. ``` > meson build The Meson build system Version: 0.25.0 Source dir: /home/evgenyz/Devel/meson/test Build dir: /home/evgenyz/Devel/meson/test/build Build type: native build Project name: test Native c compiler: cc (gcc 5.1.1) Build targets in project: 2 >mesonintrospect build --targets [{"name": "t", "type": "executable", "installed": false, "filename": "t"}, {"name": "tl", "type": "shared library", "installed": false, "filename": "libtl.so.0.0.0"}] >mesonintrospect build --target-files t Unknown target t. >mesonintrospect build --target-files t@exe Traceback (most recent call last): File "/usr/bin/mesonintrospect", line 167, in <module> list_target_files(options.target_files, coredata, builddata) File "/usr/bin/mesonintrospect", line 81, in list_target_files sources = [os.path.join(subdir, i) for i in sources] File "/usr/bin/mesonintrospect", line 81, in <listcomp> sources = [os.path.join(subdir, i) for i in sources] File "/usr/lib64/python3.4/posixpath.py", line 79, in join if b.startswith(sep): AttributeError: 'File' object has no attribute 'startswith' ```
All in all, introspection looks a little bit orphaned to me. It deserves some integration tests at least. Something like run_introspection_in_process for common tests group. In the original design "name" was an unique identifier but since we now permit multiple different top level target this is not the case any more. I'll need to think about the proper fix for this. It probably means changing the json format to add an `id` field that is unique and possible also `subproject`.
2015-08-12T11:05:37Z
[]
[]
Traceback (most recent call last): File "/usr/bin/mesonintrospect", line 167, in <module> list_target_files(options.target_files, coredata, builddata) File "/usr/bin/mesonintrospect", line 81, in list_target_files sources = [os.path.join(subdir, i) for i in sources] File "/usr/bin/mesonintrospect", line 81, in <listcomp> sources = [os.path.join(subdir, i) for i in sources] File "/usr/lib64/python3.4/posixpath.py", line 79, in join if b.startswith(sep): AttributeError: 'File' object has no attribute 'startswith'
8,967
mesonbuild/meson
mesonbuild__meson-2699
5bc1009109431ad6f72d1ddfcf46ea718123a48b
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -300,7 +300,11 @@ def run(original_args, mainfile=None): elif cmd_name == 'rewrite': return rewriter.run(remaining_args) elif cmd_name == 'configure': - return mconf.run(remaining_args) + try: + return mconf.run(remaining_args) + except MesonException as e: + mlog.log(mlog.red('\nError configuring project:'), e) + sys.exit(1) elif cmd_name == 'wrap': return wraptool.run(remaining_args) elif cmd_name == 'runpython':
meson configure -Doption=unknown-value fails with a traceback Compare: ```console $ meson configure build -Dman=asdf Traceback (most recent call last): File "/usr/bin/meson", line 37, in <module> sys.exit(main()) File "/usr/bin/meson", line 34, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 302, in run return mconf.run(remaining_args) File "/usr/lib/python3.6/site-packages/mesonbuild/mconf.py", line 279, in run c.set_options(options.sets) File "/usr/lib/python3.6/site-packages/mesonbuild/mconf.py", line 130, in set_options tgt.set_value(v) File "/usr/lib/python3.6/site-packages/mesonbuild/coredata.py", line 131, in set_value raise MesonException('Value "%s" for combo option "%s" is not one of the choices. Possible choices are: %s.' % (newvalue, self.name, optionsstring)) mesonbuild.mesonlib.MesonException: Value "asdf" for combo option "man" is not one of the choices. Possible choices are: "auto", "true", "false". $ meson build-tmp -Dman=asdf The Meson build system Version: 0.43.0 Source dir: /home/zbyszek/src/systemd Build dir: /home/zbyszek/src/systemd/build-tmp Build type: native build Meson encountered an error in file meson_options.txt, line 96, column 0: Value "asdf" for combo option "man" is not one of the choices. Possible choices are: "auto", "true", "false". A full log can be found at /home/zbyszek/src/systemd/build-tmp/meson-logs/meson-log.txt ``` This is with meson-0.43.0-1.fc27.noarch.
2017-11-28T18:38:02Z
[]
[]
Traceback (most recent call last): File "/usr/bin/meson", line 37, in <module> sys.exit(main()) File "/usr/bin/meson", line 34, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 302, in run return mconf.run(remaining_args) File "/usr/lib/python3.6/site-packages/mesonbuild/mconf.py", line 279, in run c.set_options(options.sets) File "/usr/lib/python3.6/site-packages/mesonbuild/mconf.py", line 130, in set_options tgt.set_value(v) File "/usr/lib/python3.6/site-packages/mesonbuild/coredata.py", line 131, in set_value raise MesonException('Value "%s" for combo option "%s" is not one of the choices. Possible choices are: %s.' % (newvalue, self.name, optionsstring)) mesonbuild.mesonlib.MesonException: Value "asdf" for combo option "man" is not one of the choices. Possible choices are: "auto", "true", "false".
9,002
mesonbuild/meson
mesonbuild__meson-2721
e1bdc098ca48990322b058e2a2a9fce16c3e7674
diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py --- a/mesonbuild/compilers/vala.py +++ b/mesonbuild/compilers/vala.py @@ -94,3 +94,9 @@ def find_library(self, libname, env, extra_dirs): return [vapi] mlog.debug('Searched {!r} and {!r} wasn\'t found'.format(extra_dirs, libname)) return None + + def thread_flags(self): + return [] + + def thread_link_flags(self): + return []
Thread dependency failure when building code mixed with Vala Building a Vala executable, which has a transitive dependency on threads results in the following error: ``` Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 352, in run app.generate() File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 147, in generate self._generate(env) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 197, in _generate g.generate(intr) File "/usr/lib/python3.6/site-packages/mesonbuild/backend/ninjabackend.py", line 210, in generate self.generate_target(t, outfile) File "/usr/lib/python3.6/site-packages/mesonbuild/backend/ninjabackend.py", line 347, in generate_target vala_generated_sources = self.generate_vala_compile(target, outfile) File "/usr/lib/python3.6/site-packages/mesonbuild/backend/ninjabackend.py", line 1146, in generate_vala_compile args = self.generate_basic_compiler_args(target, valac) File "/usr/lib/python3.6/site-packages/mesonbuild/backend/backends.py", line 510, in generate_basic_compiler_args commands += compiler.thread_flags() AttributeError: 'ValaCompiler' object has no attribute 'thread_flags' ``` I encountered this while trying to port gnome-sudoku. It uses a helper library, which has some C++ code in it and needs to be linked with pthreads.
2017-12-01T11:41:06Z
[]
[]
Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 352, in run app.generate() File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 147, in generate self._generate(env) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 197, in _generate g.generate(intr) File "/usr/lib/python3.6/site-packages/mesonbuild/backend/ninjabackend.py", line 210, in generate self.generate_target(t, outfile) File "/usr/lib/python3.6/site-packages/mesonbuild/backend/ninjabackend.py", line 347, in generate_target vala_generated_sources = self.generate_vala_compile(target, outfile) File "/usr/lib/python3.6/site-packages/mesonbuild/backend/ninjabackend.py", line 1146, in generate_vala_compile args = self.generate_basic_compiler_args(target, valac) File "/usr/lib/python3.6/site-packages/mesonbuild/backend/backends.py", line 510, in generate_basic_compiler_args commands += compiler.thread_flags() AttributeError: 'ValaCompiler' object has no attribute 'thread_flags'
9,007
mesonbuild/meson
mesonbuild__meson-2743
de99b9d5b99cb2a9b038714366884942a45d8ffc
diff --git a/mesonbuild/scripts/commandrunner.py b/mesonbuild/scripts/commandrunner.py --- a/mesonbuild/scripts/commandrunner.py +++ b/mesonbuild/scripts/commandrunner.py @@ -38,7 +38,10 @@ def run_command(source_dir, build_dir, subdir, meson_command, command, arguments try: return subprocess.Popen(command_array, env=child_env, cwd=cwd) except FileNotFoundError: - print('Could not execute command "%s".' % command) + print('Could not execute command "%s". File not found.' % command) + sys.exit(1) + except PermissionError: + print('Could not execute command "%s". File not executable.' % command) sys.exit(1) def run(args):
run_target Permission Denied error should be clearer Minimal example - [folder.zip](https://github.com/mesonbuild/meson/files/1530489/folder.zip) I ran - `mkdir build && cd build && meson .. && ninja` and everything works. Now I run - `ninja myscript` and it throws errors - ``` [0/1] Running external command myscript. Traceback (most recent call last): File "/usr/bin/meson", line 37, in <module> sys.exit(main()) File "/usr/bin/meson", line 34, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 311, in run sys.exit(run_script_command(args[1:])) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 278, in run_script_command return cmdfunc(cmdargs) File "/usr/lib/python3.6/site-packages/mesonbuild/scripts/commandrunner.py", line 60, in run pc = run_command(src_dir, build_dir, subdir, meson_command, command, arguments) File "/usr/lib/python3.6/site-packages/mesonbuild/scripts/commandrunner.py", line 39, in run_command return subprocess.Popen(command_array, env=child_env, cwd=cwd) File "/usr/lib/python3.6/subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) PermissionError: [Errno 13] Permission denied: '/home/agauniyal/temp/scripts/script.sh' FAILED: meson-myscript /usr/bin/python /usr/bin/meson --internal commandrunner /home/agauniyal/temp/ /home/agauniyal/temp/build '' /usr/bin/python /usr/bin/meson /home/agauniyal/temp/scripts/script.sh ninja: build stopped: subcommand failed. ```
Your script.sh does not have the right permissions to be executable. Under *nix a file must be marked as executable to be executed. If you try to execute your script you will also get a "Permission denied" error. I recommend you search for a quick introduction on *nix file permissions. As a quick fix use `chmod u+x script.sh` to change the file permissions. Using `ls -l` you can see that the file permissions change from `-rw-r--r--` to `-rwxr--r--`. You're right, this is the 3rd time I've missed marking my scripts as executable 😅 The error should be clearer, and it should not be a traceback. I agree I was thinking about submitting a pull request about this. Should be easy and would be useful.
2017-12-06T20:46:54Z
[]
[]
Traceback (most recent call last): File "/usr/bin/meson", line 37, in <module> sys.exit(main()) File "/usr/bin/meson", line 34, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 311, in run sys.exit(run_script_command(args[1:])) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 278, in run_script_command return cmdfunc(cmdargs) File "/usr/lib/python3.6/site-packages/mesonbuild/scripts/commandrunner.py", line 60, in run pc = run_command(src_dir, build_dir, subdir, meson_command, command, arguments) File "/usr/lib/python3.6/site-packages/mesonbuild/scripts/commandrunner.py", line 39, in run_command return subprocess.Popen(command_array, env=child_env, cwd=cwd) File "/usr/lib/python3.6/subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) PermissionError: [Errno 13] Permission denied: '/home/agauniyal/temp/scripts/script.sh'
9,008
mesonbuild/meson
mesonbuild__meson-2800
fd66692f73efb80783172b9d346ae4a5b6b6fa6d
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -372,7 +372,7 @@ def _get_dependencies_flags(self, deps, state, depends=None, include_rpath=False continue if gir_has_extra_lib_arg() and use_gir_args: - fixed_ldflags = set() + fixed_ldflags = OrderedSet() for ldflag in ldflags: if ldflag.startswith("-l"): fixed_ldflags.add(ldflag.replace('-l', '--extra-library=', 1)) @@ -565,6 +565,7 @@ def generate_gir(self, state, args, kwargs): ldflags += list(dep_ldflags) scan_command += ['--cflags-begin'] scan_command += cflags + scan_command += state.environment.coredata.external_args[lang] scan_command += ['--cflags-end'] # need to put our output directory first as we need to use the # generated libraries instead of any possibly installed system/prefix @@ -595,6 +596,11 @@ def generate_gir(self, state, args, kwargs): d = os.path.join(state.environment.get_build_dir(), d) scan_command.append('-L' + d) scan_command += ['--library', libname] + + for link_arg in state.environment.coredata.external_link_args[lang]: + if link_arg.startswith('-L'): + scan_command.append(link_arg) + scankwargs = {'output': girfile, 'command': scan_command, 'depends': depends} @@ -823,6 +829,8 @@ def _get_build_args(self, kwargs, state): raise MesonException( 'Gir include dirs should be include_directories().') cflags.update(get_include_args(inc_dirs)) + cflags.update(state.environment.coredata.external_args['c']) + ldflags.update(state.environment.coredata.external_link_args['c']) if cflags: args += ['--cflags=%s' % ' '.join(cflags)] if ldflags: diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -14,6 +14,7 @@ import sys, os import subprocess +import shlex import shutil import argparse from ..mesonlib import MesonException, Popen_safe @@ -45,10 +46,13 @@ parser.add_argument('--mode', dest='mode', default='') parser.add_argument('--installdir', dest='install_dir') -def gtkdoc_run_check(cmd, cwd): +def gtkdoc_run_check(cmd, cwd, library_path=None): + env = dict(os.environ) + if library_path: + env['LD_LIBRARY_PATH'] = library_path # Put stderr into stdout since we want to print it out anyway. # This preserves the order of messages. - p, out = Popen_safe(cmd, cwd=cwd, stderr=subprocess.STDOUT)[0:2] + p, out = Popen_safe(cmd, cwd=cwd, env=env, stderr=subprocess.STDOUT)[0:2] if p.returncode != 0: err_msg = ["{!r} failed with status {:d}".format(cmd[0], p.returncode)] if out: @@ -115,7 +119,15 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, '--ldflags=' + ldflags, '--ld=' + ld] - gtkdoc_run_check(scanobjs_cmd, abs_out) + library_paths = [] + for ldflag in shlex.split(ldflags): + if ldflag.startswith('-Wl,-rpath,'): + library_paths.append(ldflag[11:]) + if 'LD_LIBRARY_PATH' in os.environ: + library_paths.append(os.environ['LD_LIBRARY_PATH']) + library_path = ':'.join(library_paths) + + gtkdoc_run_check(scanobjs_cmd, abs_out, library_path) # Make docbook files if mode == 'auto':
gnome.gtkdoc doesn't include linker flags set by LDFLAGS This causes problems when building graphene with gtk-doc enabled in a jhbuild prefix on FreeBSD. LDFLAGS set by jhbuild is `-L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib`, but `-L/usr/local/lib` is missing from the gtkdoc helper command line. ``` Building documentation for graphene Error in gtkdoc helper script: 'gtkdoc-scangobj' failed with status 1 /usr/bin/ld: cannot find -lintl clang: error: linker command failed with exit code 1 (use -v to see invocation) Traceback (most recent call last): File "/home/lantw44/gnome/devinstall/bin/gtkdoc-scangobj", line 69, in <module> sys.exit(scangobj.run(options)) File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/scangobj.py", line 1262, in run res = subprocess.check_call(command, shell=True) File "/usr/local/lib/python2.7/subprocess.py", line 186, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command 'clang -std=gnu11 -pedantic >/dev/null graphene-scan.o -lgraphene-1.0 -L/home/lantw44/gnome/build/graphene/src -Wl,-rpath /home/lantw44/gnome/build/graphene/src -lm -L/home/lantw44/gnome/devinstall/lib -lgobject-2.0 -lglib-2.0 -lintl -o graphene-scan' returned non-zero exit status 1 Failed to run install script '/usr/local/bin/python3 /home/lantw44/gnome/devinstall/bin/meson --internal gtkdoc --sourcedir=/home/lantw44/gnome/source/graphene --builddir=/home/lantw44/gnome/build/graphene --subdir=doc --headerdirs=/home/lantw44/gnome/source/graphene/src@@/home/lantw44/gnome/build/graphene/src --mainfile=graphene-docs.xml --modulename=graphene --mode=auto --scanargs=--rebuild-types@@--ignore-decorators=_GRAPHENE_PUBLIC@@--ignore-headers=config.h graphene.h graphene-alloc-private.h graphene-bench-utils.h graphene-config.h graphene-line-segment-private.h graphene-macros.h graphene-private.h graphene-test-compat.h graphene-version-macros.h graphene-vectors-private.h --gobjects-types-file=graphene.types --fixxrefargs=--html-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html@@--extra-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html/glib@@--extra-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html/gobject --html-assets=rectangle-intersection.png@@rectangle-union.png@@rectangle.png@@triangle-barycentric.png --cflags=-I/home/lantw44/gnome/build/graphene/src/. -I/home/lantw44/gnome/source/graphene/src/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include --ldflags=-lgraphene-1.0 -L/home/lantw44/gnome/build/graphene/src -Wl,-rpath /home/lantw44/gnome/build/graphene/src -lm -L/home/lantw44/gnome/devinstall/lib -lgobject-2.0 -lglib-2.0 -lintl --cc=clang -std=gnu11 -pedantic --ld=clang -std=gnu11 -pedantic' FAILED: install '/usr/local/bin/python3' '/home/lantw44/gnome/devinstall/bin/meson' '--internal' 'install' '/home/lantw44/gnome/build/graphene/meson-private/install.dat' ninja: build stopped: subcommand failed. ```
2017-12-18T16:37:48Z
[]
[]
Traceback (most recent call last): File "/home/lantw44/gnome/devinstall/bin/gtkdoc-scangobj", line 69, in <module> sys.exit(scangobj.run(options)) File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/scangobj.py", line 1262, in run res = subprocess.check_call(command, shell=True) File "/usr/local/lib/python2.7/subprocess.py", line 186, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command 'clang -std=gnu11 -pedantic >/dev/null graphene-scan.o -lgraphene-1.0 -L/home/lantw44/gnome/build/graphene/src -Wl,-rpath /home/lantw44/gnome/build/graphene/src -lm -L/home/lantw44/gnome/devinstall/lib -lgobject-2.0 -lglib-2.0 -lintl -o graphene-scan' returned non-zero exit status 1
9,010
mesonbuild/meson
mesonbuild__meson-2840
c814f1145bc521efd0a46b033751a6f844d24df5
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -25,29 +25,40 @@ def detect_meson_py_location(): c = sys.argv[0] - c_fname = os.path.split(c)[1] - if c_fname == 'meson' or c_fname == 'meson.py': - # $ /foo/meson.py <args> - if os.path.isabs(c): - return c - # $ meson <args> (gets run from /usr/bin/meson) + c_dir, c_fname = os.path.split(c) + + # get the absolute path to the <mesontool> folder + m_dir = None + if os.path.isabs(c): + # $ /foo/<mesontool>.py <args> + m_dir = c_dir + elif c_dir == '': + # $ <mesontool> <args> (gets run from /usr/bin/<mesontool>) in_path_exe = shutil.which(c_fname) if in_path_exe: - # Special case: when run like "./meson.py <opts>" and user has - # period in PATH, we need to expand it out, because, for example, + m_dir, c_fname = os.path.split(in_path_exe) + # Special case: when run like "./meson.py <opts>", + # we need to expand it out, because, for example, # "ninja test" will be run from a different directory. - if '.' in os.environ['PATH'].split(':'): - p, f = os.path.split(in_path_exe) - if p == '' or p == '.': - return os.path.join(os.getcwd(), f) - return in_path_exe - # $ python3 ./meson.py <args> - if os.path.exists(c): - return os.path.join(os.getcwd(), c) - + if m_dir == '.': + m_dir = os.getcwd() + else: + m_dir = os.path.abspath(c_dir) + + # find meson in m_dir + if m_dir is not None: + for fname in ['meson', 'meson.py']: + m_path = os.path.join(m_dir, fname) + if os.path.exists(m_path): + return m_path + + # No meson found, which means that either: + # a) meson is not installed + # b) meson is installed to a non-standard location + # c) the script that invoked mesonlib is not the one of meson tools (e.g. run_unittests.py) # The only thing remaining is to try to find the bundled executable and # pray distro packagers have not moved it. - fname = os.path.join(os.path.dirname(__file__), '..', 'meson.py') + fname = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'meson.py')) if not os.path.exists(fname): raise RuntimeError('Could not determine how to run Meson. Please file a bug with details.') return fname
wraptool error on Debian unstable Hi, Just running : wraptool list Gives me this error : ``` $ wraptool list Traceback (most recent call last): File "/usr/bin/wraptool", line 17, in <module> from mesonbuild.wrap import wraptool File "/usr/share/meson/mesonbuild/wrap/wraptool.py", line 22, in <module> from .wrap import API_ROOT, open_wrapdburl File "/usr/share/meson/mesonbuild/wrap/wrap.py", line 22, in <module> from ..mesonlib import Popen_safe File "/usr/share/meson/mesonbuild/mesonlib.py", line 60, in <module> meson_command = python_command + [detect_meson_py_location()] File "/usr/share/meson/mesonbuild/mesonlib.py", line 51, in detect_meson_py_location raise RuntimeError('Could not determine how to run Meson. Please file a bug with details.') RuntimeError: Could not determine how to run Meson. Please file a bug with details. ``` This is on Debian unstable with meson 0.44.0.
Partly it is because `detect_meson_py_location` only looks for dir+`meson.py` and not also dir+`meson`. If we change this to the following then at least we can find meson: ``` # The only thing remaining is to try to find the bundled executable and # pray distro packagers have not moved it. fname_py = os.path.join(os.path.dirname(__file__), '..', 'meson.py') fname = os.path.join(os.path.dirname(__file__), '..', 'meson') if os.path.exists(fname): return fname elif os.path.exists(fname_py): return fname_py else: raise RuntimeError('Could not determine how to run Meson. Please file a bug with details.') ``` Debian doesn't install a `meson.py` file, only `meson`.
2017-12-28T12:59:37Z
[]
[]
Traceback (most recent call last): File "/usr/bin/wraptool", line 17, in <module> from mesonbuild.wrap import wraptool File "/usr/share/meson/mesonbuild/wrap/wraptool.py", line 22, in <module> from .wrap import API_ROOT, open_wrapdburl File "/usr/share/meson/mesonbuild/wrap/wrap.py", line 22, in <module> from ..mesonlib import Popen_safe File "/usr/share/meson/mesonbuild/mesonlib.py", line 60, in <module> meson_command = python_command + [detect_meson_py_location()] File "/usr/share/meson/mesonbuild/mesonlib.py", line 51, in detect_meson_py_location raise RuntimeError('Could not determine how to run Meson. Please file a bug with details.') RuntimeError: Could not determine how to run Meson. Please file a bug with details.
9,017
mesonbuild/meson
mesonbuild__meson-3036
c4892fb386d2624a74fdf5028a91e3c64b103190
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -323,9 +323,12 @@ def rpaths_for_bundled_shared_libraries(self, target): if os.path.splitext(libpath)[1] not in ['.dll', '.lib', '.so']: continue absdir = os.path.dirname(libpath) - rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] - assert(not os.path.isabs(rel_to_src)) - paths.append(os.path.join(self.build_to_src, rel_to_src)) + if absdir.startswith(self.environment.get_source_dir()): + rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] + assert not os.path.isabs(rel_to_src), 'rel_to_src: {} is absolute'.format(rel_to_src) + paths.append(os.path.join(self.build_to_src, rel_to_src)) + else: + paths.append(absdir) return paths def determine_rpath_dirs(self, target):
Assertion error when using libm from find_library() Running Meson fails with Nautilus, as we do explicit linking with libm. ``` Traceback (most recent call last): File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/mesonmain.py", line 353, in run app.generate() File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/mesonmain.py", line 152, in generate self._generate(env) File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/mesonmain.py", line 209, in _generate g.generate(intr) File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/ninjabackend.py", line 210, in generate self.generate_target(t, outfile) File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/ninjabackend.py", line 461, in generate_target elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/ninjabackend.py", line 2465, in generate_link self.determine_rpath_dirs(target), File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/backends.py", line 337, in determine_rpath_dirs for rp in self.rpaths_for_bundled_shared_libraries(target): File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/backends.py", line 326, in rpaths_for_bundled_shared_libraries assert(not os.path.isabs(rel_to_src)) AssertionError ``` The code in Meson checks if the path is a system path by looking at its prefix, but on my machine it seems to be a bit more exotic: `/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../lib64/libm.so`.
Same problem here building Nautilus in Arch Linux. Did you find a solution? Same problem on windows: ``` Traceback (most recent call last): File "c:\program files\python36\lib\site-packages\mesonbuild\mesonmain.py", line 352, in run app.generate() File "c:\program files\python36\lib\site-packages\mesonbuild\mesonmain.py", line 147, in generate self._generate(env) File "c:\program files\python36\lib\site-packages\mesonbuild\mesonmain.py", line 197, in _generate g.generate(intr) File "c:\program files\python36\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 210, in generate self.generate_target(t, outfile) File "c:\program files\python36\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 461, in generate_target elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) File "c:\program files\python36\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 2460, in generate_link self.determine_rpath_dirs(target), File "c:\program files\python36\lib\site-packages\mesonbuild\backend\backends.py", line 336, in determine_rpath_dirs for rp in self.rpaths_for_bundled_shared_libraries(target): File "c:\program files\python36\lib\site-packages\mesonbuild\backend\backends.py", line 325, in rpaths_for_bundled_shared_libraries assert(not os.path.isabs(rel_to_src)) AssertionError ``` `rel_to_src` seem to be `/<directory>` after adding some debug prints. Adding code to remove the leading `/` fixes the problem. Reverting to 0.42.1 fixes it Is this the proper fix? I thought python should have better ways to manipulate paths than strings.. ```diff -rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] +rel_to_src = absdir[len(self.environment.get_source_dir()) + 2:] ``` I added the following lines, right before the assert. ```python print(absdir) print(self.environment.get_source_dir()) print(rel_to_src) ``` I can now see that `absdir` and `self.environment.get_source_dir()` are completely unrelated if you use: ``` find_library('foo', dirs:'C:\foo\lib') ``` `absdir` will be `c:\foo\lib` and `get_source_dir` will be something like `c:\users\niklas\git\myproj`. The following line is therefore completely wrong. It subtracts the length of a completely unrelated path: ```python rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] ``` I don't know what the real fix is here though..
2018-02-09T21:56:45Z
[]
[]
Traceback (most recent call last): File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/mesonmain.py", line 353, in run app.generate() File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/mesonmain.py", line 152, in generate self._generate(env) File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/mesonmain.py", line 209, in _generate g.generate(intr) File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/ninjabackend.py", line 210, in generate self.generate_target(t, outfile) File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/ninjabackend.py", line 461, in generate_target elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/ninjabackend.py", line 2465, in generate_link self.determine_rpath_dirs(target), File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/backends.py", line 337, in determine_rpath_dirs for rp in self.rpaths_for_bundled_shared_libraries(target): File "/home/ernestas/Development/github.com/mesonbuild/meson/mesonbuild/backend/backends.py", line 326, in rpaths_for_bundled_shared_libraries assert(not os.path.isabs(rel_to_src)) AssertionError
9,037
mesonbuild/meson
mesonbuild__meson-3061
3f51745b414d027785666aa6790aff1bdb36b3c8
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3231,6 +3231,12 @@ def _func_custom_target_impl(self, node, args, kwargs): 'Implementation-only, without FeatureNew checks, for internal use' name = args[0] kwargs['install_mode'] = self._get_kwarg_install_mode(kwargs) + if 'input' in kwargs: + try: + kwargs['input'] = self.source_strings_to_files(extract_as_list(kwargs, 'input')) + except mesonlib.MesonException: + mlog.warning('''Custom target input \'%s\' can\'t be converted to File object(s). +This will become a hard error in the future.''' % kwargs['input']) tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, self.subproject, kwargs), self) self.add_target(name, tg.held_object) return tg @@ -3908,7 +3914,7 @@ def source_strings_to_files(self, sources): sources = [sources] for s in sources: if isinstance(s, (mesonlib.File, GeneratedListHolder, - CustomTargetHolder, CustomTargetIndexHolder)): + TargetHolder, CustomTargetIndexHolder)): pass elif isinstance(s, str): self.validate_within_subproject(self.subdir, s) diff --git a/run_unittests.py b/run_unittests.py --- a/run_unittests.py +++ b/run_unittests.py @@ -2372,6 +2372,38 @@ def test_cross_file_system_paths(self): self.init(testdir, ['--cross-file=' + name], inprocess=True) self.wipe() + def test_introspect_target_files(self): + ''' + Tests that mesonintrospect --target-files returns expected output. + ''' + testdir = os.path.join(self.common_test_dir, '8 install') + self.init(testdir) + expected = { + 'stat@sta': ['stat.c'], + 'prog@exe': ['prog.c'], + } + t_intro = self.introspect('--targets') + self.assertCountEqual([t['id'] for t in t_intro], expected) + for t in t_intro: + id = t['id'] + tf_intro = self.introspect(['--target-files', id]) + self.assertEqual(tf_intro, expected[id]) + self.wipe() + + testdir = os.path.join(self.common_test_dir, '53 custom target') + self.init(testdir) + expected = { + 'bindat@cus': ['data_source.txt'], + 'depfile@cus': [], + } + t_intro = self.introspect('--targets') + self.assertCountEqual([t['id'] for t in t_intro], expected) + for t in t_intro: + id = t['id'] + tf_intro = self.introspect(['--target-files', id]) + self.assertEqual(tf_intro, expected[id]) + self.wipe() + def test_compiler_run_command(self): ''' The test checks that the compiler object can be passed to
mintro: AttributeError: 'str' object has no attribute 'subdir' Running this in [Mesa](/mesa3d/mesa) breaks meson: ``` $ meson -v 0.44.0 $ meson introspect --target-files egd_tables.h@cus Traceback (most recent call last): File "/usr/bin/meson", line 37, in <module> sys.exit(main()) File "/usr/bin/meson", line 34, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 297, in run return mintro.run(remaining_args) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 236, in run list_target_files(options.target_files, coredata, builddata) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 118, in list_target_files sources = [os.path.join(i.subdir, i.fname) for i in sources] File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 118, in <listcomp> sources = [os.path.join(i.subdir, i.fname) for i in sources] AttributeError: 'str' object has no attribute 'subdir' ```
2018-02-13T16:38:14Z
[]
[]
Traceback (most recent call last): File "/usr/bin/meson", line 37, in <module> sys.exit(main()) File "/usr/bin/meson", line 34, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 297, in run return mintro.run(remaining_args) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 236, in run list_target_files(options.target_files, coredata, builddata) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 118, in list_target_files sources = [os.path.join(i.subdir, i.fname) for i in sources] File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 118, in <listcomp> sources = [os.path.join(i.subdir, i.fname) for i in sources] AttributeError: 'str' object has no attribute 'subdir'
9,041
mesonbuild/meson
mesonbuild__meson-3188
86f725c1e523088c691432c608b3228499ca3c7b
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -169,7 +169,7 @@ def detect_vs_dep_prefix(self, tempfilename): break else: # None of our compilers are MSVC, we're done. - return open(tempfilename, 'a') + return open(tempfilename, 'a', encoding='utf-8') filename = os.path.join(self.environment.get_scratch_dir(), 'incdetect.c') with open(filename, 'w') as f: @@ -196,7 +196,7 @@ def detect_vs_dep_prefix(self, tempfilename): if match: with open(tempfilename, 'ab') as binfile: binfile.write(b'msvc_deps_prefix = ' + match.group(1) + b'\n') - return open(tempfilename, 'a') + return open(tempfilename, 'a', encoding='utf-8') raise MesonException('Could not determine vs dep dependency prefix string.') def generate(self, interp): @@ -206,7 +206,7 @@ def generate(self, interp): raise MesonException('Could not detect Ninja v1.5 or newer') outfilename = os.path.join(self.environment.get_build_dir(), self.ninja_filename) tempfilename = outfilename + '~' - with open(tempfilename, 'w') as outfile: + with open(tempfilename, 'w', encoding='utf-8') as outfile: outfile.write('# This is the build file for project "%s"\n' % self.build.get_project()) outfile.write('# It is autogenerated by the Meson build system.\n') diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -227,7 +227,7 @@ def get_target_deps(self, t, recursive=False): def generate_solution(self, sln_filename, projlist): default_projlist = self.get_build_by_default_targets() - with open(sln_filename, 'w') as ofile: + with open(sln_filename, 'w', encoding='utf-8') as ofile: ofile.write('Microsoft Visual Studio Solution File, Format ' 'Version 11.00\n') ofile.write('# Visual Studio ' + self.vs_version + '\n') @@ -575,7 +575,7 @@ def _prettyprint_vcxproj_xml(self, tree, ofname): tree.write(ofname, encoding='utf-8', xml_declaration=True) # ElementTree can not do prettyprinting so do it manually doc = xml.dom.minidom.parse(ofname) - with open(ofname, 'w') as of: + with open(ofname, 'w', encoding='utf-8') as of: of.write(doc.toprettyxml()) def gen_vcxproj(self, target, ofname, guid): @@ -1119,7 +1119,7 @@ def gen_regenproj(self, project_name, ofname): igroup = ET.SubElement(root, 'ItemGroup') rulefile = os.path.join(self.environment.get_scratch_dir(), 'regen.rule') if not os.path.exists(rulefile): - with open(rulefile, 'w') as f: + with open(rulefile, 'w', encoding='utf-8') as f: f.write("# Meson regen file.") custombuild = ET.SubElement(igroup, 'CustomBuild', Include=rulefile) message = ET.SubElement(custombuild, 'Message') diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -13,9 +13,44 @@ # limitations under the License. import re +import codecs from .mesonlib import MesonException from . import mlog +# This is the regex for the supported escape sequences of a regular string +# literal, like 'abc\x00' +ESCAPE_SEQUENCE_SINGLE_RE = re.compile(r''' + ( \\U........ # 8-digit hex escapes + | \\u.... # 4-digit hex escapes + | \\x.. # 2-digit hex escapes + | \\[0-7]{1,3} # Octal escapes + | \\N\{[^}]+\} # Unicode characters by name + | \\[\\'abfnrtv] # Single-character escapes + )''', re.UNICODE | re.VERBOSE) + +# This is the regex for the supported escape sequences of a multiline string +# literal, like '''abc\x00'''. The only difference is that single quote (') +# doesn't require escaping. +ESCAPE_SEQUENCE_MULTI_RE = re.compile(r''' + ( \\U........ # 8-digit hex escapes + | \\u.... # 4-digit hex escapes + | \\x.. # 2-digit hex escapes + | \\[0-7]{1,3} # Octal escapes + | \\N\{[^}]+\} # Unicode characters by name + | \\[\\abfnrtv] # Single-character escapes + )''', re.UNICODE | re.VERBOSE) + +class MesonUnicodeDecodeError(MesonException): + def __init__(self, match): + super().__init__("%s" % match) + self.match = match + +def decode_match(match): + try: + return codecs.decode(match.group(0), 'unicode_escape') + except UnicodeDecodeError as err: + raise MesonUnicodeDecodeError(match.group(0)) + class ParseException(MesonException): def __init__(self, text, line, lineno, colno): # Format as error message, followed by the line with the error, followed by a caret to show the error column. @@ -112,7 +147,6 @@ def lex(self, subdir): par_count = 0 bracket_count = 0 col = 0 - newline_rx = re.compile(r'(?<!\\)((?:\\\\)*)\\n') while loc < len(self.code): matched = False value = None @@ -145,12 +179,18 @@ def lex(self, subdir): if match_text.find("\n") != -1: mlog.warning("""Newline character in a string detected, use ''' (three single quotes) for multiline strings instead. This will become a hard error in a future Meson release.""", self.getline(line_start), lineno, col) - value = match_text[1:-1].replace(r"\'", "'") - value = newline_rx.sub(r'\1\n', value) - value = value.replace(r" \\ ".strip(), r" \ ".strip()) + value = match_text[1:-1] + try: + value = ESCAPE_SEQUENCE_SINGLE_RE.sub(decode_match, value) + except MesonUnicodeDecodeError as err: + raise MesonException("Failed to parse escape sequence: '{}' in string:\n {}".format(err.match, match_text)) elif tid == 'multiline_string': tid = 'string' value = match_text[3:-3] + try: + value = ESCAPE_SEQUENCE_MULTI_RE.sub(decode_match, value) + except MesonUnicodeDecodeError as err: + raise MesonException("Failed to parse escape sequence: '{}' in string:\n{}".format(err.match, match_text)) lines = match_text.split('\n') if len(lines) > 1: lineno += len(lines) - 1
Unable to use find's `print0` with meson On Linux you can have some *super* weird characters in your paths -- include newlines. This means the only safe character you can use is the null terminator. find and xarg provide tools for doing this; * From the find man page; ``` -print0 True; print the full file name on the standard output, followed by a null character (instead of the newline character that -print uses). This allows file names that con‐ tain newlines or other types of white space to be correctly interpreted by programs that process the find output. This option corresponds to the -0 option of xargs. ``` * From the xargs man page; ``` -0, --null Input items are terminated by a null character instead of by whitespace, and the quotes and backslash are not special (every character is taken literally). Disables the end of file string, which is treated like any other argument. Useful when input items might contain white space, quote marks, or backslashes. The GNU find -print0 option produces input suitable for this mode. ``` However, when you try and to this with meson using the following; ```meson project('100 print null') find_file_list = run_command(find_program('find'), '-type', 'f', '-print0') assert(find_file_list.returncode() == 0, 'Didn\'t find any files.') found_files = [] foreach l : find_file_list.stdout().split('\0') found_files += [files([l])] endforeach ``` You get the following error output; ``` tansell@tansell:~/github/mesonbuild/meson/test cases/common/100 print null$ meson build . The Meson build system Version: 0.45.0.dev1 Source dir: XXXX/github/mesonbuild/meson/test cases/common/100 print null Build dir: XXXX/github/mesonbuild/meson/test cases/common/100 print null/build Build type: native build Project name: 100 print null Build machine cpu family: x86_64 Build machine cpu: x86_64 Program find found: YES (/usr/bin/find) Traceback (most recent call last): File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 363, in run app.generate() File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 150, in generate self._generate(env) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 197, in _generate intr.run() File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2992, in run super().run() File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 173, in run self.evaluate_codeblock(self.ast, start=1) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 195, in evaluate_codeblock raise e File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 189, in evaluate_codeblock self.evaluate_statement(cur) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 230, in evaluate_statement return self.evaluate_foreach(cur) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 404, in evaluate_foreach self.evaluate_codeblock(node.block) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 195, in evaluate_codeblock raise e File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 189, in evaluate_codeblock self.evaluate_statement(cur) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 232, in evaluate_statement return self.evaluate_plusassign(cur) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 409, in evaluate_plusassign addition = self.evaluate_statement(node.value) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 216, in evaluate_statement return self.evaluate_arraystatement(cur) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 243, in evaluate_arraystatement (arguments, kwargs) = self.reduce_arguments(cur.args) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 640, in reduce_arguments reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments] File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 640, in <listcomp> reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments] File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 200, in evaluate_statement return self.function_call(cur) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 456, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 55, in wrapped return f(self, node, args, kwargs) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 47, in wrapped return f(self, node, args, kwargs) File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1614, in func_files return [mesonlib.File.from_source_file(self.environment.source_dir, self.subdir, fname) for fname in args] File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1614, in <listcomp> return [mesonlib.File.from_source_file(self.environment.source_dir, self.subdir, fname) for fname in args] File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/mesonlib.py", line 230, in from_source_file if not os.path.isfile(os.path.join(source_root, subdir, fname)): File "/usr/lib/python3.5/genericpath.py", line 30, in isfile st = os.stat(path) ValueError: embedded null byte ```
In Meson it is considered bad practice to use any shell tools, because they are inherently not portable. If you need to do anything more complex, it is recommended to write a Python script do do that instead. I'm personally totally fine with having a documented limitation that Meson does not handle file names with newlines in them. @jpakkane I can replace the find command with an equivalent Python script pretty easily. However, what I don't understand is how the embedded null byte error is happening? Does `xxx.split('\0')` not strip the value? The docs; > * split(split_character) splits the string at the specified character (or whitespace if not set) and returns the parts in an array. don't really mention if the split character is included in the returned value? Strings support a [limited number of escape characters](http://mesonbuild.com/Syntax.html#strings). `\0` is not one of them. I don't see that mentioned there at all? @jpakkane Do you want to support `\0` as an escape sequence or do you want to emit errors on all common escape sequences `\X`? I think failing with a stracktrace is not very nice. Since `\` is used as the escape character I think it is wrong to accept single `\` anywhere in a string. Therefore we could easily give an error message if a single `\` is found. Currently I think both `\\` and `\` will result in a `\`. To me it makes sense to support at least `\0` and `\t` which are not completely uncommon. This would also be the "least surprising behavior" as it would imitate python. The full list can be found here: https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals @NickeZ I definitely think some type of error (or atleast a warning) on unknown escape codes would be good.
2018-03-06T09:37:49Z
[]
[]
Traceback (most recent call last): File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 363, in run
9,052
mesonbuild/meson
mesonbuild__meson-3381
e103675a3995f799d65a90595c62ad7f0ed4a088
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -46,7 +46,7 @@ def buildparser(): help='List external dependencies.') parser.add_argument('--projectinfo', action='store_true', dest='projectinfo', default=False, help='Information about projects.') - parser.add_argument('builddir', nargs='?', help='The build directory') + parser.add_argument('builddir', nargs='?', default='.', help='The build directory') return parser def determine_installed_path(target, installdata):
meson introspect fails when options.builddir is None In run(args) (mesonbuild/mintro.py, line 202), options.builddir is checked to see if it is None, but cdata.load(options.builddir) is called anyway, resulting in: ```python Traceback (most recent call last): File "/usr/bin/meson", line 26, in <module> sys.exit(main()) File "/usr/bin/meson", line 23, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 293, in run return mintro.run(remaining_args) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 212, in run coredata = cdata.load(options.builddir) File "/usr/lib/python3.6/site-packages/mesonbuild/coredata.py", line 344, in load filename = os.path.join(build_dir, 'meson-private', 'coredata.dat') ``` I worked around it for now by inserting an else clause: ```python def run(args): datadir = 'meson-private' options = parser.parse_args(args) if options.builddir is not None: datadir = os.path.join(options.builddir, datadir) else: options.builddir='./' ``` I'm using meson 0.45.0, Fedora 28 prerelease, with meson being called from gnome-builder 3.28.0.
Just wanted to say I ran into this problem as well, and m-j-b's solution fixed the issue. can confirm as well, running up-to-date openSUSE Tumbleweed with meson 0.45.0 & gnome-builder 3.28.0.
2018-04-10T15:33:29Z
[]
[]
Traceback (most recent call last): File "/usr/bin/meson", line 26, in <module> sys.exit(main()) File "/usr/bin/meson", line 23, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 293, in run return mintro.run(remaining_args) File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 212, in run coredata = cdata.load(options.builddir) File "/usr/lib/python3.6/site-packages/mesonbuild/coredata.py", line 344, in load filename = os.path.join(build_dir, 'meson-private', 'coredata.dat') ``` I worked around it for now by inserting an else clause:
9,069
mesonbuild/meson
mesonbuild__meson-3399
cb597adb0170a4818a4950ca9a4fe3f6d5a6c9d2
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -749,7 +749,9 @@ def expand_arguments(args): return expended_args def Popen_safe(args, write=None, stderr=subprocess.PIPE, **kwargs): - if sys.version_info < (3, 6) or not sys.stdout.encoding: + import locale + encoding = locale.getpreferredencoding() + if sys.version_info < (3, 6) or not sys.stdout.encoding or encoding.upper() != 'UTF-8': return Popen_safe_legacy(args, write=write, stderr=stderr, **kwargs) p = subprocess.Popen(args, universal_newlines=True, close_fds=False,
Allow running run_command() without capturing binary output which will fail to decode ``` Program glslc found: YES (/usr/local/bin/glslc) Traceback (most recent call last): File "/data/git/meson/mesonbuild/mesonmain.py", line 369, in run app.generate() File "/data/git/meson/mesonbuild/mesonmain.py", line 151, in generate self._generate(env) File "/data/git/meson/mesonbuild/mesonmain.py", line 198, in _generate intr.run() File "/data/git/meson/mesonbuild/interpreter.py", line 3125, in run super().run() File "/data/git/meson/mesonbuild/interpreterbase.py", line 189, in run self.evaluate_codeblock(self.ast, start=1) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 216, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 472, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/data/git/meson/mesonbuild/interpreterbase.py", line 79, in wrapped return f(s, node_or_state, args, kwargs) File "/data/git/meson/mesonbuild/interpreter.py", line 2791, in func_subdir self.evaluate_codeblock(codeblock) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 216, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 472, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/data/git/meson/mesonbuild/interpreterbase.py", line 79, in wrapped return f(s, node_or_state, args, kwargs) File "/data/git/meson/mesonbuild/interpreter.py", line 2791, in func_subdir self.evaluate_codeblock(codeblock) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 226, in evaluate_statement return self.evaluate_if(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 279, in evaluate_if self.evaluate_codeblock(i.block) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 226, in evaluate_statement return self.evaluate_if(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 279, in evaluate_if self.evaluate_codeblock(i.block) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 218, in evaluate_statement return self.assignment(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 690, in assignment value = self.evaluate_statement(node.value) File "/data/git/meson/mesonbuild/interpreterbase.py", line 216, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 472, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/data/git/meson/mesonbuild/interpreterbase.py", line 47, in wrapped return f(self, node, args, kwargs) File "/data/git/meson/mesonbuild/interpreter.py", line 1779, in func_run_command return self.run_command_impl(node, args, kwargs) File "/data/git/meson/mesonbuild/interpreter.py", line 1840, in run_command_impl self.environment.get_build_command() + ['introspect'], in_builddir) File "/data/git/meson/mesonbuild/interpreter.py", line 87, in __init__ pc, self.stdout, self.stderr = self.run_command(cmd, args, source_dir, build_dir, subdir, mesonintrospect, in_builddir) File "/data/git/meson/mesonbuild/interpreter.py", line 109, in run_command p, o, e = Popen_safe(command_array, env=child_env, cwd=cwd) File "/data/git/meson/mesonbuild/mesonlib.py", line 743, in Popen_safe o, e = p.communicate(write) File "/usr/lib64/python3.6/subprocess.py", line 843, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/usr/lib64/python3.6/subprocess.py", line 1554, in _communicate self.stdout.errors) File "/usr/lib64/python3.6/subprocess.py", line 740, in _translate_newlines data = data.decode(encoding, errors) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xae in position 112: invalid start byte samu: job failed: /usr/bin/python3 /usr/bin/meson --internal regenerate /data/git/taisei /data/taisei-build/dev/clang --backend ninja samu: subcommand failed ```
2018-04-13T06:49:34Z
[]
[]
Traceback (most recent call last): File "/data/git/meson/mesonbuild/mesonmain.py", line 369, in run app.generate() File "/data/git/meson/mesonbuild/mesonmain.py", line 151, in generate self._generate(env) File "/data/git/meson/mesonbuild/mesonmain.py", line 198, in _generate intr.run() File "/data/git/meson/mesonbuild/interpreter.py", line 3125, in run super().run() File "/data/git/meson/mesonbuild/interpreterbase.py", line 189, in run self.evaluate_codeblock(self.ast, start=1) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 216, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 472, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/data/git/meson/mesonbuild/interpreterbase.py", line 79, in wrapped return f(s, node_or_state, args, kwargs) File "/data/git/meson/mesonbuild/interpreter.py", line 2791, in func_subdir self.evaluate_codeblock(codeblock) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 216, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 472, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/data/git/meson/mesonbuild/interpreterbase.py", line 79, in wrapped return f(s, node_or_state, args, kwargs) File "/data/git/meson/mesonbuild/interpreter.py", line 2791, in func_subdir self.evaluate_codeblock(codeblock) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 226, in evaluate_statement return self.evaluate_if(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 279, in evaluate_if self.evaluate_codeblock(i.block) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 226, in evaluate_statement return self.evaluate_if(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 279, in evaluate_if self.evaluate_codeblock(i.block) File "/data/git/meson/mesonbuild/interpreterbase.py", line 211, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 205, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 218, in evaluate_statement return self.assignment(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 690, in assignment value = self.evaluate_statement(node.value) File "/data/git/meson/mesonbuild/interpreterbase.py", line 216, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 472, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/data/git/meson/mesonbuild/interpreterbase.py", line 47, in wrapped return f(self, node, args, kwargs) File "/data/git/meson/mesonbuild/interpreter.py", line 1779, in func_run_command return self.run_command_impl(node, args, kwargs) File "/data/git/meson/mesonbuild/interpreter.py", line 1840, in run_command_impl self.environment.get_build_command() + ['introspect'], in_builddir) File "/data/git/meson/mesonbuild/interpreter.py", line 87, in __init__ pc, self.stdout, self.stderr = self.run_command(cmd, args, source_dir, build_dir, subdir, mesonintrospect, in_builddir) File "/data/git/meson/mesonbuild/interpreter.py", line 109, in run_command p, o, e = Popen_safe(command_array, env=child_env, cwd=cwd) File "/data/git/meson/mesonbuild/mesonlib.py", line 743, in Popen_safe o, e = p.communicate(write) File "/usr/lib64/python3.6/subprocess.py", line 843, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/usr/lib64/python3.6/subprocess.py", line 1554, in _communicate self.stdout.errors) File "/usr/lib64/python3.6/subprocess.py", line 740, in _translate_newlines data = data.decode(encoding, errors) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xae in position 112: invalid start byte
9,070
mesonbuild/meson
mesonbuild__meson-3499
d52f892de96d40a4d4a8de278e861c911223a4c3
diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -347,7 +347,9 @@ def fix_elf(fname, new_rpath, verbose=True): e.fix_rpath(new_rpath) def get_darwin_rpaths_to_remove(fname): - out = subprocess.check_output(['otool', '-l', fname], universal_newlines=True) + out = subprocess.check_output(['otool', '-l', fname], + universal_newlines=True, + stderr=subprocess.DEVNULL) result = [] current_cmd = 'FOOBAR' for line in out.split('\n'): @@ -371,9 +373,13 @@ def fix_darwin(fname, new_rpath): return try: for rp in rpaths: - subprocess.check_call(['install_name_tool', '-delete_rpath', rp, fname]) - if new_rpath != '': - subprocess.check_call(['install_name_tool', '-add_rpath', new_rpath, fname]) + subprocess.check_call(['install_name_tool', '-delete_rpath', rp, fname], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) + if new_rpath: + subprocess.check_call(['install_name_tool', '-add_rpath', new_rpath, fname], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) except Exception as e: raise sys.exit(0)
Installing generated manpages crashes on OS X Hi, My project generates manpages using pandoc, and installs them. This apparently fails with recent meson because meson tries to run install-name-tool on them. Thus, from one travis run, I see: ``` Installing src/path-graph to /Users/travis/bali-phy/bin/path-graph Installing doc/bali-phy.1 to /Users/travis/bali-phy/share/man/man1/bali-phy.1 Traceback (most recent call last): File "/usr/local/Cellar/meson/0.46.0/libexec/bin/meson", line 26, in <module> sys.exit(main()) File "/usr/local/Cellar/meson/0.46.0/libexec/bin/meson", line 23, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 308, in run sys.exit(run_script_command(args[1:])) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 257, in run_script_command return cmdfunc(cmdargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/meson_install.py", line 390, in run do_install(datafilename) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/meson_install.py", line 216, in do_install install_targets(d) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/meson_install.py", line 371, in install_targets depfixer.fix_rpath(outname, install_rpath, False) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/depfixer.py", line 391, in fix_rpath fix_darwin(fname, new_rpath) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/depfixer.py", line 376, in fix_darwin subprocess.check_call(['install_name_tool', '-add_rpath', new_rpath, fname]) File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 286, in check_call retcode = call(*popenargs, **kwargs) File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 267, in call with Popen(*popenargs, **kwargs) as p: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1275, in _execute_child restore_signals, start_new_session, preexec_fn) TypeError: expected str, bytes or os.PathLike object, not NoneType FAILED: meson-install /usr/local/opt/python/bin/python3.6 /usr/local/Cellar/meson/0.46.0/libexec/bin/meson --internal install /Users/travis/build/bredelings/BAli-Phy/build/meson-private/install.dat ninja: build stopped: subcommand failed. The command "ninja -C build install" exited with 1. ```
I also see the above stack trace on my friend's Mac. Interestingly, one a _different_ travis build in the same matrix, I see the following for each man page: ``` [1/2] Installing files. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: '/Users/travis/bali-phy/share/man/man1/bali-phy.1': The file was not recognized as a valid object file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: '/Users/travis/bali-phy/share/man/man1/model_P.1': The file was not recognized as a valid object file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: '/Users/travis/bali-phy/share/man/man1/statreport.1': The file was not recognized as a valid object file ... Installing src/path-graph to /Users/travis/bali-phy/bin/path-graph Installing doc/bali-phy.1 to /Users/travis/bali-phy/share/man/man1/bali-phy.1 Installing doc/model_P.1 to /Users/travis/bali-phy/share/man/man1/model_P.1 ... ``` This build completed, although it complained. The build that completed was with xcode 8.3, and the builds that failed were with xcode 7.3 and 9.2. The `meson.build` file says: ```meson pandoc = find_program('pandoc', required: false) if pandoc.found() foreach prog : all_progs+['bp-analyze'] markdown = files('man/'+prog+'.md') manpage = prog+'.1' custom_target(manpage,command:[pandoc,'-s','-t','man',markdown], output:manpage, capture: true, install: true, install_dir: join_paths(get_option('mandir'),'man1')) endforeach ... ```
2018-04-29T17:46:12Z
[]
[]
Traceback (most recent call last): File "/usr/local/Cellar/meson/0.46.0/libexec/bin/meson", line 26, in <module> sys.exit(main()) File "/usr/local/Cellar/meson/0.46.0/libexec/bin/meson", line 23, in main return mesonmain.run(sys.argv[1:], launcher) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 308, in run sys.exit(run_script_command(args[1:])) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 257, in run_script_command return cmdfunc(cmdargs) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/meson_install.py", line 390, in run do_install(datafilename) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/meson_install.py", line 216, in do_install install_targets(d) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/meson_install.py", line 371, in install_targets depfixer.fix_rpath(outname, install_rpath, False) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/depfixer.py", line 391, in fix_rpath fix_darwin(fname, new_rpath) File "/usr/local/lib/python3.6/site-packages/mesonbuild/scripts/depfixer.py", line 376, in fix_darwin subprocess.check_call(['install_name_tool', '-add_rpath', new_rpath, fname]) File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 286, in check_call retcode = call(*popenargs, **kwargs) File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 267, in call with Popen(*popenargs, **kwargs) as p: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1275, in _execute_child restore_signals, start_new_session, preexec_fn) TypeError: expected str, bytes or os.PathLike object, not NoneType
9,081
mesonbuild/meson
mesonbuild__meson-3784
9620755ff7db9c2614ea1929fcc95bec22734cd0
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -281,7 +281,10 @@ def sanity_check_impl(self, work_dir, environment, sname, code): else: cmdlist = [binary_name] mlog.debug('Running test binary command: ' + ' '.join(cmdlist)) - pe = subprocess.Popen(cmdlist) + try: + pe = subprocess.Popen(cmdlist) + except Exception as e: + raise EnvironmentException('Could not invoke sanity test executable: %s.' % str(e)) pe.wait() if pe.returncode != 0: raise EnvironmentException('Executables created by {0} compiler {1} are not runnable.'.format(self.language, self.name_string())) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -448,6 +448,12 @@ def get_gnu_compiler_type(defines): return GCC_CYGWIN return GCC_STANDARD + def warn_about_lang_pointing_to_cross(self, compiler_exe, evar): + evar_str = os.environ.get(evar, 'WHO_WOULD_CALL_THEIR_COMPILER_WITH_THIS_NAME') + if evar_str == compiler_exe: + mlog.warning('''Env var %s seems to point to the cross compiler. +This is probably wrong, it should always point to the native compiler.''' % evar) + def _get_compilers(self, lang, evar, want_cross): ''' The list of compilers is detected in the exact same way for @@ -461,6 +467,7 @@ def _get_compilers(self, lang, evar, want_cross): ccache = self.detect_ccache() else: ccache = [] + self.warn_about_lang_pointing_to_cross(compilers[0], evar) # Return value has to be a list of compiler 'choices' compilers = [compilers] is_cross = True
Exec format error when cross compiling So when I try to cross compile with meson, I get this error: ``` Traceback (most recent call last): File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 364, in run app.generate() File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 135, in generate self._generate(env) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 174, in _generate intr = interpreter.Interpreter(b, g) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1616, in __init__ self.parse_project() File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 201, in parse_project self.evaluate_codeblock(self.ast, end=1) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 239, in evaluate_codeblock raise e File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 231, in evaluate_codeblock self.evaluate_statement(cur) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 244, in evaluate_statement return self.function_call(cur) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 504, in function_call return func(node, posargs, kwargs) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 71, in wrapped return f(self, node, args, kwargs) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 99, in wrapped return f(s, node_or_state, args, kwargs) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2142, in func_project self.add_languages(proj_langs, True) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2273, in add_languages (comp, cross_comp) = self.detect_compilers(lang, need_cross_compiler) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2242, in detect_compilers comp.sanity_check(self.environment.get_scratch_dir(), self.environment) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/compilers/cpp.py", line 48, in sanity_check return self.sanity_check_impl(work_dir, environment, 'sanitycheckcpp.cc', code) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/compilers/c.py", line 260, in sanity_check_impl pe = subprocess.Popen(cmdlist) File "/usr/lib/python3.5/subprocess.py", line 947, in __init__ restore_signals, start_new_session) File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg) OSError: [Errno 8] Exec format error ``` This is the cross file I am using: ``` [binaries] c = '/usr/bin/x86_64-w64-mingw32-gcc' cpp = '/usr/bin/x86_64-w64-mingw32-g++' ar = '/usr/bin/x86_64-w64-mingw32-ar' pkgconfig = '/usr/bin/pkg-config' [properties] root = '/usr/x86_64-w64-mingw32' sizeof_int = 4 sizeof_wchar_t = 2 sizeof_void* = 8 alignment_char = 1 alignment_void* = 8 alignment_double = 8 has_function_printf = true c_args = ['-isystem', '/home/pfultz/github/pfultz2/cget/scheme-test/mingw/include', '-isystem', '/usr/x86_64-w64-mingw32/include', '-isystem', '/usr/local/x86_64-w64-mingw32/include', '-isystem', '/home/pfultz/github/pfultz2/cget/scheme-test/mingw/include', '-isystem', '/usr/x86_64-w64-mingw32/include', '-isystem', '/usr/local/x86_64-w64-mingw32/include'] c_link_args = [] [target_machine] system = 'windows' cpu_family = 'x86' cpu = 'x86_64' endian = 'little' ``` Maybe there is something wrong with one of the settings, but it would be nice if meson would let me know which one failed.
What is happening here is that Meson is trying to use your C++ compiler to compile a test application to see that it is working. For some reason the executable for the compiler you have specified is not a valid executable. Common reasons for this include having a corrupted executable (maybe because it is an empty file for some reason) or that the executable is of incorrect format. These include running x86 _64 (or ARM) executables on 32 bit platforms, trying to run Windows apps on Linux without Wine and the requisite binfmt magic or mixing Cygwin/MinGW/VS/etc/etc binaries on Windows by accident (or by running Cygwin Python from Windows command shell or vice versa). Further debug would need more system information. The only advice I can give you right now is to try to run `/usr/bin/x86_64-w64-mingw32-g++` from the same command prompt that you tried to run Meson from. Unrelated to this, you can delete all entries in your cross file between `[properties]` and `c_args`. You probably just copied those from the sample cross file, but they are there only to demonstrate how they would be used. They are not actually needed in this case. Also, your values for `cpu_family` and `cpu` do not match. One of them is 32 bits and the other is 64 bits. You should either have both at `x86_64` or change the cpu to `i686` or something. > What is happening here is that Meson is trying to use your C++ compiler to compile a test application to see that it is working. For some reason the executable for the compiler you have specified is not a valid executable. That would be good to say when this error happens. > The only advice I can give you right now is to try to run /usr/bin/x86_64-w64-mingw32-g++ from the same command prompt that you tried to run Meson from. I did, the compiler works. Is there a way to see the command its using to invoke the compiler? I couldn't find any flags to see a log or verbose mode. Ok, so I see a meson-log.txt file in the build, which shows this: ``` Sanity testing C++ compiler: /usr/bin/x86_64-w64-mingw32-g++ Is cross compiler: False. Sanity check compiler command line: /usr/bin/x86_64-w64-mingw32-g++ /home/pfultz/github/pfultz2/cget/scheme-test/mingw/cget/build/tmp-b989928d0c9d46e4b63289f76e7121f5/build/build/meson-private/sanitycheckcpp.cc -o /home/pfultz/github/pfultz2/cget/scheme-test/mingw/cget/build/tmp-b989928d0c9d46e4b63289f76e7121f5/build/build/meson-private/sanitycheckcpp.exe Sanity check compile stdout: ----- Sanity check compile stderr: ----- Running test binary command: /home/pfultz/github/pfultz2/cget/scheme-test/mingw/cget/build/tmp-b989928d0c9d46e4b63289f76e7121f5/build/build/meson-private/sanitycheckcpp.exe ``` Which is interesting. Why does it say the `Is cross compiler: False`? It also looks like it tries to run the binary, which should fail, especially, since I haven't defined a `exe_wrapper`. Are you setting `CC` or `CXX` to the cross compiler? Those env vars are for the native compiler only.
2018-06-24T10:30:09Z
[]
[]
Traceback (most recent call last): File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 364, in run app.generate() File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 135, in generate self._generate(env) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 174, in _generate intr = interpreter.Interpreter(b, g) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1616, in __init__ self.parse_project() File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 201, in parse_project self.evaluate_codeblock(self.ast, end=1) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 239, in evaluate_codeblock raise e File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 231, in evaluate_codeblock self.evaluate_statement(cur) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 244, in evaluate_statement return self.function_call(cur) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 504, in function_call return func(node, posargs, kwargs) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 71, in wrapped return f(self, node, args, kwargs) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 99, in wrapped return f(s, node_or_state, args, kwargs) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2142, in func_project self.add_languages(proj_langs, True) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2273, in add_languages (comp, cross_comp) = self.detect_compilers(lang, need_cross_compiler) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2242, in detect_compilers comp.sanity_check(self.environment.get_scratch_dir(), self.environment) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/compilers/cpp.py", line 48, in sanity_check return self.sanity_check_impl(work_dir, environment, 'sanitycheckcpp.cc', code) File "/home/pfultz/.local/lib/python3.5/site-packages/mesonbuild/compilers/c.py", line 260, in sanity_check_impl pe = subprocess.Popen(cmdlist) File "/usr/lib/python3.5/subprocess.py", line 947, in __init__ restore_signals, start_new_session) File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg) OSError: [Errno 8] Exec format error
9,107
mesonbuild/meson
mesonbuild__meson-3818
7b2a07bcf9d3fd00013b51896ff3fe6ea852f114
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3088,6 +3088,8 @@ def func_run_target(self, node, args, kwargs): if not isinstance(i, (str, build.BuildTarget, build.CustomTarget, dependencies.ExternalProgram, mesonlib.File)): mlog.debug('Wrong type:', str(i)) raise InterpreterException('Invalid argument to run_target.') + if isinstance(i, dependencies.ExternalProgram) and not i.found(): + raise InterpreterException('Tried to use non-existing executable {!r}'.format(i.name)) cleaned_args.append(i) name = args[0] if not isinstance(name, str):
Unhandled exception when passing a program object that wasn't found to run_target ```meson project('bad_run_target', 'c') bad_program = find_program('xxxdoesnotexistxxx', required : false) run_target('bad target', command : [bad_program]) ``` ``` The Meson build system Version: 0.47.0.dev1 Source dir: /tmp/mesontest/bad_run_target Build dir: /tmp/mesontest/bad_run_target/builddir Build type: native build Project name: bad_run_target Project version: undefined Native C compiler: ccache cc (gcc 8.1.1 "cc (SUSE Linux) 8.1.1 20180523 [gcc-8-branch revision 260570]") Build machine cpu family: x86_64 Build machine cpu: x86_64 Program xxxdoesnotexistxxx found: NO Build targets in project: 1 Found ninja-1.8.2 at /usr/bin/ninja Traceback (most recent call last): File "/data/git/meson/mesonbuild/mesonmain.py", line 339, in run app.generate() File "/data/git/meson/mesonbuild/mesonmain.py", line 114, in generate self._generate(env) File "/data/git/meson/mesonbuild/mesonmain.py", line 163, in _generate intr.backend.generate(intr) File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 220, in generate self.generate_target(t, outfile) File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 323, in generate_target self.generate_run_target(target, outfile) File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 616, in generate_run_target cmd = self.replace_paths(target, cmd) File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 1880, in replace_paths for x in args] File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 1880, in <listcomp> for x in args] AttributeError: 'NoneType' object has no attribute 'replace' ```
2018-07-01T10:38:26Z
[]
[]
Traceback (most recent call last): File "/data/git/meson/mesonbuild/mesonmain.py", line 339, in run app.generate() File "/data/git/meson/mesonbuild/mesonmain.py", line 114, in generate self._generate(env) File "/data/git/meson/mesonbuild/mesonmain.py", line 163, in _generate intr.backend.generate(intr) File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 220, in generate self.generate_target(t, outfile) File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 323, in generate_target self.generate_run_target(target, outfile) File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 616, in generate_run_target cmd = self.replace_paths(target, cmd) File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 1880, in replace_paths for x in args] File "/data/git/meson/mesonbuild/backend/ninjabackend.py", line 1880, in <listcomp> for x in args] AttributeError: 'NoneType' object has no attribute 'replace'
9,110
mesonbuild/meson
mesonbuild__meson-3985
ab6929f64ad295fb42ca989d2beea023b1f37f7d
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -55,7 +55,7 @@ def __init__(self, source_dir, build_dir, prefix, strip_bin, self.mesonintrospect = mesonintrospect class TargetInstallData: - def __init__(self, fname, outdir, aliases, strip, install_name_mappings, install_rpath, install_mode): + def __init__(self, fname, outdir, aliases, strip, install_name_mappings, install_rpath, install_mode, optional=False): self.fname = fname self.outdir = outdir self.aliases = aliases @@ -63,6 +63,7 @@ def __init__(self, fname, outdir, aliases, strip, install_name_mappings, install self.install_name_mappings = install_name_mappings self.install_rpath = install_rpath self.install_mode = install_mode + self.optional = optional class ExecutableSerialisation: def __init__(self, name, fname, cmd_args, env, is_cross, exe_wrapper, @@ -1047,9 +1048,10 @@ def generate_target_install(self, d): implib_install_dir = outdirs[0] else: implib_install_dir = self.environment.get_import_lib_dir() - # Install the import library. + # Install the import library; may not exist for shared modules i = TargetInstallData(self.get_target_filename_for_linking(t), - implib_install_dir, {}, False, {}, '', install_mode) + implib_install_dir, {}, False, {}, '', install_mode, + optional=isinstance(t, build.SharedModule)) d.targets.append(i) # Install secondary outputs. Only used for Vala right now. if num_outdirs > 1: diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -1274,6 +1274,9 @@ def get_gui_app_args(self): def get_pic_args(self): return [] # PIC is handled by the loader on Windows + def gen_export_dynamic_link_args(self, env): + return [] # Not applicable with MSVC + def get_std_shared_lib_link_args(self): return ['/DLL'] diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -384,6 +384,13 @@ def run_install_script(self, d): def install_targets(self, d): for t in d.targets: + if not os.path.exists(t.fname): + # For example, import libraries of shared modules are optional + if t.optional: + print('File {!r} not found, skipping'.format(t.fname)) + continue + else: + raise RuntimeError('File {!r} could not be found'.format(t.fname)) fname = check_for_stampfile(t.fname) outdir = get_destdir_path(d, t.outdir) outname = os.path.join(outdir, os.path.basename(fname))
Don't require import library on installation for shared modules Shared modules might not export any symbols at all, so while we should install an import library if the linker generated one, if it doesn't exist, we should print a message about that and continue the installation instead of throwing a traceback: ```pytb Traceback (most recent call last): File "d:\\projects\\cerbero\\meson\\master\\build\\build-tools\\Scripts\\meson.py", line 4, in <module> __import__('pkg_resources').run_script('meson==0.47.0', 'meson.py') File "c:\Python36-32\lib\site-packages\pkg_resources\__init__.py", line 658, in run_script self.require(requires)[0].run_script(script_name, ns) File "c:\Python36-32\lib\site-packages\pkg_resources\__init__.py", line 1438, in run_script exec(code, namespace, namespace) File "d:\projects\cerbero\meson\master\build\build-tools\lib\site-packages\meson-0.47.0-py3.6.egg\EGG-INFO\scripts\meson.py", line 29, in <module> sys.exit(mesonmain.main()) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\mesonmain.py", line 367, in main return run(sys.argv[1:], launcher) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\mesonmain.py", line 281, in run return minstall.run(remaining_args) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\minstall.py", line 466, in run installer.do_install(datafilename) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\minstall.py", line 298, in do_install self.install_targets(d) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\minstall.py", line 387, in install_targets fname = check_for_stampfile(t.fname) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\minstall.py", line 170, in check_for_stampfile if os.stat(fname).st_size == 0: FileNotFoundError: [WinError 2] The system cannot find the file specified: 'tls/gnutls\\giognutls.lib' FAILED: meson-install "c:\\Python36-32\\python.exe" "d:\\projects\\cerbero\\meson\\master\\build\\build-tools\\Scripts\\meson.py" "install" "--no-rebuild" ninja: build stopped: subcommand failed. ```
2018-08-07T15:59:20Z
[]
[]
Traceback (most recent call last): File "d:\\projects\\cerbero\\meson\\master\\build\\build-tools\\Scripts\\meson.py", line 4, in <module> __import__('pkg_resources').run_script('meson==0.47.0', 'meson.py') File "c:\Python36-32\lib\site-packages\pkg_resources\__init__.py", line 658, in run_script self.require(requires)[0].run_script(script_name, ns) File "c:\Python36-32\lib\site-packages\pkg_resources\__init__.py", line 1438, in run_script exec(code, namespace, namespace) File "d:\projects\cerbero\meson\master\build\build-tools\lib\site-packages\meson-0.47.0-py3.6.egg\EGG-INFO\scripts\meson.py", line 29, in <module> sys.exit(mesonmain.main()) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\mesonmain.py", line 367, in main return run(sys.argv[1:], launcher) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\mesonmain.py", line 281, in run return minstall.run(remaining_args) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\minstall.py", line 466, in run installer.do_install(datafilename) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\minstall.py", line 298, in do_install self.install_targets(d) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\minstall.py", line 387, in install_targets fname = check_for_stampfile(t.fname) File "d:\projects\cerbero\meson\master\build\build-tools\Lib\site-packages\meson-0.47.0-py3.6.egg\mesonbuild\minstall.py", line 170, in check_for_stampfile if os.stat(fname).st_size == 0: FileNotFoundError: [WinError 2] The system cannot find the file specified: 'tls/gnutls\\giognutls.lib'
9,121
mesonbuild/meson
mesonbuild__meson-3996
a8694f4b261fbe3a854d2a2d72742fde9a67d4b3
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -20,7 +20,12 @@ from .scripts import destdir_join from .mesonlib import is_windows, Popen_safe from .mtest import rebuild_all -from __main__ import __file__ as main_file +try: + from __main__ import __file__ as main_file +except ImportError: + # Happens when running as meson.exe which is native Windows. + # This is only used for pkexec which is not, so this is fine. + main_file = None selinux_updates = []
`meson install` broken with Windows MSI installer After having installed meson via the MSI installer, I get this when trying to run `meson install` (or `ninja install`): ``` F:\projects\mesontest\libfoo\buildwin>meson install Traceback (most recent call last): File "C:\python\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run File "C:\python\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run File "meson.py", line 29, in <module> File "mesonbuild\mesonmain.py", line 379, in main File "mesonbuild\mesonmain.py", line 283, in run File "mesonbuild\minstall.py", line 23, in <module> ImportError: cannot import name '__file__' ``` - the problem exists with `meson-0.47.1-32.msi`, also with `meson-0.47.0-32.msi` - works correctly with `meson-0.46.1-32.msi` - also works correctly when installing python and getting meson 0.47.1 via `pip3 install meson`
2018-08-08T18:19:49Z
[]
[]
Traceback (most recent call last): File "C:\python\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run File "C:\python\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run File "meson.py", line 29, in <module> File "mesonbuild\mesonmain.py", line 379, in main File "mesonbuild\mesonmain.py", line 283, in run File "mesonbuild\minstall.py", line 23, in <module> ImportError: cannot import name '__file__'
9,122
mesonbuild/meson
mesonbuild__meson-4030
6ecd31af19dc537983311796929a9dd690632999
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -69,9 +69,9 @@ def __exit__(self, type, value, traceback): for d in self.dirs: append_to_log(self.lf, d) -def is_executable(path): +def is_executable(path, follow_symlinks=False): '''Checks whether any of the "x" bits are set in the source file mode.''' - return bool(os.stat(path).st_mode & 0o111) + return bool(os.stat(path, follow_symlinks=follow_symlinks).st_mode & 0o111) def append_to_log(lf, line): lf.write(line) @@ -79,13 +79,38 @@ def append_to_log(lf, line): lf.write('\n') lf.flush() +def set_chown(path, user=None, group=None, dir_fd=None, follow_symlinks=True): + # shutil.chown will call os.chown without passing all the parameters + # and particularly follow_symlinks, thus we replace it temporary + # with a lambda with all the parameters so that follow_symlinks will + # be actually passed properly. + # Not nice, but better than actually rewriting shutil.chown until + # this python bug is fixed: https://bugs.python.org/issue18108 + real_os_chown = os.chown + try: + os.chown = lambda p, u, g: real_os_chown(p, u, g, + dir_fd=dir_fd, + follow_symlinks=follow_symlinks) + shutil.chown(path, user, group) + except: + raise + finally: + os.chown = real_os_chown + +def set_chmod(path, mode, dir_fd=None, follow_symlinks=True): + try: + os.chmod(path, mode, dir_fd=dir_fd, follow_symlinks=follow_symlinks) + except (NotImplementedError, OSError, SystemError) as e: + if not os.path.islink(path): + os.chmod(path, mode, dir_fd=dir_fd) + def sanitize_permissions(path, umask): if umask is None: return - new_perms = 0o777 if is_executable(path) else 0o666 + new_perms = 0o777 if is_executable(path, follow_symlinks=False) else 0o666 new_perms &= ~umask try: - os.chmod(path, new_perms) + set_chmod(path, new_perms, follow_symlinks=False) except PermissionError as e: msg = '{!r}: Unable to set permissions {!r}: {}, ignoring...' print(msg.format(path, new_perms, e.strerror)) @@ -98,7 +123,7 @@ def set_mode(path, mode, default_umask): # No chown() on Windows, and must set one of owner/group if not is_windows() and (mode.owner or mode.group) is not None: try: - shutil.chown(path, mode.owner, mode.group) + set_chown(path, mode.owner, mode.group, follow_symlinks=False) except PermissionError as e: msg = '{!r}: Unable to set owner {!r} and group {!r}: {}, ignoring...' print(msg.format(path, mode.owner, mode.group, e.strerror)) @@ -116,7 +141,7 @@ def set_mode(path, mode, default_umask): # NOTE: On Windows you can set read/write perms; the rest are ignored if mode.perms_s is not None: try: - os.chmod(path, mode.perms) + set_chmod(path, mode.perms, follow_symlinks=False) except PermissionError as e: msg = '{!r}: Unable to set permissions {!r}: {}, ignoring...' print(msg.format(path, mode.perms_s, e.strerror)) diff --git a/run_unittests.py b/run_unittests.py --- a/run_unittests.py +++ b/run_unittests.py @@ -3779,32 +3779,42 @@ def test_usage_external_library(self): # Ensure that the otool output does not contain self.installdir self.assertNotRegex(out, self.installdir + '.*dylib ') - def test_install_subdir_symlinks(self): + def install_subdir_invalid_symlinks(self, testdir, subdir_path): ''' Test that installation of broken symlinks works fine. https://github.com/mesonbuild/meson/issues/3914 ''' - testdir = os.path.join(self.common_test_dir, '66 install subdir') - subdir = os.path.join(testdir, 'sub/sub1') + testdir = os.path.join(self.common_test_dir, testdir) + subdir = os.path.join(testdir, subdir_path) curdir = os.getcwd() os.chdir(subdir) # Can't distribute broken symlinks in the source tree because it breaks # the creation of zipapps. Create it dynamically and run the test by # hand. src = '../../nonexistent.txt' - os.symlink(src, 'test.txt') + os.symlink(src, 'invalid-symlink.txt') try: self.init(testdir) self.build() self.install() - link = os.path.join(self.installdir, 'usr', 'share', 'sub1', 'test.txt') + install_path = subdir_path.split(os.path.sep)[-1] + link = os.path.join(self.installdir, 'usr', 'share', install_path, 'invalid-symlink.txt') self.assertTrue(os.path.islink(link), msg=link) self.assertEqual(src, os.readlink(link)) self.assertFalse(os.path.isfile(link), msg=link) finally: - os.remove(os.path.join(subdir, 'test.txt')) + os.remove(os.path.join(subdir, 'invalid-symlink.txt')) os.chdir(curdir) + def test_install_subdir_symlinks(self): + self.install_subdir_invalid_symlinks('66 install subdir', os.path.join('sub', 'sub1')) + + def test_install_subdir_symlinks_with_default_umask(self): + self.install_subdir_invalid_symlinks('199 install_mode', 'sub2') + + def test_install_subdir_symlinks_with_default_umask_and_mode(self): + self.install_subdir_invalid_symlinks('199 install_mode', 'sub1') + class LinuxCrossArmTests(BasePlatformTests): '''
Symlinks can't be copied by install_subdir() since 0.47.0 If you have a dangling symlink (the symlink is referencing a path that is coming from another package on the system, so only resolved once installed on the system), in a directory, `install_subdir` is now reporting a stacktrace since the minstall.py rewrite (worked fine with 0.46, failing since 0.47.0 and still on 0.47.1). For instance, you have: `data/ubuntu-wayland/applications/gnome-initial-setup.desktop -> ../../ubuntu/applications/gnome-initial-setup.desktop` (only resolved on the installed system) meson.build has: ```install_subdir('data/ubuntu-wayland', install_dir: datadir)``` with datadir built as a package, so a destdir/prefix combo. When building: ``` Installing subdir /home/didrocks/work/build-area/ubuntu-settings-18.04.6/data/ubuntu-wayland to /home/didrocks/work/build-area/ubuntu-settings-18.04.6/debian/tmp/usr/share/ubuntu-wayland Traceback (most recent call last): File "/usr/bin/meson", line 29, in <module> sys.exit(mesonmain.main()) File "/usr/lib/python3.6/dist-packages/mesonbuild/mesonmain.py", line 367, in main return run(sys.argv[1:], launcher) File "/usr/lib/python3.6/dist-packages/mesonbuild/mesonmain.py", line 281, in run return minstall.run(remaining_args) File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 466, in run installer.do_install(datafilename) File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 297, in do_install self.install_subdirs(d) # Must be first, because it needs to delete the old subtree. File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 318, in install_subdirs self.do_copydir(d, src_dir, full_dst_dir, exclude, mode) File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 281, in do_copydir self.do_copyfile(abs_src, abs_dst) File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 196, in do_copyfile '{!r}'.format(from_file)) RuntimeError: Tried to install something that isn't a file:'/home/didrocks/work/build-area/ubuntu-settings-18.04.6/data/ubuntu-wayland/applications/gnome-initial-setup.desktop' ``` Shouldn't we either have a `copy_symlink()` or `copy_file()` be extended to support symlinks? (I see the code has a `# FIXME: what about symlinks?` as well ;))
This is a regression and will be fixed for 0.47.2. @didrocks can you try the patch in https://github.com/mesonbuild/meson/pull/4014?
2018-08-16T02:36:29Z
[]
[]
Traceback (most recent call last): File "/usr/bin/meson", line 29, in <module> sys.exit(mesonmain.main()) File "/usr/lib/python3.6/dist-packages/mesonbuild/mesonmain.py", line 367, in main return run(sys.argv[1:], launcher) File "/usr/lib/python3.6/dist-packages/mesonbuild/mesonmain.py", line 281, in run return minstall.run(remaining_args) File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 466, in run installer.do_install(datafilename) File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 297, in do_install self.install_subdirs(d) # Must be first, because it needs to delete the old subtree. File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 318, in install_subdirs self.do_copydir(d, src_dir, full_dst_dir, exclude, mode) File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 281, in do_copydir self.do_copyfile(abs_src, abs_dst) File "/usr/lib/python3.6/dist-packages/mesonbuild/minstall.py", line 196, in do_copyfile '{!r}'.format(from_file)) RuntimeError: Tried to install something that isn't a file:'/home/didrocks/work/build-area/ubuntu-settings-18.04.6/data/ubuntu-wayland/applications/gnome-initial-setup.desktop'
9,126
mesonbuild/meson
mesonbuild__meson-4129
289c1bf91992c167e8ec4292f2584a4add7f5485
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -354,7 +354,21 @@ def preexec_fn(): # There's nothing we can do (maybe the process # already died) so carry on. pass - (stdo, stde) = p.communicate() + try: + (stdo, stde) = p.communicate(timeout=1) + except subprocess.TimeoutExpired: + # An earlier kill attempt has not worked for whatever reason. + # Try to kill it one last time with a direct call. + # If the process has spawned children, they will remain around. + p.kill() + try: + (stdo, stde) = p.communicate(timeout=1) + except subprocess.TimeoutExpired: + stdo = b'Test process could not be killed.' + stde = b'' + except ValueError: + stdo = b'Could not read output. Maybe the process has redirected its stdout/stderr?' + stde = b'' endtime = time.time() duration = endtime - starttime stdo = decode(stdo)
Meson crashes while running GLib gdbus-proxy-threads test This is currently a blocker for adding FreeBSD CI to GLib. It is easily reproducible and it makes it almost impossible to complete the GLib test on FreeBSD. ``` $ ~/gnome/source/meson/meson.py test gdbus-proxy-threads ninja: Entering directory `/tmp/ram/glib-build' ninja: no work to do. Traceback (most recent call last): File "/home/lantw44/gnome/source/meson/meson.py", line 29, in <module> sys.exit(mesonmain.main()) File "/home/lantw44/gnome/source/meson/mesonbuild/mesonmain.py", line 379, in main return run(sys.argv[1:], launcher) File "/home/lantw44/gnome/source/meson/mesonbuild/mesonmain.py", line 278, in run return mtest.run(remaining_args) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 759, in run return th.run_special() File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 692, in run_special self.run_tests(tests) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 666, in run_tests self.drain_futures(futures) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 682, in drain_futures self.process_test_result(result.result()) File "/usr/local/lib/python3.6/concurrent/futures/_base.py", line 432, in result return self.__get_result() File "/usr/local/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result raise self._exception File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 262, in run return self._run_cmd(wrap + cmd + self.test.cmd_args + self.options.test_args) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 353, in _run_cmd (stdo, stde) = p.communicate() File "/usr/local/lib/python3.6/subprocess.py", line 843, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/usr/local/lib/python3.6/subprocess.py", line 1505, in _communicate selector.register(self.stdout, selectors.EVENT_READ) File "/usr/local/lib/python3.6/selectors.py", line 351, in register key = super().register(fileobj, events, data) File "/usr/local/lib/python3.6/selectors.py", line 237, in register key = SelectorKey(fileobj, self._fileobj_lookup(fileobj), events, data) File "/usr/local/lib/python3.6/selectors.py", line 224, in _fileobj_lookup return _fileobj_to_fd(fileobj) File "/usr/local/lib/python3.6/selectors.py", line 39, in _fileobj_to_fd "{!r}".format(fileobj)) from None ValueError: Invalid file object: <_io.BufferedReader name=6> ``` It took 30 seconds for meson to crash, so it looked like a timeout issue. However, `gdbus-proxy-threads` test itself completed in less than 5 seconds. It exited and became a zombie process before meson crashed. ``` └─┬= 93390 lantw44 python3 /home/lantw44/gnome/source/meson/meson.py test gdbus-proxy-threads (python3.6) └──= 93399 lantw44 <defunct> ``` Interestingly, meson doesn't crash when running the same test with `-v` flag. ``` $ ~/gnome/source/meson/meson.py test -v gdbus-proxy-threads ninja: Entering directory `/tmp/ram/glib-build' ninja: no work to do. /gdbus/proxy/vs-threads: OK 1/1 glib:gio / gdbus-proxy-threads OK 2.58 s OK: 1 FAIL: 0 SKIP: 0 TIMEOUT: 0 ``` Running `meson test` with `-v` avoids the crash, but it still doesn't work with GitLab runner. It seems there is a leftover `dbus-daemon` process when running `meson test` with `-v` and GitLab runner waits forever for it. The test https://gitlab.gnome.org/GNOME/glib/-/jobs/70974 already runs for a week and GitLab runner still waits for it. Related comments on GNOME GitLab: - https://gitlab.gnome.org/Infrastructure/GitLab/issues/286#note_273597 - https://gitlab.gnome.org/Infrastructure/GitLab/issues/286#note_273789
Looks like we're not killing process groups correctly after each test. Not sure what's going on because it seems to be BSD-specific? After spending time reading `mtest.py` and `subprocess.py`, I think I understand the problem better now. Although it cannot be reproduced on GNU/Linux, it is not a BSD-specific issue but a bug of Python subprocess `communicate` function: https://bugs.python.org/issue30154. When `communicate` is called, Python blocks itself on a call to `poll` to wait for data written to stdout and stderr. It exits the `poll` loop when all monitored file descriptors are closed. After it exits the loop, it waits for the child process to exit and return. It works most of the time because file descriptors are closed on process exit, so Python can exit the loop when the child process exits. However, if the child process forks a grandchild process and the grandchild process never exits, both stdout and stderr will still be open after the child process exits. This causes `communicate` to block forever until the timeout is expired. `gdbus-proxy-threads` is a test which forks at least two child processes. One of them is `dbus-daemon` and another one is a watcher which is responsible for killing `dbus-daemon` when the test is done. On GNU/Linux, the test works correctly, so `dbus-daemon` is terminated when the test exits. On FreeBSD, the watcher process crashes and doesn't kill the `dbus-daemon` process, causing stdout and stderr to be kept open after the main process exits. This triggers the problem described above and seems to cause the second call to `communicate` to fail. The ideal fix of the problem will be fixing the `gdbus-proxy-threads` crash on FreeBSD. However, it is still nice if meson itself can handle the case and explain the problem to users, so users will be able to easily understand what the problem is. The leftover process problem is now fixed in GLib: https://gitlab.gnome.org/GNOME/glib/merge_requests/251. I still hope the crash problem can be fixed in meson. I think having a misbehaving test crashes the build system isn't something users expect to happen. Meson is still not reliable enough to run GLib tests on FreeBSD. Meson puts wrong RPATH on the generated executable, so the test still fails on the CI machine because it uses the system-installed GLib instead of the one built under the build directory: https://gitlab.gnome.org/GNOME/glib/-/jobs/86836. > est still fails on the CI machine because it uses the system-installed GLib instead of the one built under the build directory Are you sure this is not caused by them using the "other" style of rpath or runpath or whatever it was where system paths override entries in RPATH instead of the other way around? > Are you sure this is not caused by them using the "other" style of rpath or runpath or whatever it was where system paths override entries in RPATH instead of the other way around? There is no LD_LIBRARY_PATH set in the environment and LDFLAGS already includes `-Wl,--disable-new-dtags`. I think it is really a RPATH problem because the first item in RPATH is `$ORIGIN/../../../../../../../../../../../usr/local/lib`. You can see the output of `ldd` and `readelf` in this comment: https://gitlab.gnome.org/GNOME/glib/merge_requests/251#note_296739. The test was done with meson 0.47.1.
2018-09-04T21:16:19Z
[]
[]
Traceback (most recent call last): File "/home/lantw44/gnome/source/meson/meson.py", line 29, in <module> sys.exit(mesonmain.main()) File "/home/lantw44/gnome/source/meson/mesonbuild/mesonmain.py", line 379, in main return run(sys.argv[1:], launcher) File "/home/lantw44/gnome/source/meson/mesonbuild/mesonmain.py", line 278, in run return mtest.run(remaining_args) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 759, in run return th.run_special() File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 692, in run_special self.run_tests(tests) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 666, in run_tests self.drain_futures(futures) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 682, in drain_futures self.process_test_result(result.result()) File "/usr/local/lib/python3.6/concurrent/futures/_base.py", line 432, in result return self.__get_result() File "/usr/local/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result raise self._exception File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 262, in run return self._run_cmd(wrap + cmd + self.test.cmd_args + self.options.test_args) File "/home/lantw44/gnome/source/meson/mesonbuild/mtest.py", line 353, in _run_cmd (stdo, stde) = p.communicate() File "/usr/local/lib/python3.6/subprocess.py", line 843, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/usr/local/lib/python3.6/subprocess.py", line 1505, in _communicate selector.register(self.stdout, selectors.EVENT_READ) File "/usr/local/lib/python3.6/selectors.py", line 351, in register key = super().register(fileobj, events, data) File "/usr/local/lib/python3.6/selectors.py", line 237, in register key = SelectorKey(fileobj, self._fileobj_lookup(fileobj), events, data) File "/usr/local/lib/python3.6/selectors.py", line 224, in _fileobj_lookup return _fileobj_to_fd(fileobj) File "/usr/local/lib/python3.6/selectors.py", line 39, in _fileobj_to_fd "{!r}".format(fileobj)) from None ValueError: Invalid file object: <_io.BufferedReader name=6>
9,133
mesonbuild/meson
mesonbuild__meson-4207
689d32ecfb662866d66a5aee2aa45dfad95034f2
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -127,19 +127,24 @@ def is_library(fname): 'debug': [], 'debugoptimized': [], 'release': [], - 'minsize': []} + 'minsize': [], + 'custom': [], + } armclang_buildtype_args = {'plain': [], 'debug': ['-O0', '-g'], 'debugoptimized': ['-O1', '-g'], 'release': ['-Os'], - 'minsize': ['-Oz']} + 'minsize': ['-Oz'], + 'custom': [], + } arm_buildtype_args = {'plain': [], 'debug': ['-O0', '--debug'], 'debugoptimized': ['-O1', '--debug'], 'release': ['-O3', '-Otime'], 'minsize': ['-O3', '-Ospace'], + 'custom': [], } msvc_buildtype_args = {'plain': [], @@ -147,6 +152,7 @@ def is_library(fname): 'debugoptimized': ["/Zi", "/Ob1"], 'release': ["/Ob2", "/Gw"], 'minsize': ["/Zi", "/Gw"], + 'custom': [], } apple_buildtype_linker_args = {'plain': [], @@ -154,6 +160,7 @@ def is_library(fname): 'debugoptimized': [], 'release': [], 'minsize': [], + 'custom': [], } gnulike_buildtype_linker_args = {'plain': [], @@ -161,6 +168,7 @@ def is_library(fname): 'debugoptimized': [], 'release': ['-Wl,-O1'], 'minsize': [], + 'custom': [], } arm_buildtype_linker_args = {'plain': [], @@ -168,6 +176,7 @@ def is_library(fname): 'debugoptimized': [], 'release': [], 'minsize': [], + 'custom': [], } msvc_buildtype_linker_args = {'plain': [], @@ -178,6 +187,7 @@ def is_library(fname): # REF implies ICF. 'release': ['/OPT:REF'], 'minsize': ['/INCREMENTAL:NO', '/OPT:REF'], + 'custom': [], } java_buildtype_args = {'plain': [], @@ -185,6 +195,7 @@ def is_library(fname): 'debugoptimized': ['-g'], 'release': [], 'minsize': [], + 'custom': [], } rust_buildtype_args = {'plain': [], @@ -192,6 +203,7 @@ def is_library(fname): 'debugoptimized': [], 'release': [], 'minsize': [], + 'custom': [], } d_gdc_buildtype_args = {'plain': [], @@ -199,6 +211,7 @@ def is_library(fname): 'debugoptimized': ['-finline-functions'], 'release': ['-frelease', '-finline-functions'], 'minsize': [], + 'custom': [], } d_ldc_buildtype_args = {'plain': [], @@ -206,6 +219,7 @@ def is_library(fname): 'debugoptimized': ['-enable-inlining', '-Hkeep-all-bodies'], 'release': ['-release', '-enable-inlining', '-Hkeep-all-bodies'], 'minsize': [], + 'custom': [], } d_dmd_buildtype_args = {'plain': [], @@ -213,6 +227,7 @@ def is_library(fname): 'debugoptimized': ['-inline'], 'release': ['-release', '-inline'], 'minsize': [], + 'custom': [], } mono_buildtype_args = {'plain': [], @@ -220,6 +235,7 @@ def is_library(fname): 'debugoptimized': ['-optimize+'], 'release': ['-optimize+'], 'minsize': [], + 'custom': [], } swift_buildtype_args = {'plain': [], @@ -227,6 +243,7 @@ def is_library(fname): 'debugoptimized': [], 'release': [], 'minsize': [], + 'custom': [], } gnu_winlibs = ['-lkernel32', '-luser32', '-lgdi32', '-lwinspool', '-lshell32',
Setting custom -Doptimization causes failure 1. `meson build .` 2. `meson configure build -Doptimization=s` 3. `ninja -C build/ -v` ``` Traceback (most recent call last): File "/home/soap/gitz/meson/mesonbuild/mesonmain.py", line 364, in run app.generate() File "/home/soap/gitz/meson/mesonbuild/mesonmain.py", line 136, in generate self._generate(env) File "/home/soap/gitz/meson/mesonbuild/mesonmain.py", line 185, in _generate intr.backend.generate(intr) File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 224, in generate self.generate_target(t, outfile) File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 472, in generate_target obj_list.append(self.generate_single_compile(target, outfile, src, False, [], header_deps)) File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 2051, in generate_single_compile commands = self._generate_single_compile(target, compiler, is_generated) File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 1972, in _generate_single_compile commands += self.generate_basic_compiler_args(target, compiler, no_warn_args) File "/home/soap/gitz/meson/mesonbuild/backend/backends.py", line 538, in generate_basic_compiler_args commands += compiler.get_buildtype_args(self.get_option_for_target('buildtype', target)) File "/home/soap/gitz/meson/mesonbuild/compilers/compilers.py", line 1306, in get_buildtype_args return gnulike_buildtype_args[buildtype] KeyError: 'custom' FAILED: build.ninja ```
2018-09-18T08:41:58Z
[]
[]
Traceback (most recent call last): File "/home/soap/gitz/meson/mesonbuild/mesonmain.py", line 364, in run app.generate() File "/home/soap/gitz/meson/mesonbuild/mesonmain.py", line 136, in generate self._generate(env) File "/home/soap/gitz/meson/mesonbuild/mesonmain.py", line 185, in _generate intr.backend.generate(intr) File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 224, in generate self.generate_target(t, outfile) File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 472, in generate_target obj_list.append(self.generate_single_compile(target, outfile, src, False, [], header_deps)) File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 2051, in generate_single_compile commands = self._generate_single_compile(target, compiler, is_generated) File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 1972, in _generate_single_compile commands += self.generate_basic_compiler_args(target, compiler, no_warn_args) File "/home/soap/gitz/meson/mesonbuild/backend/backends.py", line 538, in generate_basic_compiler_args commands += compiler.get_buildtype_args(self.get_option_for_target('buildtype', target)) File "/home/soap/gitz/meson/mesonbuild/compilers/compilers.py", line 1306, in get_buildtype_args return gnulike_buildtype_args[buildtype] KeyError: 'custom'
9,141
mesonbuild/meson
mesonbuild__meson-4238
2b26ddbf3e9140b2f1052fbef56c69be79eecf36
diff --git a/run_unittests.py b/run_unittests.py --- a/run_unittests.py +++ b/run_unittests.py @@ -3794,7 +3794,7 @@ def test_introspect_dependencies(self): break self.assertIsInstance(docbook_target, dict) ifile = self.introspect(['--target-files', 'generated-gdbus-docbook@cus'])[0] - self.assertEqual(t['filename'], 'gdbus/generated-gdbus-doc-' + ifile) + self.assertEqual(t['filename'], 'gdbus/generated-gdbus-doc-' + os.path.basename(ifile)) def test_build_rpath(self): if is_cygwin():
Gdbus unit tests do not pass on 0.48 rc ``` ====================================================================== FAIL: test_introspect_dependencies (__main__.LinuxlikeTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "./run_unittests.py", line 3797, in test_introspect_dependencies self.assertEqual(t['filename'], 'gdbus/generated-gdbus-doc-' + ifile) AssertionError: 'gdbus/generated-gdbus-doc-com.example.Sample.xml' != 'gdbus/generated-gdbus-doc-gdbus/data/com.example.Sample.xml' - gdbus/generated-gdbus-doc-com.example.Sample.xml + gdbus/generated-gdbus-doc-gdbus/data/com.example.Sample.xml ? +++++++++++ ``` This is a release blocker.
Bisect says that the error appeared in commit 43f7a750, which is by @nirbheek. This does not show up in CI probably due to the fact that this test requires a fairly new glib.
2018-09-22T13:23:56Z
[]
[]
Traceback (most recent call last): File "./run_unittests.py", line 3797, in test_introspect_dependencies self.assertEqual(t['filename'], 'gdbus/generated-gdbus-doc-' + ifile) AssertionError: 'gdbus/generated-gdbus-doc-com.example.Sample.xml' != 'gdbus/generated-gdbus-doc-gdbus/data/com.example.Sample.xml'
9,145
mesonbuild/meson
mesonbuild__meson-4308
c0c075c1298ad9018a62d75a632af1c0d0d7d0f8
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -82,17 +82,19 @@ def merge_file(self, state, args, kwargs): kwargs['command'] = command inputfile = kwargs['input'] - if isinstance(inputfile, str): - inputfile = mesonlib.File.from_source_file(state.environment.source_dir, + if hasattr(inputfile, 'held_object'): + ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, state.subproject, kwargs) + else: + if isinstance(inputfile, str): + inputfile = mesonlib.File.from_source_file(state.environment.source_dir, state.subdir, inputfile) - output = kwargs['output'] - ifile_abs = inputfile.absolute_path(state.environment.source_dir, - state.environment.build_dir) - values = mesonlib.get_filenames_templates_dict([ifile_abs], None) - outputs = mesonlib.substitute_values([output], values) - output = outputs[0] - - ct = build.CustomTarget(output + '_' + state.subdir + '_merge', state.subdir, state.subproject, kwargs) + output = kwargs['output'] + ifile_abs = inputfile.absolute_path(state.environment.source_dir, + state.environment.build_dir) + values = mesonlib.get_filenames_templates_dict([ifile_abs], None) + outputs = mesonlib.substitute_values([output], values) + output = outputs[0] + ct = build.CustomTarget(output + '_' + state.subdir + '_merge', state.subdir, state.subproject, kwargs) return ModuleReturnValue(ct, [ct]) @FeatureNewKwargs('i18n.gettext', '0.37.0', ['preset'])
[0.48.0] fails to build file-roller When using meson 0.48.0, file-roller (tested verison 3.30.1) no longer builds/confifures successfully but errs on a meson internal library: ``` File "/usr/lib/python3.6/site-packages/mesonbuild/modules/i18n.py", line 89, in merge_file ifile_abs = inputfile.absolute_path(state.environment.source_dir, AttributeError: 'CustomTargetHolder' object has no attribute 'absolute_path' ``` Complete trace, for reference: ``` The Meson build system Version: 0.48.0 Source dir: /home/abuild/rpmbuild/BUILD/file-roller-3.30.1 Build dir: /home/abuild/rpmbuild/BUILD/file-roller-3.30.1/build Build type: native build Project name: file-roller Project version: 3.30.1 Native C compiler: cc (gcc 8.2.1 "cc (SUSE Linux) 8.2.1 20180831 [gcc-8-branch revision 264010]") Build machine cpu family: x86_64 Build machine cpu: x86_64 Program postinstall.py found: YES (/home/abuild/rpmbuild/BUILD/file-roller-3.30.1/postinstall.py) Library m found: YES Dependency threads found: YES Found pkg-config: /usr/bin/pkg-config (0.29.2) Dependency glib-2.0 found: YES 2.58.1 Dependency gthread-2.0 found: YES 2.58.1 Dependency gtk+-3.0 found: YES 3.24.1 Dependency libnautilus-extension found: NO (tried pkgconfig) Dependency json-glib-1.0 found: YES 1.4.4 Dependency libnotify found: YES 0.7.7 Dependency libarchive found: YES 3.3.3 Checking for function "mkdtemp" : YES Program gcpio found: NO Program cpio found: YES (/usr/bin/cpio) Configuring config.h using configuration Compiler for C supports arguments -Wall: YES Compiler for C supports arguments -Wcast-align: YES Compiler for C supports arguments -Wtype-limits: YES Compiler for C supports arguments -Wclobbered: YES Compiler for C supports arguments -Wempty-body: YES Compiler for C supports arguments -Wignored-qualifiers: YES Compiler for C supports arguments -Wmissing-prototypes: YES Compiler for C supports arguments -Wnested-externs: YES Compiler for C supports arguments -Wpointer-arith: YES Compiler for C supports arguments -Wno-sign-compare -Wsign-compare: YES Compiler for C supports arguments -Wformat-security: YES Program set-mime-type-entry.py found: YES (/home/abuild/rpmbuild/BUILD/file-roller-3.30.1/data/set-mime-type-entry.py) Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 364, in run app.generate() File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 136, in generate self._generate(env) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 165, in _generate intr.run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3836, in run super().run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 380, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 404, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 398, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 409, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 705, in function_call return func(node, posargs, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 273, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 162, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3422, in func_subdir self.evaluate_codeblock(codeblock) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 404, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 398, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 413, in evaluate_statement return self.method_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 741, in method_call return obj.method_call(method_name, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 1622, in method_call value = fn(state, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 219, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 162, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/modules/i18n.py", line 89, in merge_file ifile_abs = inputfile.absolute_path(state.environment.source_dir, AttributeError: 'CustomTargetHolder' object has no attribute 'absolute_path' ```
Bisection says that this was caused by commit 176af2c8c33e79732680ebb1e2a25b5cd7a51bb9 which seems to be authored by @tintou.
2018-10-01T17:32:36Z
[]
[]
Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 364, in run app.generate() File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 136, in generate self._generate(env) File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 165, in _generate intr.run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3836, in run super().run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 380, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 404, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 398, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 409, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 705, in function_call return func(node, posargs, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 273, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 162, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3422, in func_subdir self.evaluate_codeblock(codeblock) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 404, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 398, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 413, in evaluate_statement return self.method_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 741, in method_call return obj.method_call(method_name, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 1622, in method_call value = fn(state, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 219, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 162, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/modules/i18n.py", line 89, in merge_file ifile_abs = inputfile.absolute_path(state.environment.source_dir, AttributeError: 'CustomTargetHolder' object has no attribute 'absolute_path'
9,154
mesonbuild/meson
mesonbuild__meson-4354
25fef3d1facecfb64108ef0a1439d24100593935
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -132,8 +132,8 @@ def __init__(self, build): self.build = build self.environment = build.environment self.processed_targets = {} - self.build_to_src = os.path.relpath(self.environment.get_source_dir(), - self.environment.get_build_dir()) + self.build_to_src = mesonlib.relpath(self.environment.get_source_dir(), + self.environment.get_build_dir()) def get_target_filename(self, t): if isinstance(t, build.CustomTarget): diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1540,8 +1540,8 @@ def method_call(self, method_name, args, kwargs): # because the Build object contains dicts and lists. num_targets = len(self.interpreter.build.targets) state = ModuleState( - build_to_src=os.path.relpath(self.interpreter.environment.get_source_dir(), - self.interpreter.environment.get_build_dir()), + build_to_src=mesonlib.relpath(self.interpreter.environment.get_source_dir(), + self.interpreter.environment.get_build_dir()), subproject=self.interpreter.subproject, subdir=self.interpreter.subdir, current_lineno=self.interpreter.current_lineno, @@ -2182,14 +2182,7 @@ def run_command_impl(self, node, args, kwargs, in_builddir=False): raise InterpreterException('Program or command {!r} not found ' 'or not executable'.format(cmd)) cmd = prog - try: - cmd_path = os.path.relpath(cmd.get_path(), start=srcdir) - except ValueError: - # On Windows a relative path can't be evaluated for - # paths on two different drives (i.e. c:\foo and f:\bar). - # The only thing left to is is to use the original absolute - # path. - cmd_path = cmd.get_path() + cmd_path = mesonlib.relpath(cmd.get_path(), start=srcdir) if not cmd_path.startswith('..') and cmd_path not in self.build_def_files: self.build_def_files.append(cmd_path) expanded_args = [] @@ -2206,7 +2199,7 @@ def run_command_impl(self, node, args, kwargs, in_builddir=False): if not os.path.isabs(a): a = os.path.join(builddir if in_builddir else srcdir, self.subdir, a) if os.path.isfile(a): - a = os.path.relpath(a, start=srcdir) + a = mesonlib.relpath(a, start=srcdir) if not a.startswith('..'): if a not in self.build_def_files: self.build_def_files.append(a) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -1143,3 +1143,12 @@ def __exit__(self, *args): elif have_msvcrt: msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_UNLCK, 1) self.lockfile.close() + +def relpath(path, start): + # On Windows a relative path can't be evaluated for paths on two different + # drives (i.e. c:\foo and f:\bar). The only thing left to do is to use the + # original absolute path. + try: + return os.path.relpath(path, start) + except ValueError: + return path
Cross-drive build is not supported on Windows ``` Stdout: Traceback (most recent call last): File "D:\dev\meson\mesonbuild\mesonmain.py", line 368, in run app.generate() File "D:\dev\meson\mesonbuild\mesonmain.py", line 150, in generate self._generate(env) File "D:\dev\meson\mesonbuild\mesonmain.py", line 168, in _generate g = ninjabackend.NinjaBackend(b) File "D:\dev\meson\mesonbuild\backend\ninjabackend.py", line 143, in __init__ super().__init__(build) File "D:\dev\meson\mesonbuild\backend\backends.py", line 111, in __init__ self.environment.get_build_dir()) File "C:\Python36\lib\ntpath.py", line 585, in relpath path_drive, start_drive)) ValueError: path is on mount 'D:', start on mount 'C:' ``` A little bit of debugging shows that this happens in `Backend.__init__()`, ```python self.build_to_src = os.path.relpath(self.environment.get_source_dir(), # D:\dev\meson\test cases\common\5 linkstatic self.environment.get_build_dir()) # C:\Users\$NAME\AppData\Local\Temp\tmp1iii95om ```
2018-10-09T19:46:45Z
[]
[]
Traceback (most recent call last): File "D:\dev\meson\mesonbuild\mesonmain.py", line 368, in run app.generate() File "D:\dev\meson\mesonbuild\mesonmain.py", line 150, in generate self._generate(env) File "D:\dev\meson\mesonbuild\mesonmain.py", line 168, in _generate g = ninjabackend.NinjaBackend(b) File "D:\dev\meson\mesonbuild\backend\ninjabackend.py", line 143, in __init__ super().__init__(build) File "D:\dev\meson\mesonbuild\backend\backends.py", line 111, in __init__ self.environment.get_build_dir()) File "C:\Python36\lib\ntpath.py", line 585, in relpath path_drive, start_drive)) ValueError: path is on mount 'D:', start on mount 'C:'
9,157
mesonbuild/meson
mesonbuild__meson-4414
4a9fd0e742e0cc9fb1607c182904ea48848ea1ba
diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py --- a/mesonbuild/dependencies/boost.py +++ b/mesonbuild/dependencies/boost.py @@ -443,7 +443,7 @@ def detect_lib_modules_nix(self): if self.libdir: libdirs = [self.libdir] elif self.boost_root is None: - libdirs = mesonlib.get_library_dirs(self.env) + libdirs = mesonlib.get_library_dirs() else: libdirs = [os.path.join(self.boost_root, 'lib')] for libdir in libdirs:
If Meson fails to find boost, it crashes with error "TypeError: get_library_dirs() takes 0 positional arguments but 1 was given" Tested with meson 0.48.1 Full stack trace ``` Traceback (most recent call last): File "mesonbuild/mesonmain.py", line 364, in run app.generate() File "mesonbuild/mesonmain.py", line 136, in generate self._generate(env) File "mesonbuild/mesonmain.py", line 165, in _generate intr.run() File "mesonbuild/interpreter.py", line 3836, in run super().run() File "mesonbuild/interpreterbase.py", line 380, in run self.evaluate_codeblock(self.ast, start=1) File "mesonbuild/interpreterbase.py", line 404, in evaluate_codeblock raise e File "mesonbuild/interpreterbase.py", line 398, in evaluate_codeblock self.evaluate_statement(cur) File "mesonbuild/interpreterbase.py", line 411, in evaluate_statement return self.assignment(cur) File "mesonbuild/interpreterbase.py", line 946, in assignment value = self.evaluate_statement(node.value) File "mesonbuild/interpreterbase.py", line 409, in evaluate_statement return self.function_call(cur) File "mesonbuild/interpreterbase.py", line 705, in function_call return func(node, posargs, kwargs) File "mesonbuild/interpreterbase.py", line 273, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "mesonbuild/interpreterbase.py", line 273, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "mesonbuild/interpreterbase.py", line 162, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "mesonbuild/interpreter.py", line 2998, in func_dependency dep = dependencies.find_external_dependency(name, self.environment, kwargs) File "mesonbuild/dependencies/base.py", line 1455, in find_external_dependency raise pkg_exc File "mesonbuild/dependencies/base.py", line 1409, in find_external_dependency d = c() File "mesonbuild/dependencies/boost.py", line 145, in __init__ self.detect_lib_modules() File "mesonbuild/dependencies/boost.py", line 271, in detect_lib_modules self.detect_lib_modules_nix() File "mesonbuild/dependencies/boost.py", line 446, in detect_lib_modules_nix libdirs = mesonlib.get_library_dirs(self.env) TypeError: get_library_dirs() takes 0 positional arguments but 1 was given ```
2018-10-24T18:17:51Z
[]
[]
Traceback (most recent call last): File "mesonbuild/mesonmain.py", line 364, in run app.generate() File "mesonbuild/mesonmain.py", line 136, in generate self._generate(env) File "mesonbuild/mesonmain.py", line 165, in _generate intr.run() File "mesonbuild/interpreter.py", line 3836, in run super().run() File "mesonbuild/interpreterbase.py", line 380, in run self.evaluate_codeblock(self.ast, start=1) File "mesonbuild/interpreterbase.py", line 404, in evaluate_codeblock raise e File "mesonbuild/interpreterbase.py", line 398, in evaluate_codeblock self.evaluate_statement(cur) File "mesonbuild/interpreterbase.py", line 411, in evaluate_statement return self.assignment(cur) File "mesonbuild/interpreterbase.py", line 946, in assignment value = self.evaluate_statement(node.value) File "mesonbuild/interpreterbase.py", line 409, in evaluate_statement return self.function_call(cur) File "mesonbuild/interpreterbase.py", line 705, in function_call return func(node, posargs, kwargs) File "mesonbuild/interpreterbase.py", line 273, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "mesonbuild/interpreterbase.py", line 273, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "mesonbuild/interpreterbase.py", line 162, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "mesonbuild/interpreter.py", line 2998, in func_dependency dep = dependencies.find_external_dependency(name, self.environment, kwargs) File "mesonbuild/dependencies/base.py", line 1455, in find_external_dependency raise pkg_exc File "mesonbuild/dependencies/base.py", line 1409, in find_external_dependency d = c() File "mesonbuild/dependencies/boost.py", line 145, in __init__ self.detect_lib_modules() File "mesonbuild/dependencies/boost.py", line 271, in detect_lib_modules self.detect_lib_modules_nix() File "mesonbuild/dependencies/boost.py", line 446, in detect_lib_modules_nix libdirs = mesonlib.get_library_dirs(self.env) TypeError: get_library_dirs() takes 0 positional arguments but 1 was given
9,162
mesonbuild/meson
mesonbuild__meson-4479
11e3011a6bf0adeb51582c590c90b0f4dccb4df8
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -371,13 +371,17 @@ def preexec_fn(): endtime = time.time() duration = endtime - starttime if additional_error is None: - stdout.seek(0) - stdo = decode(stdout.read()) - if stderr != stdout: - stderr.seek(0) - stde = decode(stderr.read()) + if stdout is None: # if stdout is None stderr should be as well + stdo = '' + stde = '' else: - stde = "" + stdout.seek(0) + stdo = decode(stdout.read()) + if stderr != stdout: + stderr.seek(0) + stde = decode(stderr.read()) + else: + stde = "" else: stdo = "" stde = additional_error
AttributeError: 'NoneType' object has no attribute 'seek' I happened to still install meson master in pygobject CI, which just broke: The result of executing `xvfb-run -a meson test -C _build -v` on a gitlab runner: ``` Traceback (most recent call last): File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 109, in run return options.run_func(options) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 783, in run return th.doit() File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 533, in doit self.run_tests(tests) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 693, in run_tests self.drain_futures(futures) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 708, in drain_futures result.result() File "/usr/lib/python3.6/concurrent/futures/_base.py", line 432, in result return self.__get_result() File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result raise self._exception File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 265, in run return self._run_cmd(wrap + cmd + self.test.cmd_args + self.options.test_args) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 374, in _run_cmd stdout.seek(0) AttributeError: 'NoneType' object has no attribute 'seek' ```
@marcelhollerbach could this be caused by #4449?
2018-11-06T20:55:22Z
[]
[]
Traceback (most recent call last): File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 109, in run return options.run_func(options) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 783, in run return th.doit() File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 533, in doit self.run_tests(tests) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 693, in run_tests self.drain_futures(futures) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 708, in drain_futures result.result() File "/usr/lib/python3.6/concurrent/futures/_base.py", line 432, in result return self.__get_result() File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result raise self._exception File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 265, in run return self._run_cmd(wrap + cmd + self.test.cmd_args + self.options.test_args) File "/home/user/.local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 374, in _run_cmd stdout.seek(0) AttributeError: 'NoneType' object has no attribute 'seek'
9,169
mesonbuild/meson
mesonbuild__meson-4601
ca2e378c988f92a339e51ad8bd5a61da8d1cbe55
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -539,7 +539,11 @@ def print_collected_logs(self): print('--- Listing only the last 100 lines from a long log. ---') lines = lines[-100:] for line in lines: - print(line) + try: + print(line) + except UnicodeEncodeError: + line = line.encode('ascii', errors='replace').decode() + print(line) def doit(self): if self.is_run:
`meson test` crashes with "UnicodeEncodeError: 'ascii' codec can't encode character '\u2192' in position 2: ordinal not in range(128)" A real-world example can be found at the end of https://travis-ci.org/systemd/systemd/jobs/464904604. Below is an artificial reproducer where `PYTHONIOENCODING=ascii` is used to set `sys.stdout.encoding` to `ascii`: ``` $ cat meson.build # SPDX-License-Identifier: LGPL-2.1+ project('systemd', 'c', version : '239', license : 'LGPLv2+', meson_version : '>= 0.46', ) print_arrow = find_program('print-arrow.sh') test('print arrow', print_arrow) $ cat print-arrow.sh #!/bin/bash printf 'a \u2192 b' exit 1 $ meson --version 0.48.2 $ meson ./build/ ... $ PYTHONIOENCODING=ascii ninja -v -C ./build/ test 1/1 print arrow FAIL 0.01 s (exit status 1) OK: 0 FAIL: 1 SKIP: 0 TIMEOUT: 0 The output from the failed tests: 1/1 print arrow FAIL 0.01 s (exit status 1) --- command --- /home/vagrant/TEST/print-arrow.sh --- stdout --- Traceback (most recent call last): File "/usr/local/bin/meson", line 11, in <module> load_entry_point('meson==0.48.2', 'console_scripts', 'meson')() File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 392, in main return run(sys.argv[1:], launcher) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 302, in run return mtest.run(remaining_args) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 778, in run return th.doit() File "/usr/local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 526, in doit self.run_tests(tests) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 688, in run_tests self.print_collected_logs() File "/usr/local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 517, in print_collected_logs print(line) UnicodeEncodeError: 'ascii' codec can't encode character '\u2192' in position 2: ordinal not in range(128) FAILED: meson-test /usr/local/bin/meson test --no-rebuild --print-errorlogs ninja: build stopped: subcommand failed. ```
2018-12-07T20:04:36Z
[]
[]
Traceback (most recent call last): File "/usr/local/bin/meson", line 11, in <module> load_entry_point('meson==0.48.2', 'console_scripts', 'meson')() File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 392, in main return run(sys.argv[1:], launcher) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 302, in run return mtest.run(remaining_args) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 778, in run return th.doit() File "/usr/local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 526, in doit self.run_tests(tests) File "/usr/local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 688, in run_tests self.print_collected_logs() File "/usr/local/lib/python3.6/site-packages/mesonbuild/mtest.py", line 517, in print_collected_logs print(line) UnicodeEncodeError: 'ascii' codec can't encode character '\u2192' in position 2: ordinal not in range(128)
9,176
mesonbuild/meson
mesonbuild__meson-4719
bbcf80d7348135e0590622a7b85c30429f005c07
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -17,6 +17,7 @@ import importlib import traceback import argparse +import codecs from . import mesonlib from . import mlog @@ -148,6 +149,17 @@ def run_script_command(script_name, script_args): mlog.exception(e) return 1 +def ensure_stdout_accepts_unicode(): + if sys.stdout.encoding and not sys.stdout.encoding.upper().startswith('UTF-'): + if sys.version_info >= (3, 7): + sys.stdout.reconfigure(errors='surrogateescape') + else: + sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach(), + errors='surrogateescape') + sys.stdout.encoding = 'UTF-8' + if not hasattr(sys.stdout, 'buffer'): + sys.stdout.buffer = sys.stdout.raw if hasattr(sys.stdout, 'raw') else sys.stdout + def run(original_args, mainfile): if sys.version_info < (3, 5): print('Meson works correctly only with python 3.5+.') @@ -155,6 +167,11 @@ def run(original_args, mainfile): print('Please update your environment') return 1 + # Meson gets confused if stdout can't output Unicode, if the + # locale isn't Unicode, just force stdout to accept it. This tries + # to emulate enough of PEP 540 to work elsewhere. + ensure_stdout_accepts_unicode() + # https://github.com/mesonbuild/meson/issues/3653 if sys.platform.lower() == 'msys': mlog.error('This python3 seems to be msys/python on MSYS2 Windows, which is known to have path semantics incompatible with Meson') diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -647,8 +647,8 @@ def open_log_files(self): self.logfilename = logfile_base + '.txt' self.jsonlogfilename = logfile_base + '.json' - self.jsonlogfile = open(self.jsonlogfilename, 'w', encoding='utf-8') - self.logfile = open(self.logfilename, 'w', encoding='utf-8') + self.jsonlogfile = open(self.jsonlogfilename, 'w', encoding='utf-8', errors='replace') + self.logfile = open(self.logfilename, 'w', encoding='utf-8', errors='surrogateescape') self.logfile.write('Log of Meson test suite run on %s\n\n' % datetime.datetime.now().isoformat())
meson test fails if LANG variable contains characters not valid in the current locale To reproduce: Add an environment variable with an accent: `export BLOB=éêà` Set LANG to a something that doesn'T contain the characters `export LANG=POSIX` Run meson test `meson test -C build/` See surrogates error: ``` root@276e4c1f828a libnice]# meson test -C build/ ninja: Entering directory `/root/libnice/build' ninja: no work to do. Traceback (most recent call last): File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 111, in run return options.run_func(options) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mtest.py", line 805, in run return th.doit() File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mtest.py", line 555, in doit self.run_tests(tests) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mtest.py", line 686, in run_tests self.open_log_files() File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mtest.py", line 656, in open_log_files self.logfile.write('Inherited environment: {}\n\n'.format(inherit_env)) UnicodeEncodeError: 'utf-8' codec can't encode characters in position 1658-1659: surrogates not allowed ```
2019-01-04T13:54:46Z
[]
[]
Traceback (most recent call last): File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 111, in run return options.run_func(options) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mtest.py", line 805, in run return th.doit() File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mtest.py", line 555, in doit self.run_tests(tests) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mtest.py", line 686, in run_tests self.open_log_files() File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/mesonbuild/mtest.py", line 656, in open_log_files self.logfile.write('Inherited environment: {}\n\n'.format(inherit_env)) UnicodeEncodeError: 'utf-8' codec can't encode characters in position 1658-1659: surrogates not allowed
9,193
mesonbuild/meson
mesonbuild__meson-4740
3bf2ca483e9ca80ee81ee0a07d5f5c9f36817bb3
diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py --- a/mesonbuild/modules/rpm.py +++ b/mesonbuild/modules/rpm.py @@ -29,39 +29,16 @@ class RPMModule(ExtensionModule): @noKwargs - def generate_spec_template(self, state, args, kwargs): - compiler_deps = set() - for compiler in state.compilers.values(): - # Elbrus has one 'lcc' package for every compiler - if isinstance(compiler, compilers.GnuCCompiler): - compiler_deps.add('gcc') - elif isinstance(compiler, compilers.GnuCPPCompiler): - compiler_deps.add('gcc-c++') - elif isinstance(compiler, compilers.ElbrusCCompiler): - compiler_deps.add('lcc') - elif isinstance(compiler, compilers.ElbrusCPPCompiler): - compiler_deps.add('lcc') - elif isinstance(compiler, compilers.ElbrusFortranCompiler): - compiler_deps.add('lcc') - elif isinstance(compiler, compilers.ValaCompiler): - compiler_deps.add('vala') - elif isinstance(compiler, compilers.GnuFortranCompiler): - compiler_deps.add('gcc-gfortran') - elif isinstance(compiler, compilers.GnuObjCCompiler): - compiler_deps.add('gcc-objc') - elif compiler == compilers.GnuObjCPPCompiler: - compiler_deps.add('gcc-objc++') - else: - mlog.log('RPM spec file will not created, generating not allowed for:', - mlog.bold(compiler.get_id())) - return - proj = state.project_name.replace(' ', '_').replace('\t', '_') + def generate_spec_template(self, coredata, args, kwargs): + self.coredata = coredata + required_compilers = self.__get_required_compilers() + proj = coredata.project_name.replace(' ', '_').replace('\t', '_') so_installed = False devel_subpkg = False files = set() files_devel = set() to_delete = set() - for target in state.targets.values(): + for target in coredata.targets.values(): if isinstance(target, build.Executable) and target.need_install: files.add('%%{_bindir}/%s' % target.get_filename()) elif isinstance(target, build.SharedLibrary) and target.need_install: @@ -80,18 +57,19 @@ def generate_spec_template(self, state, args, kwargs): files_devel.add('%%{_datadir}/gir-1.0/%s' % target.get_filename()[0]) elif isinstance(target, TypelibTarget) and target.should_install(): files.add('%%{_libdir}/girepository-1.0/%s' % target.get_filename()[0]) - for header in state.headers: + for header in coredata.headers: if len(header.get_install_subdir()) > 0: files_devel.add('%%{_includedir}/%s/' % header.get_install_subdir()) else: for hdr_src in header.get_sources(): files_devel.add('%%{_includedir}/%s' % hdr_src) - for man in state.man: + for man in coredata.man: for man_file in man.get_sources(): files.add('%%{_mandir}/man%u/%s.*' % (int(man_file.split('.')[-1]), man_file)) if len(files_devel) > 0: devel_subpkg = True - filename = os.path.join(state.environment.get_build_dir(), + + filename = os.path.join(coredata.environment.get_build_dir(), '%s.spec' % proj) with open(filename, 'w+') as fn: fn.write('Name: %s\n' % proj) @@ -102,24 +80,28 @@ def generate_spec_template(self, state, args, kwargs): fn.write('\n') fn.write('Source0: %{name}-%{version}.tar.xz # FIXME\n') fn.write('\n') - for compiler in compiler_deps: + fn.write('BuildRequires: meson\n') + for compiler in required_compilers: fn.write('BuildRequires: %s\n' % compiler) - for dep in state.environment.coredata.deps: + for dep in coredata.environment.coredata.deps: fn.write('BuildRequires: pkgconfig(%s)\n' % dep[0]) - for lib in state.environment.coredata.ext_libs.values(): - name = lib.get_name() - fn.write('BuildRequires: {} # FIXME\n'.format(name)) - mlog.warning('replace', mlog.bold(name), 'with the real package.', - 'You can use following command to find package which ' - 'contains this lib:', - mlog.bold("dnf provides '*/lib{}.so'".format(name))) - for prog in state.environment.coredata.ext_progs.values(): - if not prog.found(): - fn.write('BuildRequires: %%{_bindir}/%s # FIXME\n' % - prog.get_name()) - else: - fn.write('BuildRequires: {}\n'.format(prog.get_path())) - fn.write('BuildRequires: meson\n') +# ext_libs and ext_progs have been removed from coredata so the following code +# no longer works. It is kept as a reminder of the idea should anyone wish +# to re-implement it. +# +# for lib in state.environment.coredata.ext_libs.values(): +# name = lib.get_name() +# fn.write('BuildRequires: {} # FIXME\n'.format(name)) +# mlog.warning('replace', mlog.bold(name), 'with the real package.', +# 'You can use following command to find package which ' +# 'contains this lib:', +# mlog.bold("dnf provides '*/lib{}.so'".format(name))) +# for prog in state.environment.coredata.ext_progs.values(): +# if not prog.found(): +# fn.write('BuildRequires: %%{_bindir}/%s # FIXME\n' % +# prog.get_name()) +# else: +# fn.write('BuildRequires: {}\n'.format(prog.get_path())) fn.write('\n') fn.write('%description\n') fn.write('\n') @@ -167,5 +149,33 @@ def generate_spec_template(self, state, args, kwargs): mlog.log('RPM spec template written to %s.spec.\n' % proj) return ModuleReturnValue(None, []) + def __get_required_compilers(self): + required_compilers = set() + for compiler in self.coredata.compilers.values(): + # Elbrus has one 'lcc' package for every compiler + if isinstance(compiler, compilers.GnuCCompiler): + required_compilers.add('gcc') + elif isinstance(compiler, compilers.GnuCPPCompiler): + required_compilers.add('gcc-c++') + elif isinstance(compiler, compilers.ElbrusCCompiler): + required_compilers.add('lcc') + elif isinstance(compiler, compilers.ElbrusCPPCompiler): + required_compilers.add('lcc') + elif isinstance(compiler, compilers.ElbrusFortranCompiler): + required_compilers.add('lcc') + elif isinstance(compiler, compilers.ValaCompiler): + required_compilers.add('vala') + elif isinstance(compiler, compilers.GnuFortranCompiler): + required_compilers.add('gcc-gfortran') + elif isinstance(compiler, compilers.GnuObjCCompiler): + required_compilers.add('gcc-objc') + elif compiler == compilers.GnuObjCPPCompiler: + required_compilers.add('gcc-objc++') + else: + mlog.log('RPM spec file not created, generation not allowed for:', + mlog.bold(compiler.get_id())) + return required_compilers + + def initialize(*args, **kwargs): return RPMModule(*args, **kwargs)
rpm module doesn't generate template When attempting to use the [RPM module](http://mesonbuild.com/RPM-module.html#rpm-module) with meson 0.41.2, it generates the following traceback: ``` Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 307, in run app.generate() File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 180, in generate intr.run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2544, in run super().run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 125, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 361, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 47, in wrapped return f(self, node, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2261, in func_subdir self.evaluate_codeblock(codeblock) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 155, in evaluate_statement return self.method_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 389, in method_call return obj.method_call(method_name, self.flatten(args), kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 1060, in method_call value = fn(state, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/modules/rpm.py", line 100, in generate_spec_template for lib in state.environment.coredata.ext_libs.values(): AttributeError: 'CoreData' object has no attribute 'ext_libs' ```
Pinging @ignatenkobrain Igor is vacationing, so he won't be able to look into this right now. Is it blocking something urgent for you? @ignatenkobrain poke This broke in 2015 and no one noticed: ``` commit 06c7cef26ebe8b34658791adf4d6e7fcd02b173b Author: Jussi Pakkanen <[email protected]> Date: Tue Nov 24 17:49:12 2015 +0200 ``` I don't think the rpm module is getting any maintenance at all. I have previously also found things in it that had been broken for 1-2 years. We should consider removing it or disabling it till we have automated tests for it. I have version 0.43.0 and still see the same bug. can I create an rpm in a different way ? is there an estimation for fixing this bug ? Bug is still present in 0.47.1. Maybe the rpm module should be removed?
2019-01-07T23:09:33Z
[]
[]
Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 307, in run app.generate() File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 180, in generate intr.run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2544, in run super().run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 125, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 361, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 47, in wrapped return f(self, node, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2261, in func_subdir self.evaluate_codeblock(codeblock) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 155, in evaluate_statement return self.method_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 389, in method_call return obj.method_call(method_name, self.flatten(args), kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 1060, in method_call value = fn(state, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/modules/rpm.py", line 100, in generate_spec_template for lib in state.environment.coredata.ext_libs.values(): AttributeError: 'CoreData' object has no attribute 'ext_libs'
9,196
mesonbuild/meson
mesonbuild__meson-4962
92f95b3326579944ebfe6b49ee7ffd1e57400601
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -142,10 +142,11 @@ def func_dependency(self, node, args, kwargs): }] def build_target(self, node, args, kwargs, targetclass): + args = self.flatten_args(args) if not args: return kwargs = self.flatten_kwargs(kwargs, True) - name = self.flatten_args(args)[0] + name = args[0] srcqueue = [node] if 'sources' in kwargs: srcqueue += kwargs['sources']
Running "meson configure" in source directory raises an exception First bad commit is 939b011114838b886d48521806988973205aecb4, cc @mensinda ``` [0] [akari@navi] [*powersurge ← /home/akari/git/taisei] % meson configure Unable to evaluate subdir([]) in AstInterpreter --> Skipping Traceback (most recent call last): File "/data/git/meson/mesonbuild/mesonmain.py", line 115, in run return options.run_func(options) File "/data/git/meson/mesonbuild/mconf.py", line 200, in run c = Conf(builddir) File "/data/git/meson/mesonbuild/mconf.py", line 56, in __init__ intr.analyze() File "/data/git/meson/mesonbuild/ast/introspection.py", line 255, in analyze self.run() File "/data/git/meson/mesonbuild/interpreterbase.py", line 407, in run self.evaluate_codeblock(self.ast, start=1) File "/data/git/meson/mesonbuild/interpreterbase.py", line 431, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 425, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 436, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 762, in function_call return func(node, posargs, kwargs) File "/data/git/meson/mesonbuild/ast/interpreter.py", line 148, in func_subdir self.evaluate_codeblock(codeblock) File "/data/git/meson/mesonbuild/interpreterbase.py", line 431, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 425, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 438, in evaluate_statement return self.assignment(cur) File "/data/git/meson/mesonbuild/ast/interpreter.py", line 203, in assignment self.evaluate_statement(node.value) # Evaluate the value just in case File "/data/git/meson/mesonbuild/interpreterbase.py", line 436, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 762, in function_call return func(node, posargs, kwargs) File "/data/git/meson/mesonbuild/ast/introspection.py", line 209, in func_executable return self.build_target(node, args, kwargs, Executable) File "/data/git/meson/mesonbuild/ast/introspection.py", line 148, in build_target name = self.flatten_args(args)[0] IndexError: list index out of range [2] [akari@navi] [*powersurge ← /home/akari/git/taisei] % ls COPYING README.rst atlas doc external meson.build meson_options.txt misc resources scripts src subprojects taisei.kdev4 trees xdg ```
2019-02-22T10:33:41Z
[]
[]
Traceback (most recent call last): File "/data/git/meson/mesonbuild/mesonmain.py", line 115, in run return options.run_func(options) File "/data/git/meson/mesonbuild/mconf.py", line 200, in run c = Conf(builddir) File "/data/git/meson/mesonbuild/mconf.py", line 56, in __init__ intr.analyze() File "/data/git/meson/mesonbuild/ast/introspection.py", line 255, in analyze self.run() File "/data/git/meson/mesonbuild/interpreterbase.py", line 407, in run self.evaluate_codeblock(self.ast, start=1) File "/data/git/meson/mesonbuild/interpreterbase.py", line 431, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 425, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 436, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 762, in function_call return func(node, posargs, kwargs) File "/data/git/meson/mesonbuild/ast/interpreter.py", line 148, in func_subdir self.evaluate_codeblock(codeblock) File "/data/git/meson/mesonbuild/interpreterbase.py", line 431, in evaluate_codeblock raise e File "/data/git/meson/mesonbuild/interpreterbase.py", line 425, in evaluate_codeblock self.evaluate_statement(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 438, in evaluate_statement return self.assignment(cur) File "/data/git/meson/mesonbuild/ast/interpreter.py", line 203, in assignment self.evaluate_statement(node.value) # Evaluate the value just in case File "/data/git/meson/mesonbuild/interpreterbase.py", line 436, in evaluate_statement return self.function_call(cur) File "/data/git/meson/mesonbuild/interpreterbase.py", line 762, in function_call return func(node, posargs, kwargs) File "/data/git/meson/mesonbuild/ast/introspection.py", line 209, in func_executable return self.build_target(node, args, kwargs, Executable) File "/data/git/meson/mesonbuild/ast/introspection.py", line 148, in build_target name = self.flatten_args(args)[0] IndexError: list index out of range
9,218
mesonbuild/meson
mesonbuild__meson-5007
f0b0bcf86d195cc65918eea0de2c92083ac39f3f
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -405,7 +405,8 @@ def __init__(self, lineno, colno, condition, block): self.block = block class TernaryNode(BaseNode): - def __init__(self, lineno, colno, condition, trueblock, falseblock): + def __init__(self, subdir, lineno, colno, condition, trueblock, falseblock): + self.subdir = subdir self.lineno = lineno self.colno = colno self.condition = condition @@ -540,7 +541,7 @@ def e1(self): self.expect('colon') falseblock = self.e1() self.in_ternary = False - return TernaryNode(left.lineno, left.colno, left, trueblock, falseblock) + return TernaryNode(left.subdir, left.lineno, left.colno, left, trueblock, falseblock) return left def e2(self):
Ternary operator inside format() fails ``` x = true message('Using feature XXX @0@'.format(x ? 'yes' : 'no')) ``` produces ``` Traceback (most recent call last): File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 353, in run app.generate() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 148, in generate self._generate(env) File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 188, in _generate intr = interpreter.Interpreter(b, g) File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1327, in __init__ self.load_root_meson_file() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 124, in load_root_meson_file self.ast = mparser.Parser(code, self.subdir).parse() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 443, in parse block = self.codeblock() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 679, in codeblock curline = self.line() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 673, in line return self.statement() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 448, in statement return self.e1() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 451, in e1 left = self.e2() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 476, in e2 left = self.e3() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 485, in e3 left = self.e4() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 494, in e4 left = self.e5() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 501, in e5 return self.e5add() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 504, in e5add left = self.e5sub() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 510, in e5sub left = self.e5mod() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 516, in e5mod left = self.e5mul() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 522, in e5mul left = self.e5div() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 528, in e5div left = self.e6() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 538, in e6 return self.e7() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 544, in e7 args = self.args() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 589, in args s = self.statement() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 448, in statement return self.e1() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 451, in e1 left = self.e2() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 476, in e2 left = self.e3() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 485, in e3 left = self.e4() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 494, in e4 left = self.e5() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 501, in e5 return self.e5add() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 504, in e5add left = self.e5sub() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 510, in e5sub left = self.e5mod() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 516, in e5mod left = self.e5mul() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 522, in e5mul left = self.e5div() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 528, in e5div left = self.e6() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 538, in e6 return self.e7() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 555, in e7 left = self.method_call(left) File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 618, in method_call args = self.args() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 590, in args a = ArgumentNode(s) File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 351, in __init__ self.subdir = token.subdir AttributeError: 'TernaryNode' object has no attribute 'subdir' ``` Adding extra parenthesis around the ternary doesn't make any difference.
2019-03-02T00:38:43Z
[]
[]
Traceback (most recent call last): File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 353, in run app.generate() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 148, in generate self._generate(env) File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 188, in _generate intr = interpreter.Interpreter(b, g) File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1327, in __init__ self.load_root_meson_file() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 124, in load_root_meson_file self.ast = mparser.Parser(code, self.subdir).parse() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 443, in parse block = self.codeblock() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 679, in codeblock curline = self.line() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 673, in line return self.statement() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 448, in statement return self.e1() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 451, in e1 left = self.e2() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 476, in e2 left = self.e3() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 485, in e3 left = self.e4() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 494, in e4 left = self.e5() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 501, in e5 return self.e5add() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 504, in e5add left = self.e5sub() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 510, in e5sub left = self.e5mod() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 516, in e5mod left = self.e5mul() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 522, in e5mul left = self.e5div() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 528, in e5div left = self.e6() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 538, in e6 return self.e7() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 544, in e7 args = self.args() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 589, in args s = self.statement() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 448, in statement return self.e1() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 451, in e1 left = self.e2() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 476, in e2 left = self.e3() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 485, in e3 left = self.e4() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 494, in e4 left = self.e5() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 501, in e5 return self.e5add() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 504, in e5add left = self.e5sub() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 510, in e5sub left = self.e5mod() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 516, in e5mod left = self.e5mul() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 522, in e5mul left = self.e5div() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 528, in e5div left = self.e6() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 538, in e6 return self.e7() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 555, in e7 left = self.method_call(left) File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 618, in method_call args = self.args() File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 590, in args a = ArgumentNode(s) File "/home/adrian/.local/lib/python3.5/site-packages/mesonbuild/mparser.py", line 351, in __init__ self.subdir = token.subdir AttributeError: 'TernaryNode' object has no attribute 'subdir'
9,219
mesonbuild/meson
mesonbuild__meson-5058
dd2c44cdf6f8ed8a969d0666cafb08aaf78a919d
diff --git a/mesonbuild/build.py b/mesonbuild/build.py --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -2307,8 +2307,13 @@ def load(build_dir): obj = pickle.load(f) except FileNotFoundError: raise MesonException(nonexisting_fail_msg) - except pickle.UnpicklingError: + except (pickle.UnpicklingError, EOFError): raise MesonException(load_fail_msg) + except AttributeError: + raise MesonException( + "Build data file {!r} references functions or classes that don't " + "exist. This probably means that it was generated with an old " + "version of meson. Try running meson {} --wipe".format(filename, build_dir)) if not isinstance(obj, Build): raise MesonException(load_fail_msg) return obj
0.50.0: test target: AttributeError: Can't get attribute 'ConfigData' on <module 'mesonbuild.coredata' from '/usr/lib/python3.7/site-packages/mesonbuild/coredata.py'> <pre>+ /usr/bin/ninja test -v -j4 -C x86_64-redhat-linux-gnu ninja: Entering directory `x86_64-redhat-linux-gnu&apos; [0/1] /usr/bin/meson test --no-rebuild --print-errorlogs Traceback (most recent call last): File &quot;/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py&quot;, line 122, in run return options.run_func(options) File &quot;/usr/lib/python3.7/site-packages/mesonbuild/mtest.py&quot;, line 1002, in run return th.doit() File &quot;/usr/lib/python3.7/site-packages/mesonbuild/mtest.py&quot;, line 753, in doit self.run_tests(tests) File &quot;/usr/lib/python3.7/site-packages/mesonbuild/mtest.py&quot;, line 888, in run_tests self.build_data = build.load(os.getcwd()) File &quot;/usr/lib/python3.7/site-packages/mesonbuild/build.py&quot;, line 2307, in load obj = pickle.load(f) AttributeError: Can&apos;t get attribute &apos;ConfigData&apos; on &lt;module &apos;mesonbuild.coredata&apos; from &apos;/usr/lib/python3.7/site-packages/mesonbuild/coredata.py&apos;&gt; FAILED: meson-test /usr/bin/meson test --no-rebuild --print-errorlogs ninja: build stopped: subcommand failed. error: Bad exit status from /var/tmp/rpm-tmp.GduYpo (%check) </pre>
Is this with a fresh build directory? No, this looks like another bug with the rebuild for new version thing, I thought we caught those all... I can replicate this using test case 192.
2019-03-11T19:11:50Z
[]
[]
Traceback (most recent call last): File &quot;/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py&quot;, line 122, in run return options.run_func(options) File &quot;/usr/lib/python3.7/site-packages/mesonbuild/mtest.py&quot;, line 1002, in run return th.doit() File &quot;/usr/lib/python3.7/site-packages/mesonbuild/mtest.py&quot;, line 753, in doit self.run_tests(tests) File &quot;/usr/lib/python3.7/site-packages/mesonbuild/mtest.py&quot;, line 888, in run_tests self.build_data = build.load(os.getcwd()) File &quot;/usr/lib/python3.7/site-packages/mesonbuild/build.py&quot;, line 2307, in load obj = pickle.load(f) AttributeError: Can&apos;t get attribute &apos;ConfigData&apos; on &lt;module &apos;mesonbuild.coredata&apos; from &apos;/usr/lib/python3.7/site-packages/mesonbuild/coredata.py&apos;&gt;
9,222
mesonbuild/meson
mesonbuild__meson-5197
75219989ca468923142738d93df8aef64e897b8e
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -153,8 +153,20 @@ def method_call(self, node): return True def evaluate_arithmeticstatement(self, cur): + self.evaluate_statement(cur.left) + self.evaluate_statement(cur.right) return 0 + def evaluate_uminusstatement(self, cur): + self.evaluate_statement(cur.value) + return 0 + + def evaluate_ternary(self, node): + assert(isinstance(node, mparser.TernaryNode)) + self.evaluate_statement(node.condition) + self.evaluate_statement(node.trueblock) + self.evaluate_statement(node.falseblock) + def evaluate_plusassign(self, node): assert(isinstance(node, mparser.PlusAssignmentNode)) if node.var_name not in self.assignments: @@ -177,6 +189,18 @@ def reduce_arguments(self, args): return args.arguments, args.kwargs def evaluate_comparison(self, node): + self.evaluate_statement(node.left) + self.evaluate_statement(node.right) + return False + + def evaluate_andstatement(self, cur): + self.evaluate_statement(cur.left) + self.evaluate_statement(cur.right) + return False + + def evaluate_orstatement(self, cur): + self.evaluate_statement(cur.left) + self.evaluate_statement(cur.right) return False def evaluate_foreach(self, node): diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -20,7 +20,7 @@ from .. import coredata as cdata from ..interpreterbase import InvalidArguments from ..build import Executable, Jar, SharedLibrary, SharedModule, StaticLibrary -from ..mparser import ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode +from ..mparser import BaseNode, ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode import os build_target_functions = ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries'] @@ -142,6 +142,8 @@ def func_dependency(self, node, args, kwargs): condition_level = node.condition_level if hasattr(node, 'condition_level') else 0 if isinstance(required, ElementaryNode): required = required.value + if not isinstance(required, bool): + required = False self.dependencies += [{ 'name': name, 'required': required, @@ -189,6 +191,8 @@ def build_target(self, node, args, kwargs, targetclass): # Make sure nothing can crash when creating the build class kwargs_reduced = {k: v for k, v in kwargs.items() if k in targetclass.known_kwargs and k in ['install', 'build_by_default', 'build_always']} + kwargs_reduced = {k: v.value if isinstance(v, ElementaryNode) else v for k, v in kwargs_reduced.items()} + kwargs_reduced = {k: v for k, v in kwargs_reduced.items() if not isinstance(v, BaseNode)} is_cross = False objects = [] empty_sources = [] # Passing the unresolved sources list causes errors diff --git a/run_unittests.py b/run_unittests.py --- a/run_unittests.py +++ b/run_unittests.py @@ -3408,7 +3408,7 @@ def assertKeyTypes(key_type_list, obj): self.assertDictEqual(buildopts_to_find, {}) # Check buildsystem_files - bs_files = ['meson.build', 'sharedlib/meson.build', 'staticlib/meson.build'] + bs_files = ['meson.build', 'meson_options.txt', 'sharedlib/meson.build', 'staticlib/meson.build'] bs_files = [os.path.join(testdir, x) for x in bs_files] self.assertPathListEqual(list(sorted(res['buildsystem_files'])), list(sorted(bs_files))) @@ -3559,6 +3559,12 @@ def test_introspect_dependencies_from_source(self): 'has_fallback': False, 'conditional': False }, + { + 'name': 'bugDep1', + 'required': False, + 'has_fallback': False, + 'conditional': False + }, { 'name': 'somethingthatdoesnotexist', 'required': True,
Python error on introspect on meson.build file Some introspect methods work on unconfigured builds, but for the other I gets a Python exception. ``` $ meson introspect --dependencies meson.build Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 122, in run return options.run_func(options) File "/usr/lib/python3.7/site-packages/mesonbuild/mintro.py", line 405, in run return print_results(options, results, indent) File "/usr/lib/python3.7/site-packages/mesonbuild/mintro.py", line 374, in print_results print(json.dumps(results[0][1], indent=indent)) File "/usr/lib64/python3.7/json/__init__.py", line 238, in dumps **kw).encode(obj) File "/usr/lib64/python3.7/json/encoder.py", line 201, in encode chunks = list(chunks) File "/usr/lib64/python3.7/json/encoder.py", line 429, in _iterencode yield from _iterencode_list(o, _current_indent_level) File "/usr/lib64/python3.7/json/encoder.py", line 325, in _iterencode_list yield from chunks File "/usr/lib64/python3.7/json/encoder.py", line 405, in _iterencode_dict yield from chunks File "/usr/lib64/python3.7/json/encoder.py", line 438, in _iterencode o = _default(o) File "/usr/lib64/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type FunctionNode is not JSON serializable ```
Do you have the `meson.build` publically available? Unfortunately, the stack trace alone isn't enough to find the underlying bug in this case.
2019-04-02T09:42:36Z
[]
[]
Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 122, in run return options.run_func(options) File "/usr/lib/python3.7/site-packages/mesonbuild/mintro.py", line 405, in run return print_results(options, results, indent) File "/usr/lib/python3.7/site-packages/mesonbuild/mintro.py", line 374, in print_results print(json.dumps(results[0][1], indent=indent)) File "/usr/lib64/python3.7/json/__init__.py", line 238, in dumps **kw).encode(obj) File "/usr/lib64/python3.7/json/encoder.py", line 201, in encode chunks = list(chunks) File "/usr/lib64/python3.7/json/encoder.py", line 429, in _iterencode yield from _iterencode_list(o, _current_indent_level) File "/usr/lib64/python3.7/json/encoder.py", line 325, in _iterencode_list yield from chunks File "/usr/lib64/python3.7/json/encoder.py", line 405, in _iterencode_dict yield from chunks File "/usr/lib64/python3.7/json/encoder.py", line 438, in _iterencode o = _default(o) File "/usr/lib64/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type FunctionNode is not JSON serializable
9,244