dss-extensions / DSS-Python

Native, "direct" Python bindings (interface) and misc tools for a custom implementation of OpenDSS (EPRI Distribution System Simulator). Based on CFFI, DSS C-API, aiming for full COM API-level compatibility on Windows, Linux and MacOS, while providing various extensions.
https://dss-extensions.org/DSS-Python/
BSD 3-Clause "New" or "Revised" License
60 stars 4 forks source link

macOS M1 arm64 #41

Closed chhokrad closed 2 years ago

chhokrad commented 2 years ago

I am not able to install the dss_python using pip.

System: MacBook Pro Apple M1 Max macOS Monterey 12.1 pip 22.0.4 Python 3.10.2

Error:

Screen Shot 2022-03-07 at 3 15 09 PM Screen Shot 2022-03-07 at 3 16 02 PM
PMeira commented 2 years ago

M1 ARM is not supported yet. We can build for ARM64 Linux already, but we don't have any machines or CI with M1 support, AFAICT.

PMeira commented 2 years ago

I just adjusted the build scripts for DSS C-API to include aarch64 on macOS in the next release PR at https://github.com/dss-extensions/dss_capi/pull/109

I imagine building the Python wheel won't be much harder, but still there is the lack of testing. We could release it anyway and just add a warning to the release notes, but people rarely read those.

PMeira commented 2 years ago

I added a cross-compiled wheel:

(EDIT: updated)

pip install dss-python==0.12.0b5

Untested, but should work.

PMeira commented 2 years ago

The build steps are now integrated in the workflow for GitHub Actions, so wheels for macOS ARM64 are prepared with the rest.

charraig commented 2 years ago

Hi @PMeira, thanks for working on the M1 architecture. I just tested with macOS 12.0.1 on M1 w/ Python 3.9.10 virtualenv, but received an ImportError:

pip install dss-python==0.12.0b3
python
>>> import dss
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/.pyenv/versions/testodd/lib/python3.9/site-packages/dss/__init__.py", line 5, in <module>
    from .v7 import *
  File "~/.pyenv/versions/testodd/lib/python3.9/site-packages/dss/v7.py", line 9, in <module>
    from ._dss_capi import ffi, lib
ImportError: dlopen(~/.pyenv/versions/testodd/lib/python3.9/site-packages/dss/_dss_capi.abi3.so, 0x0002): tried: '~/.pyenv/versions/testodd/lib/python3.9/site-packages/dss/_dss_capi.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_dss_capi.abi3.so' (no such file), '/usr/lib/_dss_capi.abi3.so' (no such file), '~/.pyenv/versions/3.9.10/envs/testodd/lib/python3.9/site-packages/dss/_dss_capi.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_dss_capi.abi3.so' (no such file), '/usr/lib/_dss_capi.abi3.so' (no such file)
PMeira commented 2 years ago

@charraig Thanks for testing it! Please retry with pip install dss-python==0.12.0b4. A compiler flag was missing in the previous one, so the output libs resulted in mixed architectures.

charraig commented 2 years ago

@PMeira Thanks! I tested the new version and it worked perfectly.