pytogo / portforward

Kubernetes Port-Forward Go-Edition For Python
https://portforward.readthedocs.io
MIT License
17 stars 6 forks source link

How to install portforwad for MAC M1 #4

Closed hsalehgh closed 2 years ago

hsalehgh commented 2 years ago

Description

I am tring to install portforward package in my laptop and it shows me run successfully but when I run my python script it gives me the following error:

File "/Users/hsalehghaffari/Library/Python/3.8/lib/python/site-packages/portforward.py", line 12, in <module>
    import _portforward
ImportError: dlopen(/Users/hsalehghaffari/Library/Python/3.8/lib/python/site-packages/_portforward.abi3.so, 0x0002): tried: '/Users/hsalehghaffari/Library/Python/3.8/lib/python/site-packages/_portforward.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
corka149 commented 2 years ago

Hi @hsalehgh

I created a PR which contains installation details. Could you review this PR if it helps?

hsalehgh commented 2 years ago

I still have the issue. In instruction you have mentioned that the architecture is x8464. But M1 Mac architecture is arm64e. It seems that this module is not supporting this architecture. Am I right?

corka149 commented 2 years ago

No, the README states that wheels are only available for x84_64.

I added a new sentence that some things are required when there is no wheel available for the target system.

hsalehgh commented 2 years ago

But when I do pip install portforward still get the same error

corka149 commented 2 years ago

go (go version) and gcc (gcc -v) are which version?

Could you install portforward again with the verbose flag and provide the output? Thx

pip install -v portforward

Unfortunately I do not own a Mac with a M1.

hsalehgh commented 2 years ago

GO: go version go1.17.7 darwin/amd64 GCC: Apple clang version 13.0.0 (clang-1300.0.27.3) Target: arm64-apple-darwin21.5.0

