how to include ssl with python build on MacOS

前端 未结 2 1977
别跟我提以往
别跟我提以往 2021-01-06 01:37

While building python from source on a MacOS, I accidntally overwrote the python that came with MacOS, now it doesn\'t have SSL. I tried to build again by running --wi

2条回答
  •  半阙折子戏
    2021-01-06 01:52

    First of all, MacOS only includes LibreSSL 2.2.7 libraries and no headers, you really want to install OpenSSL using homebrew:

    $ brew install openssl
    

    The openssl formula is a keg-only formula because the LibreSSL library is shadowing OpenSSL and Homebrew will not interfere with this. This means that you can find OpenSSL not in /usr/local but in /usr/local/opt/openssl. But Homebrew includes the necessary command-line tools to figure out what path to use.

    You then need to tell configure about these. If you are building Python 3.7 or newer, use the --with-openssl switch:

    ./configure --with-openssl=$(brew --prefix openssl)
    

    If you are building an older release, set the CPPFLAGS and LDFLAGS environment variables:

    CPPFLAGS="-I$(brew --prefix openssl)/include" \
    LDFLAGS="-L$(brew --prefix openssl)/lib" \
    ./configure
    

    and the Python configuration infrastructure takes it from there.

    Know that now ancient Python releases (2.6 or older, 3.0-3.4) only work with OpenSSL 1.0.x and before, which no longer is installable from homebrew core.

提交回复
热议问题