python-dependency-injector icon indicating copy to clipboard operation
python-dependency-injector copied to clipboard

Not compatible with MacOs M1

Open yongxin-chen-db opened this issue 3 years ago • 4 comments

Since I am using MacOS M1 I can't run programs that are using Dependency Injector. Error message: ".../.env/lib/python3.9/site-packages/dependency_injector/containers.cpython-39-darwin.so: mach-o, but wrong architecture"

yongxin-chen-db avatar Jan 27 '22 12:01 yongxin-chen-db

@yongxin-chen-db it's ok now. I installed package with poetry and also tried building the package locally with make build.

python-dependency-injector: 4.39.1 OS: Monteray 12.3 XCode: 13.3.0.0.1.1645755326 Python: 3.9.12 Cython: 0.29.28 CPPFLAGS: -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include

...and created symlink python for homebrew bin:

$ tree -l /opt/homebrew/bin | grep python
├── 2to3 -> ../Cellar/[email protected]/3.9.12/bin/2to3
├── 2to3-3.9 -> ../Cellar/[email protected]/3.9.12/bin/2to3-3.9
├── idle3 -> ../Cellar/[email protected]/3.9.12/bin/idle3
├── idle3.9 -> ../Cellar/[email protected]/3.9.12/bin/idle3.9
├── ipython
├── ipython3
├── pip3 -> ../Cellar/[email protected]/3.9.12/bin/pip3
├── pip3.9 -> ../Cellar/[email protected]/3.9.12/bin/pip3.9
├── pydoc3 -> ../Cellar/[email protected]/3.9.12/bin/pydoc3
├── pydoc3.9 -> ../Cellar/[email protected]/3.9.12/bin/pydoc3.9
├── python -> python3
├── python3 -> ../Cellar/[email protected]/3.9.12/bin/python3
├── python3-config -> ../Cellar/[email protected]/3.9.12/bin/python3-config
├── python3.9 -> ../Cellar/[email protected]/3.9.12/bin/python3.9
├── python3.9-config -> ../Cellar/[email protected]/3.9.12/bin/python3.9-config
├── wheel3 -> ../Cellar/[email protected]/3.9.12/bin/wheel3

Build python-dependency-injector 4.39.1

$ make build

# Clean sources
find src -name '*.py[cod]' -delete
find src -name '__pycache__' -delete
find src -name '*.c' -delete
find src -name '*.h' -delete
find src -name '*.so' -delete
find src -name '*.html' -delete
# Clean tests
find tests -name '*.py[co]' -delete
find tests -name '__pycache__' -delete
# Clean examples
find examples -name '*.py[co]' -delete
find examples -name '__pycache__' -delete
# Compile Cython to C
cython -a -Xlanguage_level=2 src/dependency_injector/_cwiring.pyx src/dependency_injector/containers.pyx src/dependency_injector/providers.pyx
# Move all Cython html reports
mkdir -p reports/cython/
find src -name '*.html' -exec mv {}  reports/cython/  \;
# Compile C extensions
python setup.py build_ext --inplace
running build_ext
building 'dependency_injector.containers' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include -DCYTHON_CLINE_IN_TRACEBACK=0 -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/dependency_injector/containers.c -o build/temp.macosx-12-arm64-3.9/src/dependency_injector/containers.o -O2
creating build/lib.macosx-12-arm64-3.9
creating build/lib.macosx-12-arm64-3.9/dependency_injector
clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/opt/libpq/lib -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include build/temp.macosx-12-arm64-3.9/src/dependency_injector/containers.o -o build/lib.macosx-12-arm64-3.9/dependency_injector/containers.cpython-39-darwin.so
building 'dependency_injector.providers' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include -DCYTHON_CLINE_IN_TRACEBACK=0 -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/dependency_injector/providers.c -o build/temp.macosx-12-arm64-3.9/src/dependency_injector/providers.o -O2
src/dependency_injector/providers.c:8274:13: warning: code will never be executed [-Wunreachable-code]
        if (__pyx_t_2) {
            ^~~~~~~~~
1 warning generated.
clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/opt/libpq/lib -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include build/temp.macosx-12-arm64-3.9/src/dependency_injector/providers.o -o build/lib.macosx-12-arm64-3.9/dependency_injector/providers.cpython-39-darwin.so
building 'dependency_injector._cwiring' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include -DCYTHON_CLINE_IN_TRACEBACK=0 -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/dependency_injector/_cwiring.c -o build/temp.macosx-12-arm64-3.9/src/dependency_injector/_cwiring.o -O2
clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/opt/libpq/lib -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include build/temp.macosx-12-arm64-3.9/src/dependency_injector/_cwiring.o -o build/lib.macosx-12-arm64-3.9/dependency_injector/_cwiring.cpython-39-darwin.so
copying build/lib.macosx-12-arm64-3.9/dependency_injector/containers.cpython-39-darwin.so -> src/dependency_injector
copying build/lib.macosx-12-arm64-3.9/dependency_injector/providers.cpython-39-darwin.so -> src/dependency_injector
copying build/lib.macosx-12-arm64-3.9/dependency_injector/_cwiring.cpython-39-darwin.so -> src/dependency_injector

i8enn avatar Apr 15 '22 08:04 i8enn

It's been 2+ years, is there any fix planned? Or have the maintainers purposely left it as an open issue in dependency_injector for some reason?

adivekar-utexas avatar Mar 20 '24 05:03 adivekar-utexas

Frankly I've tried and the x86_64 wheel works, but it does not install without some wrangling.

adivekar-utexas avatar Mar 20 '24 05:03 adivekar-utexas