Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any plans for a Windows build of pygobject #8

Closed
tjwilli58 opened this issue Jun 9, 2018 · 25 comments
Closed

any plans for a Windows build of pygobject #8

tjwilli58 opened this issue Jun 9, 2018 · 25 comments
Assignees

Comments

@tjwilli58
Copy link

tjwilli58 commented Jun 9, 2018

Issue: Windows build
Just wondering if there are any plans of creating a build for Windows of pygobject. From its webpage, I see that it can be built with msys2, but is it possible to get that module installed under an anaconda python?

I haven't done this myself, but if you could give my some pointers, I'd be willing to give it a try.
I have msys2 installed. I also have VS2017 (Community), but I'm not very proficient in that either.

Thanks.


Environment (conda list):
$ conda list


Details about conda and system ( conda info ):
$ conda info

@pkgw
Copy link
Contributor

pkgw commented Jun 9, 2018

I'm not aware of any plans, but work to add Windows support would definitely be welcomed!

Before this package can be built on Windows, its dependencies will need to be built on Windows. From what I see, glib, libffi, and gobject-introspection don't have Windows builds yet.

To add Windows support, I've found that the best route is to start by emulating another package that already has Windows support. To choose one pretty much arbitrarily, cairo gets built on Windows — and its key files are meta.yaml and bld.bat. Because these packages are aimed at Unix-like systems, it can definitely be a pain to get things working, but that would be where to start.

@tjwilli58
Copy link
Author

tjwilli58 commented Jun 10, 2018

