1#!/usr/bin/env python 2# 3# Copyright 2014 Tycho Andersen 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import os 18import sys 19 20from setuptools import setup 21from setuptools.command.install import install 22from distutils.command.build import build 23 24 25class binding_build(build): 26 """This is a check to ensure that the bindings have been generated, and 27 print a helpful message if they have not been generated yet. We only need 28 to check this when we are actually building or installing. 29 """ 30 def finalize_options(self): 31 if not os.path.exists('./xcffib'): 32 print("It looks like you need to generate the binding.") 33 print("please run 'make xcffib' or 'make check'.") 34 sys.exit(1) 35 build.finalize_options(self) 36 37 38class binding_install(install): 39 def finalize_options(self): 40 if not os.path.exists('./xcffib'): 41 print("It looks like you need to generate the binding.") 42 print("please run 'make xcffib' or 'make check'.") 43 sys.exit(1) 44 install.finalize_options(self) 45 46# Check if we're running PyPy, cffi can't be updated 47if '_cffi_backend' in sys.builtin_module_names: 48 import _cffi_backend 49 requires_cffi = "cffi==" + _cffi_backend.__version__ 50else: 51 requires_cffi = "cffi>=1.1.0" 52 53cffi_args = dict( 54 cffi_modules=["xcffib/ffi_build.py:ffi"] 55) 56 57version = "0.11.1" 58dependencies = ['six', requires_cffi] 59 60setup( 61 name="xcffib", 62 version=version, 63 description="A drop in replacement for xpyb, an XCB python binding", 64 keywords="xcb xpyb cffi x11 x windows", 65 license="Apache License 2.0", 66 url="http://github.com/tych0/xcffib", 67 author="Tycho Andersen", 68 author_email="tycho@tycho.pizza", 69 install_requires=dependencies, 70 setup_requires=dependencies, 71 packages=['xcffib'], 72 package_data={'xcffib': ['py.typed']}, 73 zip_safe=False, 74 cmdclass={ 75 'build': binding_build, 76 'install': binding_install 77 }, 78 classifiers=[ 79 'Development Status :: 5 - Production/Stable', 80 'License :: OSI Approved :: Apache Software License', 81 'Programming Language :: Python :: 3', 82 'Programming Language :: Python :: 3.6', 83 'Programming Language :: Python :: 3.7', 84 'Programming Language :: Python :: 3.8', 85 'Programming Language :: Python :: 3.9', 86 'Programming Language :: Python :: Implementation :: CPython', 87 'Programming Language :: Python :: Implementation :: PyPy', 88 'Topic :: Software Development :: Libraries' 89 ], 90 **cffi_args 91) 92