Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable make clean to remove ie_wheel artifacts #5961

Merged
merged 8 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions inference-engine/ie_bridges/python/wheel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
22 changes: 21 additions & 1 deletion inference-engine/ie_bridges/python/wheel/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
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
Expand Down Expand Up @@ -160,6 +161,7 @@ def generate_package(self, src_dirs):
# 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('*'):
Expand Down Expand Up @@ -197,6 +199,22 @@ def run(self):
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:
Expand Down Expand Up @@ -330,6 +348,7 @@ def get_package_dir(install_cfg):
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] = {}

Expand All @@ -350,6 +369,7 @@ def get_package_dir(install_cfg):
'install': CustomInstall,
'build_clib': PrepareLibs,
'build_ext': CopyExt,
'clean': CustomClean,
},
ext_modules=find_prebuilt_extensions(get_dir_list(PY_INSTALL_CFG)),
packages=packages,
Expand Down