Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pkg-config-driven pycairo cflags #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,30 @@ def run(self):
extra_comp_args = list(filter(lambda arg: arg != "-fvisibility=hidden", extra_comp_args))

if os.environ.get("PYCAIRO", "false") == "true":
try:
extra_comp_args.append('-DHAVE_PYCAIRO')
print("-I%s/include/pycairo".format(sys.exec_prefix))
extra_comp_args.append("-I{0}/include/pycairo".format(sys.exec_prefix))
#extra_comp_args.extend(check_output(["pkg-config", '--cflags', 'pycairo']).strip().split(' '))
#linkflags.extend(check_output(["pkg-config", '--libs', 'pycairo']).strip().split(' '))
except:
raise Exception("Failed to find compiler options for pycairo")
pycairo_library_name = None
pycairo_default_cflags = "-I{0}/include/pycairo".format(sys.exec_prefix)
for name in ("py3cairo", "pycairo"):
try:
check_output(["pkg-config", "--exists", name])
except subprocess.CalledProcessError:
continue
else:
pycairo_library_name = name

pycairo_flags_set = False
if pycairo_library_name:
try:
extra_comp_args.extend(check_output(["pkg-config", "--cflags", pycairo_library_name]).strip().split(" "))
linkflags.extend(check_output(["pkg-config", "--libs", pycairo_library_name]).strip().split(" "))
pycairo_flags_set = True
except subprocess.CalledProcessError:
pass

if not pycairo_flags_set:
extra_comp_args.append(pycairo_default_cflags)
print("Failed to find compiler options for pycairo; using default CFLAGS:", pycairo_default_cflags)

extra_comp_args.append('-DHAVE_PYCAIRO')

if sys.platform == 'darwin':
extra_comp_args.append('-mmacosx-version-min=10.11')
Expand Down