go-python / go-python/gopy

Build Dummy Example Failed in MacOS M1

オープン
#318 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Go
スター
2.3k
フォーク
136
平均マージ
14分
マージ済み PR(30日)
2

説明

## ENV
MacOS 2020 M1 chip

python3.9 (system)

## Replication
```shell
# prepare
mkdir dummy && cd dummy
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
go env -w GOBIN="/usr/local/go/bin/"

# init project and install as python package
go mod init dummy.com/dum
go get github.com/go-python/gopy/_examples/hi

# error happened here
gopy build -output=out -vm=python3 github.com/go-python/gopy/_examples/hi
```
Output:
```
--- Processing package: github.com/go-python/gopy/_examples/hi ---

--- building package ---
gopy build -output=out -vm=python3 github.com/go-python/gopy/_examples/hi
goimports -w hi.go
go build -mod=mod -buildmode=c-shared -o hi_go.so .
cmd had error: exit status 1 output:
# dummy.com/dum/out
/usr/local/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib'
ld: library not found for -lpython3.9
clang: error: linker command failed with exit code 1 (use -v to see invocation)

2023/03/19 13:35:14 error dispatching command: exit status 1
```

## Questions
The path `/App****/Python3.framework/Versions/3.9/lib` actually doesn't exist in my PC, so I think maybe it's because somewhere point to a wrong $PATH.

I found where the true python lib path is, and added it to $PATH, since this error seems due to lib not in the path:
```shell
sudo find /Library -name "python*"

# so here I got the python3 lib path in my PC
export PATH=/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib:$PATH

# re-run
gopy build -output=out -vm=python3 github.com/go-python/gopy/_examples/hi

# still the error output
--- Processing package: github.com/go-python/gopy/_examples/hi ---

--- building package ---
gopy build -output=out -vm=python3 github.com/go-python/gopy/_examples/hi
goimports -w hi.go
go build -mod=mod -buildmode=c-shared -o hi_go.so .
cmd had error: exit status 1 output:
# dummy.com/dum/out
/usr/local/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib'
ld: library not found for -lpython3.9
clang: error: linker command failed with exit code 1 (use -v to see invocation)

2023/03/19 13:49:54 error dispatching command: exit status 1
```

Am I doing any step wrong? could you give me some advice, thanks! 😊

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

github.com/go-python/gopy/_examples/hi に対する gopy build コマンドと、レポートに示されている Go の共有ライブラリのリンク手順から始めてください。macOS arm64 の Python framework/library パスがどのように選択されるかを追跡し、Python 3.9 で失敗を再現してください。例が -lpython3.9 が見つからないエラーなしでビルドできれば、作業完了とします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
go, macos, python
領域
build-system, devtools, operating-systems
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。