Skip to content

Commit

Permalink
Merge pull request #84 from lazka/bdist-wheel-warning
Browse files Browse the repository at this point in the history
setup.py: Show a warning regarding pkgconfig paths when running bdist_wheel. Fixes #83
  • Loading branch information
lazka committed Nov 28, 2017
2 parents f589c95 + c031144 commit 3c937b0
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions setup.py
Expand Up @@ -5,9 +5,11 @@
import sys
import os
import errno
import warnings

from distutils.core import Extension, setup, Command, Distribution
from distutils.ccompiler import new_compiler
from distutils.errors import DistutilsError


PYCAIRO_VERSION = '1.15.5'
Expand All @@ -20,6 +22,23 @@ def get_command_class(name):
return Distribution({}).get_command_class(name)


# https://github.com/pygobject/pycairo/issues/83
try:
st_bdist_wheel = get_command_class("bdist_wheel")
except DistutilsError:
bdist_wheel = None
else:
class bdist_wheel(st_bdist_wheel):

def run(self):
result = st_bdist_wheel.run(self)
warnings.warn(
"Python wheels of Pycairo contain absolute paths decided at "
"build time. Installing the wheel might result in pkg-config "
"returning wrong paths. Try to avoid bdist_wheel for pycairo.")
return result


def _check_output(command):
try:
return subprocess.check_output(command)
Expand Down Expand Up @@ -321,6 +340,18 @@ def main():
with io.open('README.rst', encoding="utf-8") as h:
long_description = h.read()

cmdclass = {
"build": build,
"build_ext": build_ext,
"install": install,
"install_pkgconfig": install_pkgconfig,
"install_data": install_data,
"test": test_cmd,
}

if bdist_wheel is not None:
cmdclass["bdist_wheel"] = bdist_wheel

setup(
name="pycairo",
version=PYCAIRO_VERSION,
Expand Down Expand Up @@ -348,14 +379,7 @@ def main():
data_files=[
('include/pycairo', ['cairo/pycairo.h']),
],
cmdclass={
"build": build,
"build_ext": build_ext,
"install": install,
"install_pkgconfig": install_pkgconfig,
"install_data": install_data,
"test": test_cmd,
},
cmdclass=cmdclass,
)


Expand Down

0 comments on commit 3c937b0

Please sign in to comment.