stefanradev93 / BayesFlow

A Python library for amortized Bayesian workflows using generative neural networks.
https://bayesflow.org/
MIT License
346 stars 50 forks source link

pip install v1.1.5 fails on Mac (M1) #153

Closed marvinschmitt closed 6 months ago

marvinschmitt commented 6 months ago

Problem Description

After v.1.1.5, a fresh pip install bayesflow on Apple Silicon (M1) fails due to conflicting dependencies:

ERROR: Cannot install bayesflow==1.1.1, bayesflow==1.1.2, bayesflow==1.1.3, bayesflow==1.1.4 and bayesflow==1.1.5 because these package versions have conflicting dependencies.

The conflict is caused by:
    bayesflow 1.1.5 depends on tensorflow-macos<2.16 and >=2.10; sys_platform == "darwin" and platform_machine == "arm64"
    bayesflow 1.1.4 depends on tensorflow-macos>=2.10; sys_platform == "darwin" and platform_machine == "arm64"
    bayesflow 1.1.3 depends on tensorflow-macos>=2.10; sys_platform == "darwin" and platform_machine == "arm64"
    bayesflow 1.1.2 depends on tensorflow-macos>=2.10; sys_platform == "darwin" and platform_machine == "arm64"
    bayesflow 1.1.1 depends on tensorflow-macos>=2.10; sys_platform == "darwin" and platform_machine == "arm64"

Underlying Cause

After some initial research, this looks like a consequence of a breaking change in tensorflow 2.16.1: Apple Silicon users shall now use pip install tensorflow (new) instead of pip install tensorflow-macos (old).

Source: https://github.com/tensorflow/tensorflow/releases/tag/v2.16.1

BayesFlow's current setup.cfg still differentiates between OS types to install either tensorflow or tensorflow-macos.

Solution

BayesFlow's setup.cfg needs to be updated. If we decide to stop support for the legacy Apple x86 hardware (Intel chips), we can just remove the conditional statement in setup.cfg and always install tensorflow. Opinions appreciated.

marvinschmitt commented 6 months ago

We might maintain experimental Apple x86 support by the following conditional statements in setup.cfg:

tensorflow-macos >= 2.10, < 2.16; sys_platform == 'darwin' and platform_machine == 'x86_64'
tensorflow >= 2.10.1, < 2.16; sys_platform != 'darwin' or platform_machine == 'arm64'

sys_platform=='darwin' means "MacOS" and platform_machine=='arm64' means "Apple Silicon (M1 etc.). This way, we always install tensorflow unless users are on MacOS with x86 chips.

Python environment marker reference: https://peps.python.org/pep-0508/#environment-markers