Enable make clean to remove ie_wheel artifacts (#5961)

* enable make clean to remove ie_wheel artifacts

* ./setup.py:132:1: E302 expected 2 blank lines

* fix CI build issue

* set ouput dir for whl file to CMAKE_BINARY_DIR

* cleanup

* blank line
This commit is contained in:
Sergey Lyubimtsev
2021-06-03 14:08:42 +03:00
committed by GitHub
parent 5494280dfa
commit 5f3144c700
2 changed files with 29 additions and 3 deletions

View File

@@ -53,11 +53,17 @@ endif()
add_custom_command(TARGET ie_wheel
POST_BUILD
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} bdist_wheel
--dist-dir ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/wheels
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_CURRENT_BINARY_DIR}/site-packages"
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} clean bdist_wheel
--dist-dir ${CMAKE_BINARY_DIR}/wheels
--build=${WHEEL_BUILD}
--plat-name=${WHEEL_PLATFORM}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Building Python wheel ${WHEEL_PACKAGE_NAME}"
VERBATIM
)
set_property(TARGET ie_wheel
APPEND
PROPERTY ADDITIONAL_CLEAN_FILES ${CMAKE_BINARY_DIR}/wheels
)

View File

@@ -8,9 +8,10 @@ import errno
import subprocess # nosec
import typing
from pathlib import Path
from shutil import copyfile
from shutil import copyfile, rmtree
from distutils.command.install import install
from distutils.command.build import build
from distutils.command.clean import clean
from distutils.errors import DistutilsSetupError
from distutils.file_util import copy_file
from distutils import log
@@ -160,6 +161,7 @@ class PrepareLibs(build_clib):
# additional blacklist filter, just to fix cmake install issues
blacklist = ['.lib', '.pdb', '_debug.dll', '_debug.dylib']
package_dir = os.path.join(get_package_dir(PY_INSTALL_CFG), WHEEL_LIBS_INSTALL_DIR)
for src_dir in src_dirs:
local_base_dir = Path(src_dir)
for file_path in local_base_dir.rglob('*'):
@@ -197,6 +199,22 @@ class CopyExt(build_ext):
copy_file(src, dst, verbose=self.verbose, dry_run=self.dry_run)
class CustomClean(clean):
"""Clean up staging directories"""
def clean(self, install_cfg):
for comp, comp_data in install_cfg.items():
install_prefix = comp_data.get('prefix')
self.announce(f'Cleaning {comp}: {install_prefix}', level=3)
if os.path.exists(install_prefix):
rmtree(install_prefix)
def run(self):
self.clean(LIB_INSTALL_CFG)
self.clean(PY_INSTALL_CFG)
clean.run(self)
def is_tool(name):
"""Check if the command-line tool is available"""
try:
@@ -330,6 +348,7 @@ package_license = config('WHEEL_LICENSE', '')
if os.path.exists(package_license):
copyfile(package_license, 'LICENSE')
packages = find_namespace_packages(','.join(get_dir_list(PY_INSTALL_CFG)))
package_data: typing.Dict[str, list] = {}
@@ -350,6 +369,7 @@ setup(
'install': CustomInstall,
'build_clib': PrepareLibs,
'build_ext': CopyExt,
'clean': CustomClean,
},
ext_modules=find_prebuilt_extensions(get_dir_list(PY_INSTALL_CFG)),
packages=packages,