mirror of
				https://github.com/msgpack/msgpack-python.git
				synced 2025-11-03 19:10:55 +00:00 
			
		
		
		
	do not install cython as build dependency
This commit is contained in:
		
							parent
							
								
									9cea8b6da2
								
							
						
					
					
						commit
						08e52ab9e4
					
				
					 2 changed files with 1 additions and 48 deletions
				
			
		| 
						 | 
					@ -1,9 +1,5 @@
 | 
				
			||||||
[build-system]
 | 
					[build-system]
 | 
				
			||||||
requires = [
 | 
					requires = ["setuptools >= 69.5.1"]
 | 
				
			||||||
    # Also declared in requirements.txt, if updating here please also update there
 | 
					 | 
				
			||||||
    "Cython~=3.0.10",
 | 
					 | 
				
			||||||
    "setuptools >= 69.5.1",
 | 
					 | 
				
			||||||
]
 | 
					 | 
				
			||||||
build-backend = "setuptools.build_meta"
 | 
					build-backend = "setuptools.build_meta"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[project]
 | 
					[project]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										43
									
								
								setup.py
									
										
									
									
									
								
							
							
						
						
									
										43
									
								
								setup.py
									
										
									
									
									
								
							| 
						 | 
					@ -8,47 +8,6 @@ from setuptools.command.sdist import sdist
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PYPY = hasattr(sys, "pypy_version_info")
 | 
					PYPY = hasattr(sys, "pypy_version_info")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
class NoCython(Exception):
 | 
					 | 
				
			||||||
    pass
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
try:
 | 
					 | 
				
			||||||
    import Cython.Compiler.Main as cython_compiler
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    have_cython = True
 | 
					 | 
				
			||||||
except ImportError:
 | 
					 | 
				
			||||||
    have_cython = False
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def cythonize(src):
 | 
					 | 
				
			||||||
    if not have_cython:
 | 
					 | 
				
			||||||
        raise Exception("Cython is required for building from checkout")
 | 
					 | 
				
			||||||
    sys.stderr.write(f"cythonize: {src!r}\n")
 | 
					 | 
				
			||||||
    cython_compiler.compile([src])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def ensure_source(src):
 | 
					 | 
				
			||||||
    pyx = os.path.splitext(src)[0] + ".pyx"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if not os.path.exists(src) or have_cython and os.stat(src).st_mtime < os.stat(pyx).st_mtime:
 | 
					 | 
				
			||||||
        cythonize(pyx)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class BuildExt(build_ext):
 | 
					 | 
				
			||||||
    def build_extension(self, ext):
 | 
					 | 
				
			||||||
        for src in ext.sources:
 | 
					 | 
				
			||||||
            ensure_source(src)
 | 
					 | 
				
			||||||
        return build_ext.build_extension(self, ext)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Cython is required for sdist
 | 
					 | 
				
			||||||
class Sdist(sdist):
 | 
					 | 
				
			||||||
    def __init__(self, *args, **kwargs):
 | 
					 | 
				
			||||||
        cythonize("msgpack/_cmsgpack.pyx")
 | 
					 | 
				
			||||||
        sdist.__init__(self, *args, **kwargs)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
libraries = []
 | 
					libraries = []
 | 
				
			||||||
macros = []
 | 
					macros = []
 | 
				
			||||||
ext_modules = []
 | 
					ext_modules = []
 | 
				
			||||||
| 
						 | 
					@ -69,9 +28,7 @@ if not PYPY and not os.environ.get("MSGPACK_PUREPYTHON"):
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
del libraries, macros
 | 
					del libraries, macros
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
setup(
 | 
					setup(
 | 
				
			||||||
    cmdclass={"build_ext": BuildExt, "sdist": Sdist},
 | 
					 | 
				
			||||||
    ext_modules=ext_modules,
 | 
					    ext_modules=ext_modules,
 | 
				
			||||||
    packages=["msgpack"],
 | 
					    packages=["msgpack"],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue