[Python-modules-commits] [bdist-nsi] 01/12: import bdist-nsi_0.1.5.orig.tar.gz
Dominik George
natureshadow-guest at moszumanska.debian.org
Sun Apr 23 19:24:11 UTC 2017
This is an automated email from the git hooks/post-receive script.
natureshadow-guest pushed a commit to branch master
in repository bdist-nsi.
commit ab833ee8e6bf4fdb6f05df80c8a185683a6c9c44
Author: Dominik George <nik at naturalnet.de>
Date: Sun Apr 23 20:20:16 2017 +0200
import bdist-nsi_0.1.5.orig.tar.gz
---
LICENSE.rst | 31 +
PKG-INFO | 82 ++
README.rst | 62 ++
bdist_nsi/__init__.py | 0
bdist_nsi/bdist_nsi.py | 1872 ++++++++++++++++++++++++++++++++++
bdist_nsi/python-install-150x57.bmp | Bin 0 -> 25818 bytes
bdist_nsi/python-install-164x314.bmp | Bin 0 -> 154542 bytes
bdist_nsi/python-install.ico | Bin 0 -> 32038 bytes
bdist_nsi/python-uninstall.ico | Bin 0 -> 32038 bytes
setup.py | 36 +
10 files changed, 2083 insertions(+)
diff --git a/LICENSE.rst b/LICENSE.rst
new file mode 100755
index 0000000..f5dc120
--- /dev/null
+++ b/LICENSE.rst
@@ -0,0 +1,31 @@
+Copyright © 2009, bdist_nsi contributors
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of the bdist_nsi project nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100755
index 0000000..5f519f5
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,82 @@
+Metadata-Version: 1.1
+Name: bdist_nsi
+Version: 0.1.5
+Summary: Create NSIS windows installers for Python modules.
+Home-page: http://bdist-nsi.sourceforge.net/
+Author: Amorilia
+Author-email: amorilia at users.sourceforge.net
+License: BSD
+Description: bdist_nsi
+ =========
+
+ The bdist_nsi module extends Python's distutils module with a bdist_nsi
+ setup command to create binary Windows installers for Python modules,
+ based on NSIS. Thereby, bdist_nsi brings all the features of NSIS to
+ Windows installers for Python modules, such as silent install, modern
+ user interface, and internationalization.
+
+ In action
+ ---------
+
+ Take a look at the `screenshots <http://sourceforge.net/project/screenshots.php?group_id=139858>`_.
+
+ What you need
+ -------------
+
+ Besides Python and the bdist_nsi module, you will need `NSIS <http://nsis.sourceforge.net/>`_. It can be run under windows and linux (see NSIS forum for instructions).
+
+ Installation
+ ------------
+
+ The latest version can always be downloaded from https://sourceforge.net/projects/bdist-nsi/files.
+
+ To install from source, simply run::
+
+ python setup.py install
+
+ Usage
+ -----
+
+ Add ``bdist_nsi`` option to your setup.py file.
+
+ In your projects setup.py::
+
+ try:
+ import bdist_nsi
+ except ImportError:
+ pass
+
+ nsis_options = {} # your nsis options
+ setup(
+ name='your application name',
+ version='0.0.x',
+ author='your name',
+ author_email='your email',
+ url='http://yourdomain.com/',
+ options={'bdist_nsi': nsis_options, },
+ license='your license',) # your setup options
+
+ You can create installer ``python setup.py bdist_nsi`` command.
+
+ If the makensis executable is not installed in one of the usual
+ locations (``/usr/bin``, ``C:\Program Files\NSIS``, or
+ ``C:\Program Files (x86)\NSIS``), then you can specify the
+ NSIS folder with the *--nsis-dir* option, or just add *-k* to have a look
+ at the temporary generated files.
+
+ Development
+ -----------
+
+ Development happens at github, http://github.com/amorilia/bdist_nsi/. Fork at will!
+
+Platform: any
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Natural Language :: English
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
+Classifier: Topic :: System :: Software Distribution
+Classifier: Topic :: Software Development :: Code Generators
diff --git a/README.rst b/README.rst
new file mode 100755
index 0000000..8d1a29e
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,62 @@
+bdist_nsi
+=========
+
+The bdist_nsi module extends Python's distutils module with a bdist_nsi
+setup command to create binary Windows installers for Python modules,
+based on NSIS. Thereby, bdist_nsi brings all the features of NSIS to
+Windows installers for Python modules, such as silent install, modern
+user interface, and internationalization.
+
+In action
+---------
+
+Take a look at the `screenshots <http://sourceforge.net/project/screenshots.php?group_id=139858>`_.
+
+What you need
+-------------
+
+Besides Python and the bdist_nsi module, you will need `NSIS <http://nsis.sourceforge.net/>`_. It can be run under windows and linux (see NSIS forum for instructions).
+
+Installation
+------------
+
+The latest version can always be downloaded from https://sourceforge.net/projects/bdist-nsi/files.
+
+To install from source, simply run::
+
+ python setup.py install
+
+Usage
+-----
+
+Add ``bdist_nsi`` option to your setup.py file.
+
+In your projects setup.py::
+
+ try:
+ import bdist_nsi
+ except ImportError:
+ pass
+
+ nsis_options = {} # your nsis options
+ setup(
+ name='your application name',
+ version='0.0.x',
+ author='your name',
+ author_email='your email',
+ url='http://yourdomain.com/',
+ options={'bdist_nsi': nsis_options, },
+ license='your license',) # your setup options
+
+You can create installer ``python setup.py bdist_nsi`` command.
+
+If the makensis executable is not installed in one of the usual
+locations (``/usr/bin``, ``C:\Program Files\NSIS``, or
+``C:\Program Files (x86)\NSIS``), then you can specify the
+NSIS folder with the *--nsis-dir* option, or just add *-k* to have a look
+at the temporary generated files.
+
+Development
+-----------
+
+Development happens at github, http://github.com/amorilia/bdist_nsi/. Fork at will!
diff --git a/bdist_nsi/__init__.py b/bdist_nsi/__init__.py
new file mode 100755
index 0000000..e69de29
diff --git a/bdist_nsi/bdist_nsi.py b/bdist_nsi/bdist_nsi.py
new file mode 100755
index 0000000..ed1564a
--- /dev/null
+++ b/bdist_nsi/bdist_nsi.py
@@ -0,0 +1,1872 @@
+"""bdist_nsi.bdist_nsi
+
+Implements the Distutils 'bdist_nsi' command: create a Windows NSIS installer.
+"""
+
+# Created 2005/05/24, j-cg , inspired by the bdist_wininst of the python
+# distribution
+
+# June/July 2009 (Amorilia):
+# - further developed, 2to3, blender, maya
+
+# December 2009/January 2010 (Amorilia):
+# - added AppInfo classes for better implementation
+# - added proper 64 bit support
+
+# April 2010 (Amorilia):
+# - added support for native Python 3 packages (without 2to3)
+
+# August 2010 (Surgo)
+# - added distutils command option
+
+# September 2011 (Amorilia)
+# - added support for Blender 2.5x
+# - added productkey option
+
+import sys, os, string
+import subprocess
+from distutils.core import Command
+from distutils.util import get_platform
+from distutils.dir_util import create_tree, remove_tree
+from distutils.errors import *
+from distutils.sysconfig import get_python_version
+from distutils import log
+from distutils.spawn import spawn
+from distutils.command.install import WINDOWS_SCHEME
+
+from distutils import command
+command.__all__.append('bdist_nsi')
+sys.modules['distutils.command.bdist_nsi'] = sys.modules[__name__]
+
+class RegKey:
+ """Stores the location of a registry key."""
+
+ view = None
+ """Registry view (32 or 64)."""
+
+ root = None
+ """Root of the key (HKLM, HKCU, and so on)."""
+
+ key = None
+ """Key."""
+
+ name = None
+ """Name."""
+
+ def __init__(self, view=None, root=None, key=None, name=None):
+ """Initialize key."""
+ self.view = view
+ self.root = root
+ self.key = key
+ self.name = name
+
+ def __repr__(self):
+ r"""String representation.
+
+ >>> RegKey(view=32, root="HKLM", key=r"Software\BlenderFoundation",
+ ... name="Install_Dir")
+ RegKey(view=32, root='HKLM', key='Software\\BlenderFoundation', name='Install_Dir')
+ """
+ return(
+ "RegKey(view=%s, root=%s, key=%s, name=%s)"
+ % (repr(self.view), repr(self.root),
+ repr(self.key), repr(self.name)))
+
+class AppInfo:
+ """Information of an application which integrates Python."""
+
+ name = None
+ """Name of the application."""
+
+ version = None
+ """The version of the application."""
+
+ label = None
+ """A label which uniquely identifies the application."""
+
+ regkeys = None # list of registry keys
+ """List of registry keys which are checked to determine whether the
+ application is installed or not, and to get its installation path.
+ """
+
+ py_version = None # 2.4, 2.5, ...
+ """A string of the form 'x.x' which determines the Python version
+ for this application.
+ """
+
+ VERSIONS = []
+ """List of (version, py_version, bits) tuples."""
+
+ def __init__(self, name=None, label=None, regkeys=None, py_version=None):
+ """Initialize application information."""
+ self.name = name
+ self.label = label
+ self.regkeys = regkeys
+ self.py_version = py_version
+
+ def __repr__(self):
+ r"""Return string representation.
+
+ >>> regkey = RegKey(view=32, root="HKLM",
+ ... key=r"Software\BlenderFoundation",
+ ... name="Install_Dir")
+ >>> AppInfo(name="Test", label="test", regkeys=[regkey],
+ ... py_version="3.2")
+ AppInfo(name='Test', label='test', regkeys=[RegKey(view=32, root='HKLM', key='Software\\BlenderFoundation', name='Install_Dir')], py_version='3.2')
+ """
+ return (
+ "AppInfo(name=%s, label=%s, regkeys=%s, py_version=%s)"
+ % (repr(self.name), repr(self.label), repr(self.regkeys),
+ repr(self.py_version)))
+
+ @property
+ def bits(self):
+ """32 or 64.
+
+ >>> PythonAppInfo(version="2.7", bits=64).bits
+ 64
+ >>> PythonAppInfo(version="3.1", bits=32).bits
+ 32
+ >>> MayaAppInfo(version="2009", py_version="2.5", bits=64).bits
+ 64
+ >>> MayaAppInfo(version="2009", py_version="2.5", bits=32).bits
+ 32
+ >>> BlenderAppInfo(version="2.4x", py_version="2.6", bits=64).bits
+ 64
+ >>> BlenderAppInfo(version="2.4x", py_version="2.6", bits=32).bits
+ 32
+ """
+ return max(regkey.view for regkey in self.regkeys)
+
+ def macro_get_registry_keys(self):
+ r"""Returns NSIS script which defines a macro which jumps to
+ if_found if the registry key is found in any of the listed
+ registry keys, storing the result in $PATH_${label}.
+
+ >>> regkey1 = RegKey(view=32, root="HKLM",
+ ... key=r"Software\BlenderFoundation",
+ ... name="Install_Dir")
+ >>> regkey2 = RegKey(view=64, root="HKCU",
+ ... key=r"SOFTWARE\Autodesk\Maya\2008\Setup\InstallPath",
+ ... name="MAYA_INSTALL_LOCATION")
+ >>> regkey3 = RegKey(view=32, root="HKCR",
+ ... key="NSIS.Header",
+ ... name="DefaultIcon")
+ >>> app = AppInfo(name="Test", label="test",
+ ... regkeys=[regkey1, regkey2, regkey3],
+ ... py_version='3.2')
+ >>> print("\n".join(app.macro_get_registry_keys()))
+ !macro GET_REGISTRY_KEYS_test if_found
+ !insertmacro GET_REGISTRY_KEY $PATH_test 32 HKLM "Software\BlenderFoundation" "Install_Dir" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_test 64 HKCU "SOFTWARE\Autodesk\Maya\2008\Setup\InstallPath" "MAYA_INSTALL_LOCATION" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_test 32 HKCR "NSIS.Header" "DefaultIcon" ${if_found}
+ !macroend
+ """
+ yield "!macro GET_REGISTRY_KEYS_%s if_found" % self.label
+ for regkey in self.regkeys:
+ yield (
+ ' !insertmacro GET_REGISTRY_KEY $PATH_%s %s %s "%s" "%s"'
+ ' ${if_found}'
+ % (self.label,
+ regkey.view, regkey.root, regkey.key, regkey.name))
+ yield "!macroend"
+
+ def macro_get_path_extra_check(self):
+ """Returns NSIS script which validates a given path."""
+ # default: do nothing
+ return
+
+ def insertmacro_variables(self):
+ """Define variables."""
+ yield "var PATH_%s" % self.label
+
+ def macro_section_extra(self):
+ """Define section install variables $0 to $5 (see the
+ implementation of PythonAppInfo.macro_section_extra for an
+ example).
+ """
+ raise NotImplementedError
+
+ @staticmethod
+ def make_version_bits_tuples(versions, bits=None):
+ """Convert string versions into tuple versions.
+
+ >>> list(AppInfo.make_version_bits_tuples(["2.5", "3.1"]))
+ [('2.5', 32), ('2.5', 64), ('3.1', 32), ('3.1', 64)]
+ >>> list(AppInfo.make_version_bits_tuples(["2.5", "3.1"], bits=64))
+ [('2.5', 64), ('3.1', 64)]
+ """
+ for version in versions:
+ if bits is None:
+ for bits_ in [32, 64]:
+ yield version, bits_
+ else:
+ yield version, bits
+
+ @classmethod
+ def make_apps(cls, versions, bits=None):
+ """Get all applications of maya that match given python versions,
+ which is a list of the form ["2.3", "2.4"] etc.
+
+ >>> MayaAppInfo.make_apps(["2.6"])
+ [MayaAppInfo(version='2010', py_version='2.6', bits=32), MayaAppInfo(version='2010', py_version='2.6', bits=64)]
+ >>> BlenderAppInfo.make_apps(["2.6"])
+ [BlenderAppInfo(version='2.4x', py_version='2.6', bits=32)]
+ """
+ version_bits = list(
+ cls.make_version_bits_tuples(versions, bits))
+ return [
+ cls(*args) for args in cls.VERSIONS
+ if tuple(args[-2:]) in version_bits]
+
+class PythonAppInfo(AppInfo):
+ r"""Python application info.
+
+ >>> print("\n".join(PythonAppInfo(version="2.5", bits=32).macro_get_registry_keys()))
+ !macro GET_REGISTRY_KEYS_python_2_5_32 if_found
+ !insertmacro GET_REGISTRY_KEY $PATH_python_2_5_32 32 HKLM "SOFTWARE\Python\PythonCore\2.5\InstallPath" "" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_python_2_5_32 32 HKCU "SOFTWARE\Python\PythonCore\2.5\InstallPath" "" ${if_found}
+ !macroend
+ """
+
+ def __init__(self, version=None, bits=None):
+ r"""Constructor.
+
+ >>> print(AppInfo.__repr__(PythonAppInfo(version="2.7", bits=64)))
+ AppInfo(name='Python 2.7 (64 bit)', label='python_2_7_64', regkeys=[RegKey(view=64, root='HKLM', key='SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath', name=''), RegKey(view=64, root='HKCU', key='SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath', name='')], py_version='2.7')
+ >>> PythonAppInfo(version="2.7", bits=64).py_version
+ '2.7'
+ """
+ self.py_version = version
+ self.name = "Python %s (%i bit)" % (self.py_version, bits)
+ self.label = "python_%s_%i" % (self.py_version.replace(".", "_"), bits)
+ key = r"SOFTWARE\Python\PythonCore\%s\InstallPath" % self.py_version
+ self.regkeys = [
+ RegKey(view=bits, root="HKLM", key=key, name=""),
+ RegKey(view=bits, root="HKCU", key=key, name=""),
+ ]
+
+ def __repr__(self):
+ """String representation.
+
+ >>> PythonAppInfo(version="2.7", bits=64)
+ PythonAppInfo(version='2.7', bits=64)
+ """
+ return ("PythonAppInfo(version=%s, bits=%i)"
+ % (repr(self.py_version), self.bits))
+
+ @classmethod
+ def make_apps(cls, versions=None, bits=None):
+ """Get all applications of python that match versions, which is
+ a list of the form ["2.3", "2.4"] etc.
+
+ >>> PythonAppInfo.make_apps(["2.1", "2.2"])
+ [PythonAppInfo(version='2.1', bits=32), PythonAppInfo(version='2.1', bits=64), PythonAppInfo(version='2.2', bits=32), PythonAppInfo(version='2.2', bits=64)]
+ >>> PythonAppInfo.make_apps(["2.3", "3.0"], bits=32)
+ [PythonAppInfo(version='2.3', bits=32), PythonAppInfo(version='3.0', bits=32)]
+ """
+ version_bits = cls.make_version_bits_tuples(versions, bits)
+ return [PythonAppInfo(version=version, bits=bits)
+ for version, bits in version_bits]
+
+ def macro_get_path_extra_check(self):
+ """Returns NSIS script which validates the python path."""
+ yield '!macro GET_PATH_EXTRA_CHECK_%s' % self.label
+ yield ' !insertmacro GET_PATH_EXTRA_CHECK_PYTHON %s' % self.label
+ yield '!macroend'
+
+ def macro_section_extra(self):
+ """Returns NSIS script which sets up the installation variables
+ in the section definition.
+ """
+ yield '!macro SECTION_EXTRA_%s' % self.label
+ yield (' !insertmacro SECTION_EXTRA_PYTHON %s %s'
+ % (self.label, self.py_version))
+ yield '!macroend'
+
+class MayaAppInfo(AppInfo):
+ r"""Maya application info.
+
+ >>> print("\n".join(MayaAppInfo(version=2008, py_version="2.5", bits=32).macro_get_registry_keys()))
+ !macro GET_REGISTRY_KEYS_maya_2008_32 if_found
+ !insertmacro GET_REGISTRY_KEY $PATH_maya_2008_32 32 HKLM "SOFTWARE\Autodesk\Maya\2008\Setup\InstallPath" "MAYA_INSTALL_LOCATION" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_maya_2008_32 32 HKCU "SOFTWARE\Autodesk\Maya\2008\Setup\InstallPath" "MAYA_INSTALL_LOCATION" ${if_found}
+ !macroend
+ >>> print("\n".join(MayaAppInfo(version=2008, py_version="2.5", bits=64).macro_get_registry_keys()))
+ !macro GET_REGISTRY_KEYS_maya_2008_64 if_found
+ !insertmacro GET_REGISTRY_KEY $PATH_maya_2008_64 32 HKLM "SOFTWARE\Autodesk\Maya\2008-x64\Setup\InstallPath" "MAYA_INSTALL_LOCATION" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_maya_2008_64 32 HKCU "SOFTWARE\Autodesk\Maya\2008-x64\Setup\InstallPath" "MAYA_INSTALL_LOCATION" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_maya_2008_64 64 HKLM "SOFTWARE\Autodesk\Maya\2008-x64\Setup\InstallPath" "MAYA_INSTALL_LOCATION" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_maya_2008_64 64 HKCU "SOFTWARE\Autodesk\Maya\2008-x64\Setup\InstallPath" "MAYA_INSTALL_LOCATION" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_maya_2008_64 64 HKLM "SOFTWARE\Autodesk\Maya\2008\Setup\InstallPath" "MAYA_INSTALL_LOCATION" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_maya_2008_64 64 HKCU "SOFTWARE\Autodesk\Maya\2008\Setup\InstallPath" "MAYA_INSTALL_LOCATION" ${if_found}
+ !macroend
+ """
+
+ VERSIONS = [
+ ("2008", "2.5", 32),
+ ("2008", "2.5", 64),
+ ("2009", "2.5", 32),
+ ("2009", "2.5", 64),
+ ("2010", "2.6", 32),
+ ("2010", "2.6", 64),
+ ("2011", "2.6", 32),
+ ("2011", "2.6", 64),
+ ]
+ """All versions of maya, as (version, py_version, bits)."""
+
+ def __init__(self, version=None, py_version=None, bits=None):
+ self.version = version
+ self.py_version = py_version
+ self.name = "Maya %s (%i bit)" % (version, bits)
+ self.label = "maya_%s_%i" % (version, bits)
+ key = (
+ r"SOFTWARE\Autodesk\Maya\%s\Setup\InstallPath" % version)
+ key_x64 = (
+ r"SOFTWARE\Autodesk\Maya\%s-x64\Setup\InstallPath" % version)
+ name = "MAYA_INSTALL_LOCATION"
+ if bits == 32:
+ self.regkeys = [
+ RegKey(view=bits, root="HKLM", key=key, name=name),
+ RegKey(view=bits, root="HKCU", key=key, name=name),
+ ]
+ else:
+ self.regkeys = [
+ RegKey(view=32, root="HKLM", key=key_x64, name=name),
+ RegKey(view=32, root="HKCU", key=key_x64, name=name),
+ RegKey(view=64, root="HKLM", key=key_x64, name=name),
+ RegKey(view=64, root="HKCU", key=key_x64, name=name),
+ RegKey(view=64, root="HKLM", key=key, name=name),
+ RegKey(view=64, root="HKCU", key=key, name=name),
+ ]
+
+ def __repr__(self):
+ """String representation.
+
+ >>> MayaAppInfo(version="2009", py_version="2.5", bits=64)
+ MayaAppInfo(version='2009', py_version='2.5', bits=64)
+ """
+ return ("MayaAppInfo(version=%s, py_version=%s, bits=%i)"
+ % (repr(self.version), repr(self.py_version), self.bits))
+
+ def macro_get_path_extra_check(self):
+ """Returns NSIS script which validates the python path."""
+ yield '!macro GET_PATH_EXTRA_CHECK_%s' % self.label
+ yield ' !insertmacro GET_PATH_EXTRA_CHECK_MAYA %s' % self.label
+ yield '!macroend'
+
+ def macro_section_extra(self):
+ """Returns NSIS script which sets up the installation variables
+ in the section definition.
+ """
+ yield '!macro SECTION_EXTRA_%s' % self.label
+ yield (' !insertmacro SECTION_EXTRA_MAYA %s %s'
+ % (self.label, self.py_version))
+ yield '!macroend'
+
+class BlenderAppInfo(AppInfo):
+ r"""Blender application info.
+
+ >>> print("\n".join(BlenderAppInfo(version="2.4x", py_version="2.6", bits=32).macro_get_registry_keys()))
+ !macro GET_REGISTRY_KEYS_blender_2_4x_2_6_32 if_found
+ !insertmacro GET_REGISTRY_KEY $PATH_blender_2_4x_2_6_32 32 HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" ${if_found}
+ !insertmacro GET_REGISTRY_KEY $PATH_blender_2_4x_2_6_32 32 HKCU "SOFTWARE\BlenderFoundation" "Install_Dir" ${if_found}
+ !macroend
+ """
+
+ VERSIONS = [
+ ("2.4x", "2.3", 32),
+ ("2.4x", "2.4", 32),
+ ("2.4x", "2.5", 32),
+ ("2.4x", "2.6", 32),
+ ]
+ """All versions of blender, as (version, py_version, bits)."""
+
+ def __init__(self, version=None, py_version=None, bits=None):
+ self.version = version
+ self.name = ("Blender %s (Python %s, %i bit)"
+ % (version, py_version, bits))
+ self.label = (("blender_%s_%s_%i" % (version, py_version, bits))
+ .replace(".", "_"))
+ self.py_version = py_version
+ key = r"SOFTWARE\BlenderFoundation"
+ name = r"Install_Dir"
+ self.regkeys = [
+ RegKey(view=bits, root="HKLM", key=key, name=name),
+ RegKey(view=bits, root="HKCU", key=key, name=name),
+ ]
+
+ def __repr__(self):
+ """String representation.
+
+ >>> BlenderAppInfo(version="2.4x", py_version="2.6", bits=64)
+ BlenderAppInfo(version='2.4x', py_version='2.6', bits=64)
+ """
+ return ("%s(version=%s, py_version=%s, bits=%s)"
+ % (self.__class__.__name__, repr(self.version),
+ repr(self.py_version), repr(self.bits)))
+
+ def insertmacro_variables(self):
+ """Define variables."""
+ yield "var PATH_%s" % self.label
+ yield "var SCRIPTS_%s" % self.label
+
+ def macro_get_path_extra_check(self):
+ """Returns NSIS script which validates the python path."""
+ yield '!macro GET_PATH_EXTRA_CHECK_%s' % self.label
+ yield (' !insertmacro GET_PATH_EXTRA_CHECK_BLENDER %s %s'
+ % (self.label, self.py_version))
+ yield '!macroend'
+
+ def macro_section_extra(self):
+ """Returns NSIS script which sets up the installation variables
+ in the section definition.
+ """
+ yield '!macro SECTION_EXTRA_%s' % self.label
+ yield (' !insertmacro SECTION_EXTRA_BLENDER %s %s'
+ % (self.label, self.py_version))
+ yield '!macroend'
+
+ @staticmethod
+ def insertmacro_push_blender_python_version(target_versions):
+ """Push the python version, for use in the
+ CHECK_BLENDER_PYTHON_VERSION macro.
+ """
+ if not target_versions:
+ raise ValueError(
+ "target_versions must contain at least one element")
+ yield ' ; note: if user installs a newer version of Blender over'
+ yield ' ; an older version then two python dll files could co-exist;'
+ yield ' ; therefore, check the higher version numbers first'
+ versions = sorted(target_versions, reverse=True)
+ yield (' ${If} ${FileExists} "$PATH_${label}\python%s.dll"'
+ % versions[0].replace(".", ""))
+ yield ' Push "%s"' % versions[0]
+ for version in versions[1:]:
+ yield (' ${ElseIf} ${FileExists} "$PATH_${label}\python%s.dll"'
+ % version.replace(".", ""))
+ yield ' Push "%s"' % version
+ yield ' ${Else}'
+ yield ' Push ""'
+ yield ' ${EndIf}'
+
+# blender versions from 25x onwards embed python
+class Blender25xAppInfo(BlenderAppInfo):
+ VERSIONS = [
+ ("2.59", "3.2", 32),
+ ("2.59", "3.2", 64),
+ ("2.60", "3.2", 32),
+ ("2.60", "3.2", 64),
+ ("2.61", "3.2", 32),
+ ("2.61", "3.2", 64),
+ ("2.62", "3.2", 32),
+ ("2.62", "3.2", 64),
+ ("2.63", "3.2", 32),
+ ("2.63", "3.2", 64),
+ ("2.64", "3.2", 32),
+ ("2.64", "3.2", 64),
+ ]
+ """All versions of blender, as (version, py_version, bits)."""
+
+ def insertmacro_variables(self):
+ """Define variables."""
+ return AppInfo.insertmacro_variables(self) # only PATH_${label}
+
+ def macro_get_path_extra_check(self):
+ """Returns NSIS script which validates the python path."""
+ yield '!macro GET_PATH_EXTRA_CHECK_%s' % self.label
+ yield (' !insertmacro GET_PATH_EXTRA_CHECK_BLENDER_25X %s %s %s'
+ % (self.label, self.py_version, self.version))
+ yield '!macroend'
+
+ def macro_section_extra(self):
+ """Returns NSIS script which sets up the installation variables
+ in the section definition.
+ """
+ yield '!macro SECTION_EXTRA_%s' % self.label
+ yield (' !insertmacro SECTION_EXTRA_BLENDER_25X %s %s %s'
+ % (self.label, self.py_version, self.version))
+ yield '!macroend'
+
+class bdist_nsi(Command):
+
+ description = "create an executable installer for MS Windows, using NSIS"
+
+ user_options = [('bdist-dir=', None,
+ "temporary directory for creating the distribution"),
+ ('plat-name=', 'p',
+ "platform name to embed in generated filenames "
+ "(default: %s)" % get_platform()),
+ ('keep-temp', 'k',
+ "keep the pseudo-installation tree around after " +
+ "creating the distribution archive"),
+ ('target-version=', None,
+ "require a specific python version" +
+ " on the target system"),
+ ('no-target-compile', 'c',
+ "do not compile .py to .pyc on the target system"),
+ ('no-target-optimize', 'o',
+ "do not compile .py to .pyo (optimized)"
+ "on the target system"),
+ ('dist-dir=', 'd',
+ "directory to put final built distributions in"),
+ ('nsis-dir=', 'n',
+ "directory of nsis compiler"),
+ ('bitmap=', 'b',
+ "bitmap (size 164x314) to use for the " +
+ "installer instead of python-powered logo"),
+ ('headerbitmap=', None,
+ "header bitmap (size 150x57) to use for the " +
+ "installer instead of python-powered logo"),
+ ('title=', 't',
+ "title to display on the installer background instead of default"),
+ ('skip-build', None,
+ "skip rebuilding everything (for testing/debugging)"),
+ ('run2to3', None,
+ "run 2to3 on 3.x installs"),
+ ('msvc2005', None,
+ "check if msvc 2005 redistributable package is installed"),
+ ('msvc2005sp1', None,
+ "check if msvc 2005 sp1 redistributable package is installed"),
+ ('msvc2008', None,
+ "check if msvc 2008 redistributable package is installed"),
+ ('msvc2008sp1', None,
+ "check if msvc 2008 sp1 redistributable package is installed"),
+ ('nshextra=', None,
+ "additional nsis header file to include at the start of the file, and which must define the following macros (they can be empty if not used): InstallFilesExtra, UninstallFilesExtra, PostExtra, and UnPostExtra"),
+ ('target-versions=', None,
+ "comma separated list of python versions (only for pure packages)"),
+ ('maya', None,
+ "include (compatible) Maya targets in installer"),
+ ('blender', None,
+ "include (compatible) Blender targets in installer"),
+ ('debug', None,
+ "debug mode (only use if you know what you are doing)"),
+ ('productkey=', None,
+ "product key"
+ " used for install registry key"
+ " and install folder; useful for allowing"
+ " different versions"
+ " of the same package installed simultaneously"),
+ ]
+
+ boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize',
+ 'skip-build', 'run2to3', 'msvc2005', 'msvc2005sp1',
+ 'msvc2008', 'msvc2008sp1', 'maya', 'blender', 'debug']
+
+ def initialize_options (self):
+ self.bdist_dir = None
+ self.plat_name = None
+ self.keep_temp = 0
+ self.no_target_compile = 0
+ self.no_target_optimize = 0
+ self.target_version = None
+ self.dist_dir = None
+ self.nsis_dir = None
+ self.bitmap = None
+ self.headerbitmap = None
+ self.title = None
+ self.skip_build = 0
+ self.run2to3 = 0
+ self.msvc2005 = 0
+ self.msvc2005sp1 = 0
+ self.msvc2008 = 0
+ self.msvc2008sp1 = 0
+ self.nshextra = None
+ self.target_versions = None
+ self.maya = 0
+ self.blender = 0
+ self.debug = 0
+ self.productkey = None
+
+ # initialize_options()
+
+
+ def finalize_options (self):
+ if self.bdist_dir is None:
+ if self.skip_build and self.plat_name:
+ # If build is skipped and plat_name is overridden, bdist will
+ # not see the correct 'plat_name' - so set that up manually.
+ bdist = self.distribution.get_command_obj('bdist')
+ bdist.plat_name = self.plat_name
+ # next the command will be initialized using that name
+ bdist_base = self.get_finalized_command('bdist').bdist_base
+ self.bdist_dir = os.path.join(bdist_base, 'nsi')
+ if not self.target_version:
+ self.target_version = ""
+ if not self.skip_build and self.distribution.has_ext_modules():
+ short_version = get_python_version()
+ if self.target_version and self.target_version != short_version:
+ raise DistutilsOptionError("target version can only be %s, or the '--skip_build'" \
+ " option must be specified" % (short_version,))
+ self.target_version = short_version
+
+ # find makensis executable
+ if self.nsis_dir is None:
+ pathlist = os.environ.get('PATH', os.defpath).split(os.pathsep)
+ # common locations
+ pathlist.extend([
+ ".",
+ "C:\\Program Files\\NSIS",
+ "C:\\Program Files (x86)\\NSIS"])
+ else:
+ pathlist = [self.nsis_dir]
+ for path in pathlist:
+ # windows executable?
+ makensis = os.path.join(path, "makensis.exe")
+ if os.access(makensis, os.X_OK):
+ self.nsis_dir = makensis
+ break
+ # linux executable? (for instance on Fedora 11)
+ makensis = os.path.join(path, "makensis")
+ if os.access(makensis, os.X_OK):
+ self.nsis_dir = makensis
+ break
+ else:
+ print(
+ "Error: makensis executable not found, "
+ "add NSIS directory to the path or specify it "
+ "with --nsis-dir")
+ self.nsis_dir = None
+
+ if not self.headerbitmap:
+ self.headerbitmap = os.path.join(os.path.dirname(__file__),
+ "python-install-150x57.bmp").replace("/", "\\")
+ else:
+ self.headerbitmap = self.abspath(self.headerbitmap)
+ if not self.bitmap:
+ self.bitmap = os.path.join(os.path.dirname(__file__),
+ "python-install-164x314.bmp").replace("/", "\\")
+ else:
+ self.bitmap = self.abspath(self.bitmap)
+
+ if self.nshextra:
+ self.nshextra = self.abspath(self.nshextra)
+
+ self.set_undefined_options('bdist',
+ ('dist_dir', 'dist_dir'),
+ ('plat_name', 'plat_name'),
+ ('nsis_dir', 'nsis_dir'),
+ )
+
+ # finalize_options()
+
+ def abspath(self, filename):
+ # absolute path with windows separator
+ return os.path.abspath(filename).replace('/', '\\')
+
+ def run (self):
+ if (sys.platform != "win32" and
+ (self.distribution.has_ext_modules() or
+ self.distribution.has_c_libraries())):
+ raise DistutilsPlatformError \
+ ("distribution contains extensions and/or C libraries; "
+ "must be compiled on a Windows 32 platform")
+
+ if not self.skip_build:
+ self.run_command('build')
+
+ install = self.reinitialize_command('install', reinit_subcommands=1)
+ install.root = self.bdist_dir
+ install.skip_build = self.skip_build
+ install.warn_dir = 0
+ install.plat_name = self.plat_name
+
+ install_lib = self.reinitialize_command('install_lib')
+ # we do not want to include pyc or pyo files
+ install_lib.compile = 0
+ install_lib.optimize = 0
+
+ if self.distribution.has_ext_modules():
+ # If we are building an installer for a Python version other
+ # than the one we are currently running, then we need to ensure
+ # our build_lib reflects the other Python version rather than ours.
+ # Note that for target_version!=sys.version, we must have skipped the
+ # build step, so there is no issue with enforcing the build of this
+ # version.
+ target_version = self.target_version
+ if not target_version:
+ assert self.skip_build, "Should have already checked this"
+ target_version = sys.version[0:3]
+ plat_specifier = ".%s-%s" % (self.plat_name, target_version)
+ build = self.get_finalized_command('build')
+ build.build_lib = os.path.join(build.build_base,
+ 'lib' + plat_specifier)
+ # use windows installation scheme
+ for key in WINDOWS_SCHEME.keys():
+ value = WINDOWS_SCHEME[key].replace("$base", "_python")
+ setattr(install,
+ 'install_' + key,
+ value)
+
+ log.info("installing to %s", self.bdist_dir)
+ install.ensure_finalized()
+ install.run()
+
+ self.build_nsi()
+
+ if not self.keep_temp:
+ remove_tree(self.bdist_dir, dry_run=self.dry_run)
+
+ # run()
+
+
+ def build_nsi(self):
+ if self.target_version.upper() not in ["","ANY"]:
+ nsiscript = get_nsi(target_versions=[self.target_version])
+ elif self.target_versions:
+ nsiscript = get_nsi(target_versions=self.target_versions.split(","))
+ elif sys.version_info[0] < 3:
+ # python 2.x
+ target_versions = ["2.3", "2.4", "2.5", "2.6", "2.7"]
+ if self.run2to3:
+ target_versions.extend(["3.0", "3.1", "3.2"])
+ nsiscript = get_nsi(target_versions=target_versions)
+ else:
+ # python 3.x
+ target_versions = ["3.0", "3.1", "3.2"]
+ # disable 2to3
+ self.run2to3 = 0
+ nsiscript = get_nsi(target_versions=target_versions)
+ metadata = self.distribution.metadata
+
+ def get_full_author(key):
+ # full author and maintainer info?
+ author = key
+ author_email = "%s_email" % author
+ if (getattr(metadata, author, "")
+ and getattr(metadata, author_email, "")):
+ return '@%s@ <@%s@>' % (author, author_email)
+ elif getattr(metadata, author, ""):
+ return '@%s@' % author
+ elif getattr(metadata, author_email, ""):
+ return '@%s@' % author_email
+ else:
+ return ''
+
+ annotated_author = get_full_author("author")
+ if annotated_author:
+ nsiscript = nsiscript.replace(
+ "@annotated_author@",
+ "Author: %s$\\r$\\n" % annotated_author)
+ annotated_maintainer = get_full_author("maintainer")
+ if annotated_maintainer:
+ nsiscript = nsiscript.replace(
+ "@annotated_maintainer@",
+ "Maintainer: %s$\\r$\\n" % annotated_maintainer)
+
+ for name in ["author", "author_email", "maintainer",
+ "maintainer_email", "description", "name", "url",
+ "version", "license"]:
+ data = getattr(metadata, name, "")
+ if data:
+ nsiscript = nsiscript.replace('@has'+name+'@', "")
+ nsiscript = nsiscript.replace('@'+name+'@',data)
+ nsiscript = nsiscript.replace(
+ '@annotated_'+name+'@',
+ "%s: %s$\\r$\\n"
+ % (name.replace("_", " ").capitalize(), data))
+ else:
+ nsiscript = nsiscript.replace(
+ '@annotated_'+name+'@', '')
+ nsiscript = nsiscript.replace('@has'+name+'@', ";")
+ # XXX todo: use the moduleinfo file in the installer?
+
+ for licensefile in ['license', 'license.txt', 'license.rst',
+ 'LICENSE', 'LICENSE.txt', 'LICENSE.rst',
+ 'LICENSE.TXT', 'LICENSE.RST']:
+ if os.path.exists(licensefile):
+ nsiscript=nsiscript.replace('@haslicensefile@', "")
+ nsiscript=nsiscript.replace('@licensefile@',
... 1150 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/bdist-nsi.git
More information about the Python-modules-commits
mailing list