aboutsummaryrefslogtreecommitdiffstats
path: root/build_scripts
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-11-17 15:36:25 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-12-09 13:26:02 +0100
commit1567f5bb52c1cb56dbe36f6865325b78a8512ed4 (patch)
tree5db8f6b5a3bc3264cd0448fb8ca800897ae2e144 /build_scripts
parent40d91782ebeb3080305cda5de6ee91864459a7a1 (diff)
Reland: Move all build dirs into a common 'build' subdirectory
When building the project using setup.py, it would pollute the source directory with a lot of virtual environment build directories. Move all of those into a common 'build' subdirectory. This eases cleanup of all build directories because they can all be removed with a single rm command. It also places all the various stages of build -> install -> package folders into a common subdirectory so it's easier to find and navigate between them. If no virtualenv is detected, change the venv prefix from the previous value of 'pyside' to 'qfp' and include the build classifiers. If a virtualenv is detected, we consider it is distinct enough and don't include the build classifiers, apart from a few chars to denote a debug python, debug Qt or limited api build. Example of the new build directory structure when a virtualenv is detected build/{venv_name}/build/shiboken6 build/{venv_name}/build/pyside6 build/{venv_name}/install/bin/shiboken6 build/{venv_name}/package Example of the new build directory structure when a virtualenv is NOT detected build/qfp-py3.9-qt6.2.0-64bit-release/build/shiboken6 build/qfp-py3.9-qt6.2.0-64bit-release/build/pyside6 build/qfp-py3.9-qt6.2.0-64bit-release/install/bin/shiboken6 build/qfp-py3.9-qt6.2.0-64bit-release/package Move the code that always removed the ./build directory on each setup.py invocation into prepare_packages() instead. This way it only removes the files from the 'package' subfolder which is the common packaging location between all the sub-projects. This removal is needed to ensure shiboken files don't end up packaged in the PySide6 wheel. This relands commit 234349d124ccfa399921e2b9fc09addcff0b0a94 This reverts commit 0c6eb7cd232fff9d81a8d5bc9a7fd71d9b8c67f5 [ChangeLog][setup.py] Build directories are now created inside the root ./build directory, rather than directly under the root of the project. Change-Id: I6d511ae77cb66c2c5a872d6b85ff33e1831b803e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 0a40ebb1defe14bb3d7a308657777a11058cf182) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'build_scripts')
-rw-r--r--build_scripts/build_info_collector.py41
-rw-r--r--build_scripts/main.py39
2 files changed, 53 insertions, 27 deletions
diff --git a/build_scripts/build_info_collector.py b/build_scripts/build_info_collector.py
index a4842e8ae..dcc9d7d6b 100644
--- a/build_scripts/build_info_collector.py
+++ b/build_scripts/build_info_collector.py
@@ -54,18 +54,19 @@ from .wheel_utils import get_qt_version
# Return a prefix suitable for the _install/_build directory
def prefix():
virtual_env_name = os.environ.get('VIRTUAL_ENV', None)
+ has_virtual_env = False
if virtual_env_name is not None:
name = os.path.basename(virtual_env_name)
+ has_virtual_env = True
else:
- name = "pyside"
- name += str(sys.version_info[0])
+ name = "qfp"
if OPTION["DEBUG"]:
name += "d"
if is_debug_python():
name += "p"
if OPTION["LIMITED_API"] == "yes":
name += "a"
- return name
+ return name, has_virtual_env
def is_debug_python():
@@ -210,13 +211,35 @@ class BuildInfoCollectorMixin(object):
self.build_classifiers = (f"py{py_version}-qt{qt_version}-{platform.architecture()[0]}-"
f"{build_type.lower()}")
- if OPTION["SHORTER_PATHS"]:
- build_name = f"p{py_version}"
- else:
- build_name = self.build_classifiers
+ venv_prefix, has_virtual_env = prefix()
+
+ # The virtualenv name serves as the base of the build dir
+ # and we consider it is distinct enough that we don't have to
+ # append the build classifiers, thus keeping dir names shorter.
+ build_name = f"{venv_prefix}"
+
+ # If short paths are requested and no virtual env is found, at
+ # least append the python version for more uniqueness.
+ if OPTION["SHORTER_PATHS"] and not has_virtual_env:
+ build_name += f"-p{py_version}"
+ # If no virtual env is found, use build classifiers for
+ # uniqueness.
+ elif not has_virtual_env:
+ build_name += f"-{self.build_classifiers}"
+
+ common_prefix_dir = os.path.join(script_dir, build_base)
+ build_dir = os.path.join(common_prefix_dir, build_name, "build")
+ install_dir = os.path.join(common_prefix_dir, build_name, "install")
- build_dir = os.path.join(script_dir, f"{prefix()}_build", f"{build_name}")
- install_dir = os.path.join(script_dir, f"{prefix()}_install", f"{build_name}")
+ # Change the setuptools build_lib dir to be under the same
+ # directory where the cmake build and install dirs are so
+ # there's a common subdirectory for all build-related dirs.
+ # Example:
+ # Replaces
+ # build/lib.macosx-10.14-x86_64-3.7' with
+ # build/{venv_prefix}/package'
+ setup_tools_build_lib_dir = os.path.join(common_prefix_dir, build_name, "package")
+ self.build_lib = setup_tools_build_lib_dir
self.script_dir = script_dir
self.sources_dir = sources_dir
diff --git a/build_scripts/main.py b/build_scripts/main.py
index 5b0c39bfc..a0b9335bb 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -172,17 +172,6 @@ qt_src_dir = ''
def prepare_build():
- # Clean up temp build folder.
- for n in ["build"]:
- d = os.path.join(setup_script_dir, n)
- if os.path.isdir(d):
- log.info(f"Removing {d}")
- try:
- rmtree(d)
- except Exception as e:
- log.warn(f'***** problem removing "{d}"')
- log.warn(f'ignored error: {e}')
-
# locate Qt sources for the documentation
if OPTION["QT_SRC"] is None:
install_prefix = QtInfo().prefix_dir
@@ -276,8 +265,9 @@ class PysideInstallLib(_install_lib):
def install(self):
"""
- Installs files from build/xxx directory into final
- site-packages/PySide6 directory.
+ Installs files from self.build_dir directory into final
+ site-packages/PySide6 directory when the command is 'install'
+ or into build/wheel when command is 'bdist_wheel'.
"""
if os.path.isdir(self.build_dir):
@@ -448,14 +438,14 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin):
log.info(dedent(f"""
Building {config.package_name()} will create and touch directories
in the following order:
- make build directory (py*_build/*/*) ->
- make install directory (py*_install/*/*) ->
- setuptools build directory (build/*/*) ->
+ make build directory ->
+ make install directory ->
+ setuptools build directory ->
setuptools install directory
(usually path-installed-python/lib/python*/site-packages/*)
"""))
- log.info(f"make build directory: {self.build_dir}")
- log.info(f"make install directory: {self.install_dir}")
+ log.info(f"make build directory: {self.build_dir}")
+ log.info(f"make install directory: {self.install_dir}")
log.info(f"setuptools build directory: {self.st_build_dir}")
log.info(f"setuptools install directory: {setuptools_install_prefix}")
log.info(dedent(f"""
@@ -823,6 +813,19 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin):
os.chdir(self.script_dir)
+ # Clean up the previous st_build_dir before files are copied
+ # into it again. That's the because the same dir is used
+ # when copying the files for each of the sub-projects and
+ # we don't want to accidentally install shiboken files
+ # as part of pyside-tools package.
+ if os.path.isdir(self.st_build_dir):
+ log.info(f"Removing {self.st_build_dir}")
+ try:
+ rmtree(self.st_build_dir)
+ except Exception as e:
+ log.warn(f'***** problem removing "{self.st_build_dir}"')
+ log.warn(f'ignored error: {e}')
+
if sys.platform == "win32":
vars['dbg_postfix'] = OPTION["DEBUG"] and "_d" or ""
return prepare_packages_win32(self, vars)