matchms / ms2deepscore

Deep learning similarity measure for comparing MS/MS spectra with respect to their chemical similarity
Apache License 2.0
53 stars 24 forks source link

Possible Fix For macos m1 tensorflow installation issue #109

Closed kevinmildau closed 1 year ago

kevinmildau commented 1 year ago

The current version of ms2deepscore has tensorflow in the install_requires which prevents successful installation on m1 macbooks. I've managed to get ms2deepscore to install and run on my M1 MacBook by slightly modifying the install requires.

I cloned the repo, and basically changed the setup.py install_requires and extras_requires with respect to tensorflow to be platform specific (see below). In macOS m1 one needs to make use of two distributions to unlock tensorflow cpu and gpu capabilities, hence the separate tensorflow-macos and tensorflow-metal packages.

There is one downside to this fix however; tensorflow, tensorflow-macos, and tensorflow-metal are not automatically installed if placed into the extras_requires like this, but are needed to successfully import ms2deepscore. They can however be separately pip installed. Both modules will be available together as a tensorflow module for importing, so no import code changes are needed anywhere; the entire MS2DeepScore_tutorial.ipynb can be run without changes.

I’m not sure whether the platform system dependence can be added to the install requires themselves somehow.

setup(
    name="ms2deepscore",
    version=version["__version__"],
    description="Deep learning similarity measure for comparing MS/MS spectra.",
    long_description=readme,
    long_description_content_type='text/markdown',
    author="Netherlands eScience Center",
    author_email="[f.huber@esciencecenter.nl](mailto:f.huber@esciencecenter.nl)",
    url="https://github.com/iomega/ms2deepscore",
    packages=find_packages(),
    include_package_data=True,
    license="Apache Software License 2.0",
    zip_safe=False,
    test_suite="tests",
    python_requires='>=3.7',
    install_requires=[
        "matchms",
        "numba",
        "numpy",
        "pandas",
        "tqdm”,
                                                             # <——————————————  Removed tensorflow
    ],
    extras_require={"dev": ["bump2version",
                            "isort>=4.2.5,<5",
                            "prospector[with_pyroma]",
                            "pytest",
                            "pytest-cov",
                            "sphinx>=3.0.0,!=3.2.0,<4.0.0",
                            "sphinx_rtd_theme",
                            "sphinxcontrib-apidoc",
                            "yapf",],
                    'platform_system=="Windows"': ['tensorflow’],       # <——————————————  Added
                    'platform_system=="Linux"':   ['tensorflow’],        #<——————————————  Added
                    'platform_system=="Darwin"':  ['tensorflow-macos’],  #<——————————————  Added
                    'platform_system=="Darwin"':  ['tensorflow-metal’]. # <——————————————  Added
    }
)
niekdejonge commented 1 year ago

This was fixed in #110