Skip to content

Commit 9a538b7

Browse files
committed
MacOS: check openssl prefix in brew.
1 parent cb55f6b commit 9a538b7

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

.github/workflows/test_macos.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,12 @@ jobs:
4646
python-version: ${{ matrix.python-version }}
4747

4848
- name: build wheel and sdist
49-
env:
50-
LDFLAGS: -L/usr/local/opt/openssl@1.1/lib
51-
CPPFLAGS: -I/usr/local/opt/openssl@1.1/include
52-
PKG_CONFIG_PATH: /usr/local/opt/openssl@1.1/lib/pkgconfig
5349
run: |
5450
pip install --upgrade pip
5551
pip install -r dev/requirements-dev.txt
5652
pip install delocate
5753
python setup.py sdist
58-
brew install openssl@1.1
54+
brew install openssl
5955
brew install libiconv
6056
python dev/build.py \
6157
--ws-dir=./freetds \

setup.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from pathlib import Path
2727
import platform
2828
import struct
29+
import subprocess
2930
import sys
3031

3132
from setuptools import setup, Extension
@@ -40,7 +41,7 @@
4041
else:
4142
# Force `setup_requires` stuff like Cython to be installed before proceeding
4243
from setuptools.dist import Distribution
43-
Distribution(dict(setup_requires='Cython>=0.29.21'))
44+
Distribution(dict(setup_requires='Cython>=3.0'))
4445
from Cython.Distutils import build_ext as _build_ext
4546

4647
def check_env(env_name, default):
@@ -65,7 +66,7 @@ def check_env(env_name, default):
6566
library_dirs = []
6667
libraries = ['sybdb']
6768

68-
prefix = None
69+
prefix = "/usr/local"
6970
if os.getenv('PYMSSQL_FREETDS'):
7071
prefix = os.path.abspath(os.getenv('PYMSSQL_FREETDS').strip())
7172
elif exists("/usr/local/include/sqlfront.h"):
@@ -78,20 +79,26 @@ def check_env(env_name, default):
7879
prefix = "/opt/local"
7980
elif exists("/sw/include/sqlfront.h"): # Fink
8081
prefix = "/sw"
82+
print(f"prefix='{prefix}'")
8183

82-
if prefix:
83-
print(f"prefix='{prefix}'")
84+
if os.getenv('PYMSSQL_FREETDS_INCLUDEDIR'):
85+
include_dirs = [ os.getenv('PYMSSQL_FREETDS_INCLUDEDIR') ]
86+
else:
8487
include_dirs = [ join(prefix, "include") ]
88+
89+
if os.getenv('PYMSSQL_FREETDS_LIBDIR'):
90+
library_dirs = [ os.getenv('PYMSSQL_FREETDS_LIBDIR') ]
91+
else:
8592
if BITNESS == 64 and exists(join(prefix, "lib64")):
8693
library_dirs = [ join(prefix, "lib64") ]
8794
else:
8895
library_dirs = [ join(prefix, "lib") ]
8996

90-
if os.getenv('PYMSSQL_FREETDS_INCLUDEDIR'):
91-
include_dirs = [ os.getenv('PYMSSQL_FREETDS_INCLUDEDIR') ]
92-
93-
if os.getenv('PYMSSQL_FREETDS_LIBDIR'):
94-
library_dirs = [ os.getenv('PYMSSQL_FREETDS_LIBDIR') ]
97+
if MACOS:
98+
pref = subprocess.getoutput('brew --prefix openssl')
99+
print(f"PREFIX={pref}")
100+
include_dirs.append(f"{pref}/include")
101+
library_dirs.append(f"{pref}/lib")
95102

96103
print("setup.py: platform.system() =>", platform.system())
97104
print("setup.py: platform.architecture() =>", platform.architecture())

0 commit comments

Comments
 (0)