aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2017-11-02 11:49:39 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2017-11-15 15:47:00 +0000
commitcadc370720773b4372496fafc40b34f604da6f9b (patch)
treed8d69f656d1e07b9c6d6e8d4edb400df35742fed /setup.py
parent554a82039fb5165bf2e1922551df54dd9fbf3d2c (diff)
Preserve symlinks instead of duplicating files
This change overrides some of the commands provided by distutils / setuptools to preserve symlinks when copying directories. This is mostly to decrease the time spent and amount of space used by copying into the pyside_package, build/xxx and site-packages directories (copying around WebEngine libraries takes a bit of time and space). It is not useful for bdist_wheels or eggs, because Python's zip module does not preserve symlinks when archiving the files. Ultimately this will probably go away, once we figure out which if any of the symlinks are needed. Task-number: PYSIDE-495 Change-Id: I8766266c9ab51d610c9a5377618ab06020637d7d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index 0335a7a2b..1ee13ffcd 100644
--- a/setup.py
+++ b/setup.py
@@ -165,8 +165,10 @@ from distutils.command.build_ext import build_ext as _build_ext
from setuptools import setup, Extension
from setuptools.command.install import install as _install
+from setuptools.command.install_lib import install_lib as _install_lib
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
from setuptools.command.develop import develop as _develop
+from setuptools.command.build_py import build_py as _build_py
from qtinfo import QtInfo
from utils import rmtree
@@ -463,6 +465,40 @@ class pyside_build_ext(_build_ext):
def run(self):
pass
+# pyside_build_py and pyside_install_lib are reimplemented to preserve symlinks when
+# distutils / setuptools copy files to various directories through the different build stages.
+class pyside_build_py(_build_py):
+
+ def __init__(self, *args, **kwargs):
+ _build_py.__init__(self, *args, **kwargs)
+
+ def build_package_data(self):
+ """Copies files from pyside_package into build/xxx directory"""
+
+ for package, src_dir, build_dir, filenames in self.data_files:
+ for filename in filenames:
+ target = os.path.join(build_dir, filename)
+ self.mkpath(os.path.dirname(target))
+ srcfile = os.path.abspath(os.path.join(src_dir, filename))
+ # Using our own copyfile makes sure to preserve symlinks.
+ copyfile(srcfile, target)
+
+class pyside_install_lib(_install_lib):
+
+ def __init__(self, *args, **kwargs):
+ _install_lib.__init__(self, *args, **kwargs)
+
+ def install(self):
+ """Installs files from build/xxx directory into final site-packages/PySide2 directory."""
+
+ if os.path.isdir(self.build_dir):
+ # Using our own copydir makes sure to preserve symlinks.
+ outfiles = copydir(os.path.abspath(self.build_dir), os.path.abspath(self.install_dir))
+ else:
+ self.warn("'%s' does not exist -- no Python modules to install" % self.build_dir)
+ return
+ return outfiles
+
class pyside_build(_build):
def __init__(self, *args, **kwargs):
@@ -1317,10 +1353,12 @@ setup(
},
cmdclass = {
'build': pyside_build,
+ 'build_py': pyside_build_py,
'build_ext': pyside_build_ext,
'bdist_egg': pyside_bdist_egg,
'develop': pyside_develop,
- 'install': pyside_install
+ 'install': pyside_install,
+ 'install_lib': pyside_install_lib
},
# Add a bogus extension module (will never be built here since we are