wingtk / gvsbuild

GTK stack for Windows
GNU General Public License v2.0
432 stars 163 forks source link

Error on "gvsbuild build pygobject" #1081

Open codeXiaoMing opened 11 months ago

codeXiaoMing commented 11 months ago

When running "gvsbuild build --enable-gi --py-wheel gobject-introspection gtk4 libadwaita gtksourceview5 pygobject pycairo adwaita-icon-theme hicolor-icon-theme" the following error occurs:

https://pastebin.com/9GJ3Y57T

My development environment: windows10 choco 2.2.2 git 2.42.0 graphviz 9.0.0 msys2 20230718.0.0 visualstudio2022buildtools 117.7.4 visualstudio2022-workload-vctools 1.0.0 visualstudio-installer 2.0.03 python 3.11.5 pipx 1.2.0 gvsbuild 2023.9.0 poetry 1.6.1

danyeaw commented 11 months ago

Hi @codeXiaoMing, this looks like the same issue as in https://github.com/wingtk/gvsbuild/issues/877. Is your language set to Chinese as well?

codeXiaoMing commented 11 months ago

Yes, my language is set to Chinese

danyeaw commented 11 months ago

Would it be possible to set your language to English to help isolate this to some type of unicode error?

codeXiaoMing commented 11 months ago

I have tried using VMware to create an English version of Windows and successfully configured the development environment. But I don't think this is a good choice, I will try this method https://www.cnblogs.com/Steven-HU/p/14547749.html

danyeaw commented 11 months ago

Was that method to change the system locale?

codeXiaoMing commented 11 months ago

yes, It also mentions that there are several other ways to solve this problem:

  1. Modify the project file or source file, and disable the C4819 warning
  2. Modify the file content to avoid using illegal characters
  3. Save the file in Unicode format again
danyeaw commented 11 months ago

Hey @codeXiaoMing, I don't think this is specific to Gvsbuild, GLib (which was the code that PyGObject was building against when the error occurred) has some guidance which is to set the non-unicode language to English: https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/win32-build.md#c4819-build-errors

It does give a 2nd option to use the /UTF-8 flag with MSVC, but it doesn't sound like that is always effective.

codeXiaoMing commented 11 months ago

@danyeaw you are right. The method you mentioned is what I mentioned earlier. I have successfully installed pygobject using this method

codeXiaoMing commented 11 months ago

I have already configured the environment according to the official installation process and successfully ran gaphors using “poetry run gaphor”, but an error occurred during the second run

PS D:\project\MBSE-tool-develop\gaphor-main> poetry run gaphor No translations were found for language zh_CN: [Errno 2] No translation file found for domain: 'gaphor' Traceback (most recent call last): File "", line 1, in File "D:\project\MBSE-tool-develop\gaphor-main\gaphor\main.py", line 21, in main commands: dict[str, argparse.ArgumentParser] = initialize("gaphor.argparsers") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\project\MBSE-tool-develop\gaphor-main\gaphor\entrypoint.py", line 13, in initialize return init_entry_points(load_entry_points(scope, services), **known_services) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\project\MBSE-tool-develop\gaphor-main\gaphor\entrypoint.py", line 29, in load_entry_points cls = ep.load() ^^^^^^^^^ File "D:\python\Lib\importlib\metadata__init__.py", line 202, in load module = import_module(match.group('module')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\Lib\importlib__init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1126, in _find_and_load_unlocked File "", line 241, in _call_with_frames_removed File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "D:\project\MBSE-tool-develop\gaphor-main\gaphor\plugins\diagramexport\init.py", line 8, in from gaphor.diagram.export import ( File "D:\project\MBSE-tool-develop\gaphor-main\gaphor\diagram\init.py", line 5, in import gi File "D:\project\MBSE-tool-develop\gaphor-main.venv\Lib\site-packages\gi\init__.py", line 47, in from . import _gi ImportError: DLL load failed while importing _gi

danyeaw commented 11 months ago

It looks like it can't find PyGObject to import any longer. Do you still have your environmental variables set?

$env:Path = "C:\gtk-build\gtk\x64\release\bin;" + $env:Path
$env:LIB = "C:\gtk-build\gtk\x64\release\lib;" + $env:LIB
$env:INCLUDE = "C:\gtk-build\gtk\x64\release\include;C:\gtk-build\gtk\x64\release\include\cairo;C:\gtk-build\gtk\x64\release\include\glib-2.0;C:\gtk-build\gtk\x64\release\include\gobject-introspection-1.0;C:\gtk-build\gtk\x64\release\lib\glib-2.0\include;" + $env:INCLUDE

For the C4819 errors, do you think we should add that to the Gvsbuild README? Are you interested in making a pull request?

codeXiaoMing commented 11 months ago

After resetting these environment variables, there was no problem. thank you. I think it is necessary to add the C4819 errors to Gvsbuild README. My recent plan is to develop some customized content based on gaphor, and then I can organize the process for solving the C4819 error and make a pull request

codeXiaoMing commented 11 months ago

I encountered an error while attempting to package when running this command:poetry run poe win-installer

D:\project\MBSE-tool-develop\gaphor-2.20.0>poetry run poe win-installer Poe => win-installer Cleaning files Building Installer Traceback (most recent call last): File "", line 1, in File "D:\project\MBSE-tool-develop\gaphor-2.20.0_packaging\windows\build-win-installer.py", line 107, in main build_installer(icon, nsi, gaphor_files, installer) File "D:\project\MBSE-tool-develop\gaphor-2.20.0_packaging\windows\build-win-installer.py", line 28, in build_installer subprocess.run( File "D:\python\Lib\subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\Lib\subprocess.py", line 1026, in init self._execute_child(args, executable, preexec_fn, close_fds, File "D:\python\Lib\subprocess.py", line 1538, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [WinError 2] 系统找不到指定的文件。

danyeaw commented 11 months ago

@codeXiaoMing Ok, I'll leave this open until we update the docs.

Let's move Gaphor support to that project :+1: