@@ -332,21 +332,28 @@ def decompress_file(src, dst, comtype, stat=None):
332332compression_type = _createrepo_c .compression_type
333333
334334
335- DATA = os .path .join (os .path .dirname (__file__ ), 'data' )
336-
337- # Support running tests from the source tree
338- if not os .path .exists (DATA ):
339- from skbuild .constants import CMAKE_INSTALL_DIR as SKBUILD_CMAKE_INSTALL_DIR
340- _data = os .path .abspath (os .path .join (
341- os .path .dirname (__file__ ), '..' , SKBUILD_CMAKE_INSTALL_DIR , 'src/python/data' ))
342- if os .path .exists (_data ):
343- DATA = _data
344-
345- BIN_DIR = os .path .join (DATA , 'bin' )
346-
335+ _SKBUILD = bool ("@SKBUILD@" ) # Replaced by CMake
336+
337+ if _SKBUILD :
338+ # If we have been built as a Python package, e.g. "setup.py" or "pip install -e"
339+ _DATA = os .path .join (os .path .dirname (__file__ ), 'data' )
340+
341+ # Support running tests from the source tree
342+ if not os .path .exists (_DATA ):
343+ from skbuild .constants import CMAKE_INSTALL_DIR as SKBUILD_CMAKE_INSTALL_DIR
344+ _data = os .path .abspath (os .path .join (
345+ os .path .dirname (__file__ ), '..' , SKBUILD_CMAKE_INSTALL_DIR , 'src/python/data' ))
346+ if os .path .exists (_data ):
347+ DATA = _data
348+
349+ _BIN_DIR = os .path .join (DATA , 'bin' )
350+ else :
351+ # If we were not built as a Python package, e.g. RPM, "cmake ..; make"
352+ # Just assume that the binary will be on the PATH somewhere, likely /usr/bin/
353+ _BIN_DIR = ""
347354
348355def _program (name , args ):
349- return subprocess .call ([os .path .join (BIN_DIR , name )] + args )
356+ return subprocess .call ([os .path .join (_BIN_DIR , name )] + args )
350357
351358
352359def createrepo_c ():
0 commit comments