ets-labs / python-dependency-injector

Dependency injection framework for Python
https://python-dependency-injector.ets-labs.org/
BSD 3-Clause "New" or "Revised" License
3.89k stars 304 forks source link

Not compatible with MacOs M1 #553

Open yongxin-chen-db opened 2 years ago

yongxin-chen-db commented 2 years ago

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"

i8enn commented 2 years ago

@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/openssl@1.1/include -I/opt/homebrew/opt/libpq/include

...and created symlink python for homebrew bin:

$ tree -l /opt/homebrew/bin | grep python
├── 2to3 -> ../Cellar/python@3.9/3.9.12/bin/2to3
├── 2to3-3.9 -> ../Cellar/python@3.9/3.9.12/bin/2to3-3.9
├── idle3 -> ../Cellar/python@3.9/3.9.12/bin/idle3
├── idle3.9 -> ../Cellar/python@3.9/3.9.12/bin/idle3.9
├── ipython
├── ipython3
├── pip3 -> ../Cellar/python@3.9/3.9.12/bin/pip3
├── pip3.9 -> ../Cellar/python@3.9/3.9.12/bin/pip3.9
├── pydoc3 -> ../Cellar/python@3.9/3.9.12/bin/pydoc3
├── pydoc3.9 -> ../Cellar/python@3.9/3.9.12/bin/pydoc3.9
├── python -> python3
├── python3 -> ../Cellar/python@3.9/3.9.12/bin/python3
├── python3-config -> ../Cellar/python@3.9/3.9.12/bin/python3-config
├── python3.9 -> ../Cellar/python@3.9/3.9.12/bin/python3.9
├── python3.9-config -> ../Cellar/python@3.9/3.9.12/bin/python3.9-config
├── wheel3 -> ../Cellar/python@3.9/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/openssl@1.1/include -I/opt/homebrew/opt/libpq/include -DCYTHON_CLINE_IN_TRACEBACK=0 -I/opt/homebrew/opt/python@3.9/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/include -I/opt/homebrew/opt/libpq/include -DCYTHON_CLINE_IN_TRACEBACK=0 -I/opt/homebrew/opt/python@3.9/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/include -I/opt/homebrew/opt/libpq/include -DCYTHON_CLINE_IN_TRACEBACK=0 -I/opt/homebrew/opt/python@3.9/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/openssl@1.1/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/openssl@1.1/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
adivekar-utexas commented 6 months ago

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 commented 6 months ago

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

peterfortuin commented 1 month ago

Version 4.42.0b1 seems to be working fine on my M1 Macbook.