I see that m2-glib2 and m2-libffi exist in pkgs/msys2. Can these be used?
I'll see what I can do about gobject-introspection, although I'm not sure how much time I can find to work on this. I really want to get pygobject built on Windows with Python > 3.4. I have a program that needs this and gstreamer (which I'm just finding out now is also not on conda) by the Windows installer found here is stuck at Python3.4.

Pygobject and gstreamer are both available on msys2, but I'd like to get this on my conda environment also.

@pkgw
Copy link
Contributor

pkgw commented Jun 10, 2018

Oh, hm. It's certainly worth giving the m2- versions of those dependencies a try. As I understand it, the goal is to eventually build all of those kinds of packages within the conda-forge framework, but there's nothing wrong with being expedient to meet user needs.

One thing to keep an eye out for is if the versions provided by the m2- packages are pretty close to the ones used in conda-forge. If they're a lot older, there might be problems providing a single version that's compatible across all of the platforms.

@tjwilli58
Copy link
Author

Well I cloned the cairo-feedstock and did a conda-build of it with no problems, so I then cloned the glib, libffi,, and gobject-introspection feedstocks. Of course, none of these worked for me. I looked at some of the differences in each meta.yaml file and tried a few things like copying some of the requirements build lines from the cairo meta.yaml file to the others, but no such luck. I think I need to read over and understand how to build the GTK+ stack using Microsoft Visual Studio and how to build GTK+ with MSVC on Windows.

@tjwilli58
Copy link
Author

Update:
Trying to build GTK using wingtk/gvsbuild. This system also uses MSYS2, so I'm not sure if I can apply lessons learned to getting pygobject built on conda-forge anyway.

No success yet. I did get libffi, glib projects here built, but I can't get past atk, which I think is needed gobject-introspection.

@pkgw
Copy link
Contributor

pkgw commented Jun 19, 2018

You may have already noticed this, but there is already a conda-forge atk feedstock that is currently disabled on Windows.

Also as things get closer, there has been effort to include gtk in conda-forge, but we have gotten stuck trying to decide how to deal with the two major versions of the toolkit.

@tjwilli58
Copy link
Author

No I didn't know. Thanks.

@tjwilli58
Copy link
Author

tjwilli58 commented Aug 11, 2018

Followup:

Working on modifying glib-feedstock and gobject-introspection-feedstock for WIndows. I have a PR in for glib-feedstock and am ready to submit PR for gobject-introspection-feedstock.
With those two built locally, I'm trying to get pygobject-feedstock to build, but currently having problems because the setup.py build for pygobject is trying to use VS2015 as the compiler and MSVC is not supported

        def build_ext(ext):
            if compiler.compiler_type == "msvc":
                raise Exception("MSVC support not implemented")


Haven't figured out a way around this yet. (Also getting errors about glib-object.h not being found.)

@tjwilli58
Copy link
Author

tjwilli58 commented Dec 26, 2018

@pkgw , I just started looking over this issue again to see if I could make some progress while I'm taking a few days off over the holidays. I see that you got glib-feedstock built for Windows. Thanks so much! I did eventually get atk built with wingtk/gvsbuild with miniconda (not Anaconda - go figure), so maybe I can look into that.

@tjwilli58
Copy link
Author

Ok, so I got atk to build with wingtk/gvsbuild by uninstalling libiconv. I also see that libiconv is also an issue in building glib according to what I can see from @pkgw 's recipe .

I really don't understand this enough to be able to contribute.

@pkgw
Copy link
Contributor

pkgw commented Dec 27, 2018

Thanks for pushing on this @tjwilli58 !

It looks like there may be some good news here. Newer versions of pygobject seem to have started using the Meson build system, which is a lot more cross-platform-friendly than the old one. If we start packaging the 3.30.x series and switch to Meson, adding in Windows support may be relatively easy. If I can find the time, I'll see if I can play around with this a bit.

@pkgw
Copy link
Contributor

pkgw commented Dec 27, 2018

OK, but we still need to have gobject-introspection on Windows before this package can be built.

@tjwilli58
Copy link
Author

tjwilli58 commented Dec 28, 2018

That would be great. I've forked gobject-introspection also, but I haven't successfully built that either. I've read over the docs on building packages, but it's very confusing and complicated to me. I just found this issue today about Compiler support for MSVC 2017 #2541, while I was uninstalling VS2017 and installing VS2015 to see if that was my problem. (Didn't get very far on that either - I'm reinstalling VS2017 now.)

We have an application that uses pygobject and gstreamer at work, and we currently use PyGobject for Windows, but this has been stuck at python 3.4. In addition to wanting to update to python3.6+, I'd also like to get this in a conda environment.

I've found that I can use msys2 to do this, but it would be nice to not have to multiple environments for everything. One more system to get approval from out IT people.

@pkgw
Copy link
Contributor

pkgw commented Dec 28, 2018

Some notes-to-self:

  • to get this working, we need gobject-introspection
  • the fastest path to that seems to be to upgrade g-i to version 1.58, which provides Meson build files
  • g-i 1.58 requires glib 2.58, which must be built with Meson.
  • Once glib 2.58 is available, Cairo will need to be updated since g-i depends on it and it depends on glib

@pkgw
Copy link
Contributor

pkgw commented Dec 29, 2018

I think I have this working! It will take some time for all of the pieces to fall into place, though, due to fun with issues such as conda-forge/glib-feedstock#40.

@tjwilli58
Copy link
Author

This is great! I started trying to build gobject-introspection by looking at your meta.yml file from glib-feedstock and copying the bld.bat from there. I modified it with some guessing, and got it partially built, but the binaries weren't built.
Here's the diff (from git-gui):

@@ -1,10 +1,12 @@
 {% set name = "gobject-introspection" %}
-{% set major = "1.56" %}
-{% set patch = "1" %}
+{% set major = "1.58" %}
+{% set patch = "2" %}
 {% set version = major ~ "." ~ patch %}
-{% set sha256 = "5b2875ccff99ff7baab63a34b67f8c920def240e178ff50add809e267d9ea24b" %}
+{% set sha256 = "2a5e0f69459af7ca4c41b8f4e19d9c80ddf877834bb0e7fdd420e2495ae2eda8" %}
+{% set posix = 'm2-' if win else '' %}
+{% set native = 'm2w64-' if win else '' %}
 
 package:
   name: {{ name|lower }}
   version: {{ version }}
 
@@ -16,20 +18,28 @@ source:
     - gcc7-rpath-link.patch  # [linux]
 
 build:
   number: 1001
   detect_binary_files_with_prefix: true
-  skip: true  # [win]
+  skip: true  # [not py36]
 
 requirements:
   build:
-    - pkg-config  # [not win]
+    - {{posix}}patch  # [win]
+    - ninja
+    - {{native}}pkg-config
     - {{ compiler('c') }}
+    - {{posix}}flex
+    - {{posix}}bison
   host:
-    - bison
+    # The meson version pin is to avoid a buggy package; see
+    # meson-feedstock issue #11.
+    - meson <0.48  # [win]
+    - meson        # [not win]
+    - {{posix}}bison
     - cairo
-    - flex
+    - {{posix}}flex
     - gettext  # [osx]
     - glib
     - libffi
     - python
   run:


@pkgw
Copy link
Contributor

pkgw commented Dec 29, 2018

@tjwilli58 Thanks! That's a good start, although what happens nearly every time is that there's some subtle problem that needs working around. I've got a version of g-i that seems to work, so this isn't something you need to spend time on unless it's an area that you're actively interested in learning about how to do all this stuff. There is a lot of hard-won nitty-gritty knowledge that comes up as soon as anything goes wrong.

@tjwilli58
Copy link
Author

@pkgw I am interested in learning this, but it does seem to be a bit of "black box/magic" to it. I'd like to be able to contribute, but finding the time and getting the right knowledge is a bit of a steep climb for me.

(@joshdoe, I'm tagging you as an FYI that progress is being made on getting pygobject built for Windows on conda-forge. We still need gstreamer!)

@pkgw pkgw self-assigned this Dec 29, 2018
@pkgw
Copy link
Contributor

pkgw commented Dec 29, 2018

Current status: this is blocked on getting a new gobject-introspection published. I believe we need a new version of meson — macOS builds of the new introspection module are currently failing and I have traced the problem to mesonbuild/meson#4117, which was fixed in mesonbuild/meson#4187, which has not yet made it into a Meson release.

duncanmmacleod pushed a commit to duncanmmacleod/pygobject-feedstock that referenced this issue Jan 22, 2019
Fix g-ir-scanner linking on GCC7 with dependent libraries
@pkgw pkgw closed this as completed in #13 Jan 30, 2019
@tjwilli58
Copy link
Author

Woohoo! Thanks so much!

@cmichal2
Copy link

I'm delighted to think that pygtk will be usable in anacoda - thanks!

I feel like I'm missing something though. I installed pygobject with:
conda install -c conda-forge pygobject (on a windows-64 bit system).

But then when I try to use it:

>>> import gi
Traceback (most recent call last):
 File "<stdin>", line 1 in <module>
 File "C:\Users\default\Anaconda3\lib\site-packages\gi\__init__.py", line 42, in <module>
    from . import _gi
ImportError: DLL load failed: The specified procedure could not be found.

Am I missing something obvious?

@pkgw
Copy link
Contributor

pkgw commented Feb 11, 2019

@cmichal2 I'm 99% sure that the command you tried should work, but just to check, does the following fare any better?

from gi.repository import GLib

The import command that you tried is tested during the package verification process, so I am not sure how to figure out why it doesn't work on your system :-/

For what it's worth, please be aware that while Python/GObject interaction should now be available on Windows, PyGtk is not, as per this comment I made on another issue.

@cmichal2
Copy link

importing GLib as you suggest fails with same error message.

Thanks for the pointer to the earlier gtk comment. That's too bad - I'd love to see an easy-to-install way to get pygtk running on windows (for teaching purposes).

@tjwilli58
Copy link
Author

tjwilli58 commented Feb 11, 2019

@cmichal2 ,
If you're willing to be stuck at Python 3.4, you can try
PyGObject for Windows

It looks like some work is being done on ticket #50, but it's not there yet.

This is my primary reason for wanting pygobject built on conda for WIndows. Still needed is gstreamer-feedstock building on Windows.

Have you thought about using pyqt instead of pygtk?

@shawn-peng
Copy link

shawn-peng commented Feb 21, 2019

I got the same DLL loading error as @cmichal2 . Any idea what the reason might be? I have VS2017, msys2 and cygwin installed. Do they have influences?

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

No branches or pull requests

4 participants