Add information how to fix common build error on Windows in symlink-install-tree
PATCH v2 1/1 Add information how to fix common build error on Windows in symlink-install-tree
By default, Windows doesn't allow to create soft links for user account and only administrator is allowed to do this. To fix this problem you have to raise your permissions or enable Developer Mode, which available since Windows 10. Additional explanation when build fails will allow developer to fix the problem on his computer faster.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1386
v2:
Removed unnecessary newlines to be consistent with QEMU coding styles.
--- scripts/symlink-install-tree.py | 5 +++++ 1 file changed, 5 insertions(+)
scripts/symlink-install-tree.py +5 -0
@@ -7,12 +7,14 @@ import subprocess import sys + def destdir_join(d1: str, d2: str) -> str: if not d1: return d2 # c:\destdir + c:\prefix must produce c:\destdir\prefix return str(PurePath(d1, *PurePath(d2).parts[1:])) + introspect = os.environ.get('MESONINTROSPECT') out = subprocess.run([*introspect.split(' '), '--installed'], stdout=subprocess.PIPE, check=True).stdout
@@ -28,5 +30,8 @@ def destdir_join(d1: str, d2: str) -> str: os.symlink(source, bundle_dest) except BaseException as e: if not isinstance(e, OSError) or e.errno != errno.EEXIST: + if os.name == 'nt': + print('Please enable Developer Mode to support soft link ' + 'without Administrator permission') print(f'error making symbolic link {dest}', file=sys.stderr) raise e
Signature · 1 line
2.40.1
Quoted 8 lines · Mateusz Krawczuk
By default, Windows doesn't allow to create soft links for user account and only administrator is allowed to do this. To fix this problem you have to raise your permissions or enable Developer Mode, which available since Windows 10. Additional explanation when build fails will allow developer to fix the problem on his computer faster.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1386
Signed-off-by Mateusz Krawczuk <[email protected]>v2:
Removed unnecessary newlines to be consistent with QEMU coding styles.
I don't think you actually did this, but it's maybe fine. If you wanted to be careful about it, you could use pylint and flake8 to check the formatting of this script, though it isn't perfect to start:
jsnow@scv ~/s/q/scripts (python-socket-connect)> pylint symlink-install-tree.py ************* Module symlink-install-tree symlink-install-tree.py:1:0: C0114: Missing module docstring (missing-module-docstring)
symlink-install-tree.py:1:0: C0103: Module name "symlink-install-tree" doesn't conform to snake_case naming style (invalid-name) symlink-install-tree.py:10:0: C0116: Missing function or method docstring (missing-function-docstring) symlink-install-tree.py:10:17: C0103: Argument name "d1" doesn't conform to snake_case naming style (invalid-name) symlink-install-tree.py:10:26: C0103: Argument name "d2" doesn't conform to snake_case naming style (invalid-name) symlink-install-tree.py:29:11: W0703: Catching too general exception BaseException (broad-except)
symlink-install-tree.py:30:41: E1101: Instance of 'BaseException' has no 'errno' member (no-member)
jsnow@scv ~/s/q/scripts (python-socket-connect) [22]> flake8 symlink-install-tree.py
symlink-install-tree.py:10:1: E302 expected 2 blank lines, found 1 symlink-install-tree.py:16:1: E305 expected 2 blank lines after class or function definition, found 1
jsnow@scv ~/s/q/scripts (python-socket-connect) [1]> isort -c symlink-install-tree.py
ERROR: /home/jsnow/src/qemu/scripts/symlink-install-tree.py Imports are incorrectly sorted and/or formatted.
As long as you don't make the spacing *worse*, it's fine - but any fixes to existing code should go in its own patch.
Quoted 25 lines
Signed-off-by Mateusz Krawczuk <[email protected]>--- scripts/symlink-install-tree.py | 5 +++++ 1 file changed, 5 insertions(+)scripts/symlink-install-tree.py +2
-0@@ -7,12 +7,14 @@ import subprocess import sys + def destdir_join(d1: str, d2: str) -> str: if not d1: return d2 # c:\destdir + c:\prefix must produce c:\destdir\prefix return str(PurePath(d1, *PurePath(d2).parts[1:])) + introspect = os.environ.get('MESONINTROSPECT') out = subprocess.run([*introspect.split(' '), '--installed'], stdout=subprocess.PIPE, check=True).stdout
scripts/symlink-install-tree.py def destdir_join(d1: str, d2: str) -> str: · line 35
Quoted 6 lines
scripts/symlink-install-tree.py +3
-0@@ -28,5 +30,8 @@ def destdir_join(d1: str, d2: str) -> str: os.symlink(source, bundle_dest) except BaseException as e: if not isinstance(e, OSError) or e.errno != errno.EEXIST: + if os.name == 'nt': + print('Please enable Developer Mode to support soft link ' + 'without Administrator permission')
Use file=sys.stderr here, too, though. If you resubmitted a patch that omitted all whitespace changes and fixed this part, I think that'd be sufficient. Thanks for the patch!
--js
Quoted 5 lines
scripts/symlink-install-tree.py +0
-1print(f'error making symbolic link {dest}', file=sys.stderr) raise e --2.40.1
05.05.2023 00:11, Mateusz Krawczuk wrote:
..
scripts/symlink-install-tree.py def destdir_join(d1: str, d2: str) -> str: · line 37
Quoted 7 lines
except BaseException as e:
if notisinstance(e, OSError)or e.errno != errno.EEXIST:scripts/symlink-install-tree.py +3
-0+ if os.name == 'nt': + print('Please enable Developer Mode to support soft link ' + 'without Administrator permission') print(f'error making symbolic link {dest}', file=sys.stderr) raise e
FWIW, can't we get rid of symlinks entirely? It smells like this should be possible with meson.
/mjt