OUTPUT: Using cached portforward-0.2.7.tar.gz (39 kB) Running command python setup.py egg_info running egg_info creating /private/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/pip-pip-egg-info-a5fl9o8y/portforward.egg-info writing /private/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/pip-pip-egg-info-a5fl9o8y/portforward.egg-info/PKG-INFO writing dependency_links to /private/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/pip-pip-egg-info-a5fl9o8y/portforward.egg-info/dependency_links.txt writing top-level names to /private/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/pip-pip-egg-info-a5fl9o8y/portforward.egg-info/top_level.txt writing manifest file '/private/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/pip-pip-egg-info-a5fl9o8y/portforward.egg-info/SOURCES.txt' reading manifest file '/private/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/pip-pip-egg-info-a5fl9o8y/portforward.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files matching '__pycache__' found under directory '*' warning: no previously-included files matching '*.py[co]' found under directory '*' warning: no files found matching '*.jpg' under directory 'docs' writing manifest file '/private/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/pip-pip-egg-info-a5fl9o8y/portforward.egg-info/SOURCES.txt' Preparing metadata (setup.py) ... done Building wheels for collected packages: portforward Running command python setup.py bdist_wheel running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.14.6-arm64-3.8 copying portforward.py -> build/lib.macosx-10.14.6-arm64-3.8 running egg_info writing portforward.egg-info/PKG-INFO writing dependency_links to portforward.egg-info/dependency_links.txt writing top-level names to portforward.egg-info/top_level.txt reading manifest file 'portforward.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files matching '__pycache__' found under directory '*' warning: no previously-included files matching '*.py[co]' found under directory '*' warning: no files found matching '*.jpg' under directory 'docs' writing manifest file 'portforward.egg-info/SOURCES.txt' running build_ext $ GOPATH=/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/tmplb3oy2dh go get -d go: downloading github.com/pytogo/pytogo/portforward v0.0.0-20210905201127-a3c4eb1cd533 go: downloading k8s.io/client-go v0.22.0 go: downloading k8s.io/apimachinery v0.22.0 go: downloading github.com/Azure/go-autorest/autorest/adal v0.9.13 go: downloading github.com/Azure/go-autorest/autorest v0.11.18 go: downloading github.com/Azure/go-autorest v14.2.0+incompatible go: downloading github.com/Azure/go-autorest/autorest/date v0.3.0 go: downloading github.com/Azure/go-autorest/logger v0.2.1 go: downloading github.com/Azure/go-autorest/tracing v0.6.0 go: downloading github.com/form3tech-oss/jwt-go v3.2.3+incompatible go: downloading golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 go: downloading github.com/gogo/protobuf v1.3.2 go: downloading github.com/google/gofuzz v1.1.0 go: downloading gopkg.in/inf.v0 v0.9.1 go: downloading github.com/google/go-cmp v0.5.5 go: downloading k8s.io/klog/v2 v2.9.0 go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.1.2 go: downloading github.com/go-logr/logr v0.4.0 go: downloading golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 go: downloading github.com/json-iterator/go v1.1.11 go: downloading gopkg.in/yaml.v2 v2.4.0 go: downloading k8s.io/api v0.22.0 go: downloading golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d go: downloading github.com/moby/spdystream v0.2.0 go: downloading github.com/imdario/mergo v0.3.5 go: downloading github.com/spf13/pflag v1.0.5 go: downloading golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d go: downloading github.com/golang/protobuf v1.5.2 go: downloading github.com/googleapis/gnostic v0.5.5 go: downloading golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac go: downloading sigs.k8s.io/yaml v1.2.0 go: downloading k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9 go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd go: downloading github.com/modern-go/reflect2 v1.0.1 go: downloading github.com/davecgh/go-spew v1.1.1 go: downloading google.golang.org/protobuf v1.26.0 go: downloading cloud.google.com/go v0.54.0 go: downloading google.golang.org/appengine v1.6.5 go: downloading golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 go: downloading gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b go: downloading golang.org/x/text v0.3.6 $ CGO_CFLAGS='-I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -DPy_LIMITED_API' CGO_LDFLAGS=-Wl,-undefined,dynamic_lookup GOPATH=/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/tmplb3oy2dh go build -buildmode=c-shared -o /private/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/pip-install-jkg11r29/portforward_bad25c210bd14b7f93a3604c530ff0a6/build/lib.macosx-10.14.6-arm64-3.8/_portforward.abi3.so '-ldflags=-s -w' installing to build/bdist.macosx-10.14.6-arm64/wheel running install running install_lib creating build/bdist.macosx-10.14.6-arm64 creating build/bdist.macosx-10.14.6-arm64/wheel copying build/lib.macosx-10.14.6-arm64-3.8/_portforward.abi3.so -> build/bdist.macosx-10.14.6-arm64/wheel copying build/lib.macosx-10.14.6-arm64-3.8/portforward.py -> build/bdist.macosx-10.14.6-arm64/wheel copying build/lib.macosx-10.14.6-arm64-3.8/_portforward.abi3.h -> build/bdist.macosx-10.14.6-arm64/wheel running install_egg_info Copying portforward.egg-info to build/bdist.macosx-10.14.6-arm64/wheel/portforward-0.2.7-py3.8.egg-info running install_scripts adding license file "LICENSE" (matched pattern "LICEN[CS]E*") adding license file "AUTHORS.rst" (matched pattern "AUTHORS*") creating build/bdist.macosx-10.14.6-arm64/wheel/portforward-0.2.7.dist-info/WHEEL creating '/private/var/folders/cj/bff_1hc10kb_l79fckygsh500000gp/T/pip-wheel-o6rh7k1s/portforward-0.2.7-cp38-cp38-macosx_10_14_6_arm64.whl' and adding 'build/bdist.macosx-10.14.6-arm64/wheel' to it adding '_portforward.abi3.h' adding '_portforward.abi3.so' adding 'portforward.py' adding 'portforward-0.2.7.dist-info/AUTHORS.rst' adding 'portforward-0.2.7.dist-info/LICENSE' adding 'portforward-0.2.7.dist-info/METADATA' adding 'portforward-0.2.7.dist-info/WHEEL' adding 'portforward-0.2.7.dist-info/top_level.txt' adding 'portforward-0.2.7.dist-info/RECORD' removing build/bdist.macosx-10.14.6-arm64/wheel Building wheel for portforward (setup.py) ... done Created wheel for portforward: filename=portforward-0.2.7-cp38-cp38-macosx_10_14_6_arm64.whl size=8955972 sha256=53e9f04def70f9e942be036cc2bd9039ed56fbc3ab62de92cb0335568921efe1 Stored in directory: /Users/hsalehghaffari/Library/Caches/pip/wheels/0d/1e/1b/df77f72503213a17dc59ecc29cb7901c75f18254762bfee341 Successfully built portforward Installing collected packages: portforward Successfully installed portforward-0.2.7

corka149 commented 2 years ago

This looks good. It builds _portforward without issues. Could you try to important _portforward directly?

hsalehgh commented 2 years ago

same error when importing _portforward directly: import _portforward Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dlopen(/Users/hsalehghaffari/Library/Python/3.8/lib/python/site-packages/_portforward.abi3.so, 0x0002): tried: '/Users/hsalehghaffari/Library/Python/3.8/lib/python/site-packages/_portforward.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

corka149 commented 2 years ago

Strange. Go builds for arm64. Maybe there is an issue with the previous installation tries.

Could you try to

  1. pip uninstall portforward
  2. Check that there is nothing left from portforward in /Users/hsalehghaffari/Library/Python/3.8/lib/python/site-packages/
  3. pip install portforward again