GNOME Bugzilla – Bug 757126
Make scripts in giscanner/ work for Python 2.x and Python 3.x in Visual Studio builds too
Last modified: 2016-02-19 06:08:08 UTC
Hi, This is meant to continue the work in 679438 to make the introspection Python scripts work for Visual Studio builds, especially as better Visual Studio support came after Simon's work in bug 679438. I will post my progress here... With blessings, thank you!
Created attachment 314287 [details] [review] g-ir-tool-template.in: Re-enable 'relocatability' on Windows Hi, First up is to make the template tool script work again on Windows with its 'relocatable' feature re-enabled, as the move to Python 3 compatibility removed this by accident...
Created attachment 314289 [details] [review] msvccompiler.py: Make preprocessing work on Python 3.x Hi, This updates msvccompiler.py to make it work with Python 3.x, specifically the preprocessing part, when handling exceptions from distutils...
Created attachment 314290 [details] [review] ccompiler.py: Fix lib resolution on Windows for Python 3.x Hi, This updates ccompiler.py where we look into the lib file(s) fed into g-ir-scanner to deduce the correct DLL that would be used by the generated .gir/.typelib files...
Created attachment 314291 [details] [review] dumper.py: Fix ignore-of-embedding-manifest-errors for Python 3.x Hi, This makes the call to sys.exc_clear() only done on Python 2.x as it is only needed (and available) on Python 2.x...
Created attachment 314292 [details] [review] transformer.py: Fix --identifier-filter on Python 3.x Hi, This is probably more of an all-platforms fix, where the case where a identifier filter script is used... This is what I have now to fix the introspection scripts on Windows, in particular the Visual Studio builds. With blessings, thank you!
Review of attachment 314287 [details] [review]: Sure.
Review of attachment 314289 [details] [review]: Okay.
Review of attachment 314290 [details] [review]: Okay.
Review of attachment 314291 [details] [review]: Okay.
Review of attachment 314292 [details] [review]: Okay.
Hi Emmanuele, Thanks for the really quick reviews :) The patches were pushed to master as: Attachment 314287 [details]: 6492ac6 Attachment 314289 [details]: f12d853 Attachment 314290 [details]: ee28491 Attachment 314291 [details]: 3bb86de Attachment 314292 [details]: cb1fabb Closing bug now. With blessings, thank you!
(In reply to Fan, Chun-wei from comment #1) > Created attachment 314287 [details] [review] [review] > g-ir-tool-template.in: Re-enable 'relocatability' on Windows > > First up is to make the template tool script work again on Windows with its > 'relocatable' feature re-enabled, as the move to Python 3 compatibility > removed this by accident... Have you considered using setuptools for installation of the Python modules? By setuptools conventions, the binaries are generated by setup.py, so you can't bake configurable values as globals into the binaries. Instead, these can be put into the package metadata by setup.py, which in turn can be created as part of AC_CONFIG_FILES by configure. On the upside, setuptools take care of the platform variation, so you can get rid of the "if os.name == 'nt'" spaghetti. Installing the modules into standard Python locations will effectively make them public and reusable: https://bugzilla.gnome.org/show_bug.cgi?id=755385 FYI, I have forked a part of the giscanner modules into a larger project which is installed by setuptools: https://github.com/gi-rust/grust-gen/tree/master/grust/gi I didn't go for the metadata approach discussed above, instead I just stopped using the configured DATADIR as it is not needed for that project. Still, the template directory is resolved relatively to the package using the pkg_resources API, which could also be used to get at configure-time package artefacts: https://github.com/gi-rust/grust-gen/blob/master/grust/genmain.py#L76
Hi Mikhail, I think that suggestion might[1] be good in the long run, but since this bug is more on making the giscanner scripts work for Visual Studio builds (and at least restoring what used to be able to be done on Windows builds), let's redirect attention for this to your bug report, 755385. The main reason for mentioning this is because the suggestion would be out of scope by quite a bit for this bug report here. Thanks though, with blessings. [1]: This would also involve what the core maintainers of g-i has to say about doing this.
(In reply to Fan, Chun-wei from comment #2) > Created attachment 314289 [details] [review] [review] > msvccompiler.py: Make preprocessing work on Python 3.x > > Hi, > > This updates msvccompiler.py to make it work with Python 3.x, specifically > the preprocessing part, when handling exceptions from distutils... The commit f12d853 introduced an undefined name 'msg' error. You need to use `except ... as ...` statement instead, as shown below: diff --git a/giscanner/msvccompiler.py b/giscanner/msvccompiler.py index d578577..86049da 100644 --- a/giscanner/msvccompiler.py +++ b/giscanner/msvccompiler.py @@ -80,7 +80,7 @@ class MSVCCompiler(distutils.msvccompiler.MSVCCompiler): if self.force or output_file is None or newer(source, output_file): try: self.spawn(cpp_args) - except (DistutilsExecError, msg): + except DistutilsExecError as msg: print(msg) raise CompileError Thanks.
Hi Cosimo, Thanks, the problem was fixed in commit f5cc8f5. With blessings.