aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST.in26
-rw-r--r--README.rst37
-rw-r--r--setup.py65
-rw-r--r--utils.py56
4 files changed, 115 insertions, 69 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
index 944e2b2c7..0810f6c5d 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -26,18 +26,18 @@ recursive-exclude sources/pyside-tools/.git **
recursive-exclude sources/pyside-examples/.git **
# PySide package
-recursive-include pyside_dist/PySide **
-recursive-include pyside_dist/PySide/docs **
-recursive-include pyside_dist/PySide/plugins **
-recursive-include pyside_dist/PySide/imports **
-recursive-include pyside_dist/PySide/translations **
-recursive-include pyside_dist/PySide/include **
-recursive-include pyside_dist/PySide/typesystems **
-recursive-include pyside_dist/PySide/examples **
+recursive-include pyside_package/PySide **
+recursive-include pyside_package/PySide/docs **
+recursive-include pyside_package/PySide/plugins **
+recursive-include pyside_package/PySide/imports **
+recursive-include pyside_package/PySide/translations **
+recursive-include pyside_package/PySide/include **
+recursive-include pyside_package/PySide/typesystems **
+recursive-include pyside_package/PySide/examples **
# pysideuic package
-recursive-include pyside_dist/pysideuic **
-recursive-include pyside_dist/pysideuic/Compiler **
-recursive-include pyside_dist/pysideuic/port_v2 **
-recursive-include pyside_dist/pysideuic/port_v3 **
-recursive-include pyside_dist/pysideuic/widget-plugins **
+recursive-include pyside_package/pysideuic **
+recursive-include pyside_package/pysideuic/Compiler **
+recursive-include pyside_package/pysideuic/port_v2 **
+recursive-include pyside_package/pysideuic/port_v3 **
+recursive-include pyside_package/pysideuic/widget-plugins **
diff --git a/README.rst b/README.rst
index a7e38cb90..b8ff3f712 100644
--- a/README.rst
+++ b/README.rst
@@ -112,7 +112,13 @@ Building PySide distribution
::
- c:\> c:\Python27\python.exe setup.py bdist_wininst --msvc-version=9.0 --qmake=c:\Qt\4.8.4\bin\qmake.exe --openssl=c:\OpenSSL32bit\bin
+ c:\> c:\Python27\python.exe setup.py bdist_wininst --qmake=c:\Qt\4.8.4\bin\qmake.exe --openssl=c:\OpenSSL32bit\bin
+
+#. Optionally you can specify the msvc compiler version:
+
+ ::
+
+ c:\> c:\Python27\python.exe setup.py bdist_wininst --msvc-version=10.0 --qmake=c:\Qt\4.8.4\bin\qmake.exe --openssl=c:\OpenSSL32bit\bin
#. After the successful build, install the distribution with easy_install
and run the post-install script:
@@ -220,11 +226,18 @@ Distribution types
``bdist_wininst``
Create standalone windows installer with embedded Qt libs and development tools.
This distribution type can be installed with ``easy_install``.
-
+
``bdist_egg``
Create egg binary distribution.
This distribution type can be installed with ``easy_install``.
-
+
+``install``
+ Install package to site packages folder.
+
+``develop``
+ Install package in ``development mode``, such that it's available on
+ ``sys.path``, yet can still be edited directly from its source folder.
+
``sdist``
Create full source distribution with included sources of PySide Setup Scripts,
PySide, Shiboken, PySide Tools and PySide Examples.
@@ -237,22 +250,20 @@ Options
Specify the path to qmake.
Useful when the qmake is not in path or more than one Qt versions are installed.
+``--openssl``
+ Specify the path to OpenSSL libs.
+
+``--only-package``
+ Skip rebuilding everything and create distribution from prebuilt binaries.
+ Before using this option first time, the full distribution build is required.
+
``--cmake``
Specify the path to cmake.
Useful when the cmake is not in path.
``--msvc-version``
Specify the Visual C++ compiler version.
- Supported values are ``9.0``, ``10.0``, ``11.0``.
- This option adds support for building windows binaries outside the Visual Studio Command Prompt.
- The MSVC environment is properly initialized by setup script.
-
-``--openssl``
- Specify the path to OpenSSL libs.
-
-``--only-package``
- Create distribution from prebuilt PySide binaries.
- Before using this option first time, the full distribution build is required.
+ Supported values are ``9.0`` (for VS 2008), ``10.0`` (for VS 2010), ``11.0`` (for VS 2012).
``--standalone``
When enabled, all required Qt libs will be included in PySide distribution.
diff --git a/setup.py b/setup.py
index 56d8761db..b3b0be69d 100644
--- a/setup.py
+++ b/setup.py
@@ -73,6 +73,7 @@ from distutils.command.build import build as _build
from setuptools import setup, Extension
from setuptools.command.install import install as _install
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
+from setuptools.command.develop import develop as _develop
from qtinfo import QtInfo
from utils import rmtree
@@ -82,8 +83,8 @@ from utils import copydir
from utils import run_process
from utils import has_option
from utils import option_value
-from utils import find_vcvarsall
-from utils import get_environment_from_batch_command
+from utils import update_env_path
+from utils import init_msvc_env
# Declare options
OPTION_DEBUG = has_option("debug")
@@ -184,14 +185,14 @@ if os.path.isdir(".git") and not OPTION_IGNOREGIT and not OPTION_ONLYPACKAGE:
os.chdir(script_dir)
# Clean up temp and package folders
-for n in ["pyside_dist", "build", "PySide.egg-info", "PySide-%s" % __version__]:
+for n in ["pyside_package", "build", "PySide-%s" % __version__]:
d = os.path.join(script_dir, n)
if os.path.isdir(d):
print("Removing %s" % d)
rmtree(d)
# Prepare package folders
-for pkg in ["pyside_dist/PySide", "pyside_dist/pysideuic"]:
+for pkg in ["pyside_package/PySide", "pyside_package/pysideuic"]:
pkg_dir = os.path.join(script_dir, pkg)
os.makedirs(pkg_dir)
@@ -219,6 +220,15 @@ class pyside_install(_install):
]
run_process(cmd)
+class pyside_develop(_develop):
+
+ def __init__(self, *args, **kwargs):
+ _develop.__init__(self, *args, **kwargs)
+
+ def run(self):
+ self.run_command("build")
+ _develop.run(self)
+
class pyside_bdist_egg(_bdist_egg):
def __init__(self, *args, **kwargs):
@@ -251,42 +261,12 @@ class pyside_build(_build):
self.qtinfo = None
def run(self):
- def update_env_path(newpaths):
- paths = os.environ['PATH'].lower().split(os.pathsep)
- for path in newpaths:
- if not path.lower() in paths:
- log.info("Inserting path \"%s\" to environment" % path)
- paths.insert(0, path)
- os.environ['PATH'] = os.pathsep.join(paths)
-
platform_arch = platform.architecture()[0]
log.info("Python architecture is %s" % platform_arch)
- # Try to init the MSVC env
- if sys.platform == "win32" and OPTION_MSVCVERSION:
- # Search for MSVC
- log.info("Searching vcvarsall.bat for MSVC version %s" % OPTION_MSVCVERSION)
- msvc_version = float(OPTION_MSVCVERSION)
- vcvarsall_path = find_vcvarsall(msvc_version)
- if not vcvarsall_path:
- raise DistutilsSetupError(
- "Failed to find the vcvarsall.bat for MSVC version %s." % OPTION_MSVCVERSION)
- log.info("Found %s" % vcvarsall_path)
- # Get MSVC env
- msvc_arch = "x86" if platform_arch.startswith("32") else "amd64"
- log.info("Getting MSVC env for %s architecture" % msvc_arch)
- vcvarsall_cmd = ["call", vcvarsall_path, msvc_arch]
- msvc_env = get_environment_from_batch_command(vcvarsall_path)
- msvc_env_paths = os.pathsep.join([msvc_env[k] for k in msvc_env if k.upper() == 'PATH']).split(os.pathsep)
- msvc_env_without_paths = dict([(k, msvc_env[k]) for k in msvc_env if k.upper() != 'PATH'])
- # Extend os.environ with MSVC env
- log.info("Initializing MSVC env...")
- update_env_path(msvc_env_paths)
- for k in msvc_env_without_paths:
- v = msvc_env_without_paths[k]
- log.info("Inserting \"%s = %s\" to environment" % (k, v))
- os.environ[k] = v
- log.info("Done initializing MSVC env")
+ # Try to init the MSVC environment
+ if sys.platform == "win32" and OPTION_MAKESPEC == "msvc":
+ init_msvc_env(OPTION_MSVCVERSION, platform_arch, log)
# Check env
make_path = None
@@ -398,7 +378,7 @@ class pyside_build(_build):
sys.exit(1)
# Update the PATH environment variable
- update_env_path([py_scripts_dir, qt_dir])
+ update_env_path([py_scripts_dir, qt_dir], log)
build_name = "py%s-qt%s-%s-%s" % \
(py_version, qt_version, platform.architecture()[0], build_type.lower())
@@ -568,7 +548,7 @@ class pyside_build(_build):
"install_dir": self.install_dir,
"build_dir": self.build_dir,
"script_dir": self.script_dir,
- "dist_dir": os.path.join(self.script_dir, 'pyside_dist'),
+ "dist_dir": os.path.join(self.script_dir, 'pyside_package'),
"ssl_libs_dir": OPTION_OPENSSL,
"py_version": self.py_version,
"qt_version": self.qtinfo.version,
@@ -878,8 +858,7 @@ setup(
download_url = 'http://releases.qt-project.org/pyside',
license = 'LGPL',
packages = ['PySide', 'pysideuic'],
- package_dir = {'PySide': 'pyside_dist/PySide',
- 'pysideuic': 'pyside_dist/pysideuic'},
+ package_dir = {'': 'pyside_package'},
include_package_data = True,
zip_safe = False,
entry_points = {
@@ -890,6 +869,7 @@ setup(
cmdclass = {
'build': pyside_build,
'bdist_egg': pyside_bdist_egg,
+ 'develop': pyside_develop,
'install': pyside_install,
},
@@ -897,7 +877,6 @@ setup(
# overriding the build command to do it using cmake) so things like
# bdist_egg will know that there are extension modules and will name the
# dist with the full platform info.
- ext_modules = [Extension('QtCore', [])],
+ #ext_modules = [Extension('QtCore', [])],
ext_package = 'PySide',
-
)
diff --git a/utils.py b/utils.py
index 1a9f20bb8..1dfa0e3f4 100644
--- a/utils.py
+++ b/utils.py
@@ -53,12 +53,68 @@ def filter_match(name, patterns):
return False
+def update_env_path(newpaths, logger):
+ paths = os.environ['PATH'].lower().split(os.pathsep)
+ for path in newpaths:
+ if not path.lower() in paths:
+ logger.info("Inserting path \"%s\" to environment" % path)
+ paths.insert(0, path)
+ os.environ['PATH'] = os.pathsep.join(paths)
+
+
def find_vcvarsall(version):
from distutils import msvc9compiler
vcvarsall_path = msvc9compiler.find_vcvarsall(version)
return vcvarsall_path
+def find_vcvarsall_paths(versions):
+ vcvarsall_paths = []
+ for version in versions:
+ vcvarsall_paths.append([version, find_vcvarsall(version)])
+ return vcvarsall_paths
+
+
+def init_msvc_env(default_msvc_version, platform_arch, logger):
+ logger.info("Searching vcvarsall.bat")
+ all_vcvarsall_paths = find_vcvarsall_paths([9.0, 10.0, 11.0])
+ if len(all_vcvarsall_paths) == 0:
+ raise DistutilsSetupError(
+ "Failed to find the MSVC compiler on your system.")
+ for v in all_vcvarsall_paths:
+ logger.info("Found MSVC %s in %s" % (v[0], v[1]))
+
+ if default_msvc_version:
+ msvc_version = float(default_msvc_version)
+ vcvarsall_path_tmp = [p for p in all_vcvarsall_paths if p[0] == msvc_version]
+ vcvarsall_path = vcvarsall_path_tmp[0][1] if len(vcvarsall_path_tmp) > 0 else None
+ if not vcvarsall_path:
+ raise DistutilsSetupError(
+ "Failed to find the vcvarsall.bat for MSVC version %s." % msvc_version)
+ else:
+ # By default use first MSVC compiler found in system
+ msvc_version = all_vcvarsall_paths[0][0]
+ vcvarsall_path = all_vcvarsall_paths[0][1]
+
+ # Get MSVC env
+ logger.info("Using MSVC %s in %s" % (msvc_version, vcvarsall_path))
+ msvc_arch = "x86" if platform_arch.startswith("32") else "amd64"
+ logger.info("Getting MSVC env for %s architecture" % msvc_arch)
+ vcvarsall_cmd = [vcvarsall_path, msvc_arch]
+ msvc_env = get_environment_from_batch_command(vcvarsall_cmd)
+ msvc_env_paths = os.pathsep.join([msvc_env[k] for k in msvc_env if k.upper() == 'PATH']).split(os.pathsep)
+ msvc_env_without_paths = dict([(k, msvc_env[k]) for k in msvc_env if k.upper() != 'PATH'])
+
+ # Extend os.environ with MSVC env
+ logger.info("Initializing MSVC env...")
+ update_env_path(msvc_env_paths, logger)
+ for k in sorted(msvc_env_without_paths):
+ v = msvc_env_without_paths[k]
+ logger.info("Inserting \"%s = %s\" to environment" % (k, v))
+ os.environ[k] = v
+ logger.info("Done initializing MSVC env")
+
+
def copyfile(src, dst, logger=None, force=True, vars=None, subst_content=False):
if vars is not None:
src = src.format(**vars)