mirror of https://github.com/kivy/kivy.git
distutils module is deprecated and slated for removal in 3.12 (#8070)
This commit is contained in:
parent
c4a52ed078
commit
a0df4298c6
|
@ -18,7 +18,7 @@ update_version_metadata() {
|
|||
}
|
||||
|
||||
generate_sdist() {
|
||||
python3 -m pip install cython
|
||||
python3 -m pip install cython packaging
|
||||
python3 setup.py sdist --formats=gztar
|
||||
python3 -m pip uninstall cython -y
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ from __future__ import print_function
|
|||
|
||||
__all__ = ('FactoryBuild', )
|
||||
|
||||
from distutils.cmd import Command
|
||||
import fnmatch
|
||||
import os
|
||||
|
||||
from setuptools import Command
|
||||
|
||||
import kivy
|
||||
|
||||
ignore_list = (
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[build-system]
|
||||
requires = [
|
||||
"setuptools", "wheel",
|
||||
"setuptools", "wheel", "packaging",
|
||||
"cython>=0.24,<=0.29.33,!=0.27,!=0.27.2",
|
||||
'kivy_deps.gstreamer_dev~=0.3.3; sys_platform == "win32"',
|
||||
'kivy_deps.sdl2_dev~=0.6.0; sys_platform == "win32"',
|
||||
|
|
54
setup.py
54
setup.py
|
@ -12,18 +12,16 @@ if "--build_examples" in sys.argv:
|
|||
from kivy.utils import pi_version
|
||||
from copy import deepcopy
|
||||
import os
|
||||
from os.path import join, dirname, sep, exists, basename, isdir
|
||||
from os.path import join, dirname, exists, basename, isdir
|
||||
from os import walk, environ, makedirs
|
||||
from distutils.command.build_ext import build_ext
|
||||
from distutils.version import LooseVersion
|
||||
from distutils.sysconfig import get_python_inc
|
||||
from collections import OrderedDict
|
||||
from time import sleep
|
||||
from sysconfig import get_paths
|
||||
from pathlib import Path
|
||||
import logging
|
||||
from setuptools import setup, Extension, find_packages
|
||||
import sysconfig
|
||||
|
||||
from setuptools import Extension, find_packages, setup
|
||||
from setuptools.command.build_ext import build_ext
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
logging.critical(
|
||||
|
@ -36,10 +34,6 @@ def ver_equal(self, other):
|
|||
return self.version == other
|
||||
|
||||
|
||||
# fix error with py3's LooseVersion comparisons
|
||||
LooseVersion.__eq__ = ver_equal
|
||||
|
||||
|
||||
def get_description():
|
||||
with open(join(dirname(__file__), 'README.md'), 'rb') as fileh:
|
||||
return fileh.read().decode("utf8").replace('\r\n', '\n')
|
||||
|
@ -234,29 +228,8 @@ with open(join(src_path, 'kivy', '_version.py'), encoding="utf-8") as f:
|
|||
|
||||
class KivyBuildExt(build_ext, object):
|
||||
|
||||
def __new__(cls, *a, **kw):
|
||||
# Note how this class is declared as a subclass of distutils
|
||||
# build_ext as the Cython version may not be available in the
|
||||
# environment it is initially started in. However, if Cython
|
||||
# can be used, setuptools will bring Cython into the environment
|
||||
# thus its version of build_ext will become available.
|
||||
# The reason why this is done as a __new__ rather than through a
|
||||
# factory function is because there are distutils functions that check
|
||||
# the values provided by cmdclass with issublcass, and so it would
|
||||
# result in an exception.
|
||||
# The following essentially supply a dynamically generated subclass
|
||||
# that mix in the cython version of build_ext so that the
|
||||
# functionality provided will also be executed.
|
||||
if can_use_cython:
|
||||
from Cython.Distutils import build_ext as cython_build_ext
|
||||
build_ext_cls = type(
|
||||
'KivyBuildExt', (KivyBuildExt, cython_build_ext), {})
|
||||
return super(KivyBuildExt, cls).__new__(build_ext_cls)
|
||||
else:
|
||||
return super(KivyBuildExt, cls).__new__(cls)
|
||||
|
||||
def finalize_options(self):
|
||||
retval = super(KivyBuildExt, self).finalize_options()
|
||||
super().finalize_options()
|
||||
|
||||
# Build the extensions in parallel if the options has not been set
|
||||
if hasattr(self, 'parallel') and self.parallel is None:
|
||||
|
@ -273,8 +246,6 @@ class KivyBuildExt(build_ext, object):
|
|||
build_path = self.build_lib
|
||||
print("Updated build directory to: {}".format(build_path))
|
||||
|
||||
return retval
|
||||
|
||||
def build_extensions(self):
|
||||
# build files
|
||||
config_h_fn = ('include', 'config.h')
|
||||
|
@ -327,7 +298,7 @@ class KivyBuildExt(build_ext, object):
|
|||
for e in self.extensions:
|
||||
e.extra_link_args += ['-lm']
|
||||
|
||||
super(KivyBuildExt, self).build_extensions()
|
||||
super().build_extensions()
|
||||
|
||||
def update_if_changed(self, fn, content):
|
||||
need_update = True
|
||||
|
@ -392,17 +363,18 @@ cython_min_msg, cython_max_msg, cython_unsupported_msg = get_cython_msg()
|
|||
|
||||
if can_use_cython:
|
||||
import Cython
|
||||
from packaging import version
|
||||
print('\nFound Cython at', Cython.__file__)
|
||||
|
||||
cy_version_str = Cython.__version__
|
||||
cy_ver = LooseVersion(cy_version_str)
|
||||
cy_ver = version.parse(cy_version_str)
|
||||
print('Detected supported Cython version {}'.format(cy_version_str))
|
||||
|
||||
if cy_ver < LooseVersion(MIN_CYTHON_STRING):
|
||||
if cy_ver < version.Version(MIN_CYTHON_STRING):
|
||||
print(cython_min_msg)
|
||||
elif cy_ver in CYTHON_UNSUPPORTED:
|
||||
print(cython_unsupported_msg)
|
||||
elif cy_ver > LooseVersion(MAX_CYTHON_STRING):
|
||||
elif cy_ver > version.Version(MAX_CYTHON_STRING):
|
||||
print(cython_max_msg)
|
||||
sleep(1)
|
||||
|
||||
|
@ -477,7 +449,9 @@ if platform not in ('ios', 'android') and (c_options['use_gstreamer']
|
|||
gstreamer_valid = True
|
||||
c_options['use_gstreamer'] = True
|
||||
else:
|
||||
_includes = get_isolated_env_paths()[0] + [get_paths()['include']]
|
||||
_includes = get_isolated_env_paths()[0] + [
|
||||
sysconfig.get_path("include")
|
||||
]
|
||||
for include_dir in _includes:
|
||||
if exists(join(include_dir, 'gst', 'gst.h')):
|
||||
print('GStreamer found via gst.h')
|
||||
|
@ -644,7 +618,7 @@ def determine_base_flags():
|
|||
flags['extra_compile_args'] += ['-F%s' % sysroot]
|
||||
flags['extra_link_args'] += ['-F%s' % sysroot]
|
||||
elif platform == 'win32':
|
||||
flags['include_dirs'] += [get_python_inc(prefix=sys.prefix)]
|
||||
flags['include_dirs'] += [sysconfig.get_path('include')]
|
||||
flags['library_dirs'] += [join(sys.prefix, "libs")]
|
||||
return flags
|
||||
|
||||
|
|
Loading…
Reference in New Issue