Giter VIP home page Giter VIP logo

Comments (6)

hush-hush avatar hush-hush commented on July 30, 2024

Hi @BenDerPan,

The bindings should work on Windows (I haven't tried), nothing is Linux specific.
Are you sure your setup for pkg-config is working ? Does this command works on you build environment pkg-config --cflags python3 ?

from go-python3.

MarSoft avatar MarSoft commented on July 30, 2024

There is a problem though.

Probably we can somehow build some parts using MSVC and other parts using migw32-w64, but I am not sure how can this be achieved.

In fact, the issue I bumped into when first tried to build with mingw-w64: Python.h header requires crypt.h, which is missing in mingw headers.

There is a mingwpy project there which aims to support building python modules with mingw, but it is seemingly dead and doesn't mention any support for python>3.5.

from go-python3.

Zalberth avatar Zalberth commented on July 30, 2024

Same issure on MacOS by using go get -u github.com/DataDog/go-python3. Python3 already installed by pkg.

from go-python3.

christian-korneck avatar christian-korneck commented on July 30, 2024

first of all thanks a lot for this great project 🙏

can this work on windows

this go module works fine for me so far on Windows 10. However, I don't use mingw. This is what I do for Python 3.7 x64:

  • go to the Python 3.7.7 downloads page and download the Windows x86-64 embeddable zip file (direct link) and extract it to i.e. c:\dist (this will become the build output dir for your app and you will need to bundle these files with your app)
  • obtain the include dir from a regular Python 3.7.7 x64 installation (direct link regular installer) and put it somewhere (i.e. to c:\py\include)
  • install TDM GCC (i.e. to c:\tdm-gcc)
  • install pkgconfig (easiest way I find is with the chocolatey package manager: choco install pkgconfiglite)
  • in your project, create a pkg-config\python3.pc file with these paths
prefix=C:/dist
exec_prefix=${prefix}
libdir=${exec_prefix}
includedir=C:/py/include

Name: Python
Description: Python library embedded
Requires:
Version: 3.7
Libs: -L${libdir} -lpython37 -lpthread -lm
Cflags: -I${includedir} -DMS_WIN64

in a cmd shell navigate to your project root and set the environment:

set PATH=c:\dist;c:\tdm-gcc\bin;%PATH%
set PKG_CONFIG_PATH=%cd%\pkg-config

now we can build our app:

go build -o c:\dist

and run it (should work from any shell, i.e. the above env vars don't need to be set for running):

c:\dist\myapp.exe

One more note: If you accidentally compile against the wrong Python binaries the go build cache can be "dirty" (happened to me a couple of times). In that case rename/delete the folder that go env GOCACHE shows.

from go-python3.

equisde avatar equisde commented on July 30, 2024

first of all thanks a lot for this great project 🙏

can this work on windows

this go module works fine for me so far on Windows 10. However, I don't use mingw. This is what I do for Python 3.7 x64:

  • go to the Python 3.7.7 downloads page and download the Windows x86-64 embeddable zip file (direct link) and extract it to i.e. c:\dist (this will become the build output dir for your app and you will need to bundle these files with your app)
  • obtain the include dir from a regular Python 3.7.7 x64 installation (direct link regular installer) and put it somewhere (i.e. to c:\py\include)
  • install TDM GCC (i.e. to c:\tdm-gcc)
  • install pkgconfig (easiest way I find is with the chocolatey package manager: choco install pkgconfiglite)
  • in your project, create a pkg-config\python3.pc file with these paths
prefix=C:/dist
exec_prefix=${prefix}
libdir=${exec_prefix}
includedir=C:/py/include

Name: Python
Description: Python library embedded
Requires:
Version: 3.7
Libs: -L${libdir} -lpython37 -lpthread -lm
Cflags: -I${includedir} -DMS_WIN64

in a cmd shell navigate to your project root and set the environment:

set PATH=c:\dist;c:\tdm-gcc\bin;%PATH%
set PKG_CONFIG_PATH=%cd%\pkg-config

now we can build our app:

go build -o c:\dist

and run it (should work from any shell, i.e. the above env vars don't need to be set for running):

c:\dist\myapp.exe

One more note: If you accidentally compile against the wrong Python binaries the go build cache can be "dirty" (happened to me a couple of times). In that case rename/delete the folder that go env GOCACHE shows.

hello i'm new to golang i tried to use your instruction i was able to go get the package and compile but when running i get this

Exception 0xc0000005 0x0 0x10 0x7ffe1214f90d
PC=0x7ffe1214f90d

runtime: unknown pc 0x7ffe1214f90d
stack: frame={sp:0xdcd63ffaa0, fp:0x0} stack=[0x0,0xdcd63ffbe0)
000000dcd63ff9a0:  0000000000000008  00007ffe121691bb
000000dcd63ff9b0:  0000024540f90030  00007ffe1230a238
000000dcd63ff9c0:  0000000000000000  0000000000000000
000000dcd63ff9d0:  0000000000000004  0000000000000000
000000dcd63ff9e0:  0000000000000010  0000000000000000
000000dcd63ff9f0:  0000000000000001  0000000000000000
000000dcd63ffa00:  000002451bb20000  00007ffe6a7090cc
000000dcd63ffa10:  0000000000000000  0000024540f90060
000000dcd63ffa20:  0000007f00000001  0000000000000008
000000dcd63ffa30:  0000000000000008  0000000000000008
000000dcd63ffa40:  000000000000007f  0000000000000000
000000dcd63ffa50:  0000000000000000  00007ffe1230a240
000000dcd63ffa60:  00007ffe68ad0000  0000000000000000
000000dcd63ffa70:  000000000000000b  0000000000000001
000000dcd63ffa80:  0000000000000000  000002451bb26cf0
000000dcd63ffa90:  0000000000000000  ffffffffffffffff
000000dcd63ffaa0: <0000000000000025  00007ff7cc9174b8
000000dcd63ffab0:  00007ff7cc8fb920  00007ff7cc9911e0
000000dcd63ffac0:  0000024540f90030  00007ffe12189fd0
000000dcd63ffad0:  00007ffe1230a240  00007ffe1230a238
000000dcd63ffae0:  0000000000000000  0000000000000000
000000dcd63ffaf0:  000002451bb26cf0  00007ffe12175710
000000dcd63ffb00:  0000000000000000  00007ffe68c0c750
000000dcd63ffb10:  0000000000000000  0000000000000004
000000dcd63ffb20:  0000024540f518b8  0000000000000000
000000dcd63ffb30:  000000c000110000  00007ff7cc8c5caf
000000dcd63ffb40:  000000c00010ff20  0000000000000004
000000dcd63ffb50:  00007ff7cc86e4cd <runtime.wakep+109>  0000024540f518c8
000000dcd63ffb60:  000000c00010ff20  00007ff7cc9911e0
000000dcd63ffb70:  000000c00010ff20  00007ff7cc896753 <runtime.asmcgocall+115>
000000dcd63ffb80:  00007ff7cc9174f8  0000000000000010
000000dcd63ffb90:  00007ff7cc8f9b80  00007ff7cc8f9b80
runtime: unknown pc 0x7ffe1214f90d
stack: frame={sp:0xdcd63ffaa0, fp:0x0} stack=[0x0,0xdcd63ffbe0)
000000dcd63ff9a0:  0000000000000008  00007ffe121691bb
000000dcd63ff9b0:  0000024540f90030  00007ffe1230a238
000000dcd63ff9c0:  0000000000000000  0000000000000000
000000dcd63ff9d0:  0000000000000004  0000000000000000
000000dcd63ff9e0:  0000000000000010  0000000000000000
000000dcd63ff9f0:  0000000000000001  0000000000000000
000000dcd63ffa00:  000002451bb20000  00007ffe6a7090cc
000000dcd63ffa10:  0000000000000000  0000024540f90060
000000dcd63ffa20:  0000007f00000001  0000000000000008
000000dcd63ffa30:  0000000000000008  0000000000000008
000000dcd63ffa40:  000000000000007f  0000000000000000
000000dcd63ffa50:  0000000000000000  00007ffe1230a240
000000dcd63ffa60:  00007ffe68ad0000  0000000000000000
000000dcd63ffa70:  000000000000000b  0000000000000001
000000dcd63ffa80:  0000000000000000  000002451bb26cf0
000000dcd63ffa90:  0000000000000000  ffffffffffffffff
000000dcd63ffaa0: <0000000000000025  00007ff7cc9174b8
000000dcd63ffab0:  00007ff7cc8fb920  00007ff7cc9911e0
000000dcd63ffac0:  0000024540f90030  00007ffe12189fd0
000000dcd63ffad0:  00007ffe1230a240  00007ffe1230a238
000000dcd63ffae0:  0000000000000000  0000000000000000
000000dcd63ffaf0:  000002451bb26cf0  00007ffe12175710
000000dcd63ffb00:  0000000000000000  00007ffe68c0c750
000000dcd63ffb10:  0000000000000000  0000000000000004
000000dcd63ffb20:  0000024540f518b8  0000000000000000
000000dcd63ffb30:  000000c000110000  00007ff7cc8c5caf
000000dcd63ffb40:  000000c00010ff20  0000000000000004
000000dcd63ffb50:  00007ff7cc86e4cd <runtime.wakep+109>  0000024540f518c8
000000dcd63ffb60:  000000c00010ff20  00007ff7cc9911e0
000000dcd63ffb70:  000000c00010ff20  00007ff7cc896753 <runtime.asmcgocall+115>
000000dcd63ffb80:  00007ff7cc9174f8  0000000000000010
000000dcd63ffb90:  00007ff7cc8f9b80  00007ff7cc8f9b80

goroutine 1 [syscall]:
github.com/DataDog/go-python3._Cfunc_PyRun_SimpleStringFlags(0x2451bb26cf0, 0x0, 0x24500000000)
        _cgo_gotypes.go:4695 +0x4b
github.com/DataDog/go-python3.PyRun_SimpleString(0x7ff7cc90e71e, 0x3, 0x0)
        C:/Users/rbert/go/pkg/mod/github.com/!data!dog/[email protected]/high_level_layer.go:66 +0x93
main.main()
        D:/!-criss/main.go:9 +0x3d
rax     0x0
rbx     0x24540f90030
rcx     0xdcd63ffa10
rdi     0x2451bb26cf0
rsi     0x7ff7cc9911e0
rbp     0xc00010fee0
rsp     0xdcd63ffaa0
r8      0x24540f90060
r9      0x24540f90000
r10     0xfc0
r11     0x246
r12     0x7ff7cc8fb920
r13     0x7ff7cc9174b8
r14     0x25
r15     0xffffffffffffffff
rip     0x7ffe1214f90d
rflags  0x10206
cs      0x33
fs      0x53
gs      0x2b

from go-python3.

christian-korneck avatar christian-korneck commented on July 30, 2024

i was able to go get the package and compile but when running i get this

@equisde I don't know what's the problem you're seeing, but I've just created a quick github actions demo project that builds a simple Windows executable with go-python3. If you like you can fork it, run it on your github account and compare it with your setup. Hope this helps.

from go-python3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.