Exemple #1
0
 def run(self):
     if not self.skip_build:
         self.run_command('build')
     install = self.reinitialize_command('install', reinit_subcommands=1)
     install.prefix = self.bdist_dir
     install.skip_build = self.skip_build
     install.warn_dir = 0
     distutils.log.info("installing to %s", self.bdist_dir)
     install.ensure_finalized()
     install.run()
     self.mkpath(self.dist_dir)
     fullname = self.distribution.get_fullname()
     if os.path.exists(self.target_name):
         os.unlink(self.target_name)
     metadata = self.distribution.metadata
     author = metadata.author or metadata.maintainer or "UNKNOWN"
     version = metadata.get_version()
     sversion = "%d.%d.%d" % \
             distutils.version.StrictVersion(version).version
     self.db = msilib.init_database(self.target_name, msilib.schema,
                                    self.distribution.metadata.name,
                                    msilib.gen_uuid(), sversion, author)
     msilib.add_tables(self.db, msilib.sequence)
     self.add_properties()
     self.add_config(fullname)
     self.add_upgrade_config(sversion)
     self.add_ui()
     self.add_files()
     self.db.Commit()
     if not self.keep_temp:
         distutils.dir_util.remove_tree(self.bdist_dir,
                                        dry_run=self.dry_run)
Exemple #2
0
    def run(self):
        if not self.skip_build:
            self.run_command("build")
        install = self.reinitialize_command("install", reinit_subcommands=1)
        install.prefix = self.bdist_dir
        install.skip_build = self.skip_build
        install.warn_dir = 0
        distutils.log.info("installing to %s", self.bdist_dir)
        install.ensure_finalized()
        install.run()
        self.mkpath(self.dist_dir)
        fullname = self.distribution.get_fullname()
        if os.path.exists(self.target_name):
            os.unlink(self.target_name)
        metadata = self.distribution.metadata
        author = metadata.author or metadata.maintainer or "UNKNOWN"
        version = metadata.get_version()
        sversion = ".".join(
            str(x) for x in distutils.version.LooseVersion(version).version
        )

        # msilib is reloaded in order to reset the "_directories" global member
        # in that module.  That member is used by msilib to prevent any two
        # directories from having the same logical name.  _directories might
        # already have contents due to msilib having been previously used in
        # the current instance of the python interpreter -- if so, it could
        # prevent the root from getting the logical name TARGETDIR, breaking
        # the MSI.
        importlib.reload(msilib)

        if self.product_code is None:
            self.product_code = msilib.gen_uuid()
        self.db = msilib.init_database(
            self.target_name,
            msilib.schema,
            self.distribution.metadata.name,
            self.product_code,
            sversion,
            author,
        )
        msilib.add_tables(self.db, msilib.sequence)
        self.add_properties()
        self.add_config(fullname)
        self.add_upgrade_config(sversion)
        self.add_ui()
        self.add_files()
        self.db.Commit()
        self.distribution.dist_files.append(
            ("bdist_msi", sversion or "any", self.target_name)
        )

        if not self.keep_temp:
            distutils.dir_util.remove_tree(
                self.bdist_dir, dry_run=self.dry_run
            )

        # Cause the MSI file to be released. Without this, then if bdist_msi
        # is run programmatically from within a larger script, subsequent
        # editting of the MSI is blocked.
        self.db = None
Exemple #3
0
 def run(self):
     if not self.skip_build:
         self.run_command('build')
     install = self.reinitialize_command('install', reinit_subcommands = 1)
     install.prefix = self.bdist_dir
     install.skip_build = self.skip_build
     install.warn_dir = 0
     distutils.log.info("installing to %s", self.bdist_dir)
     install.ensure_finalized()
     install.run()
     self.mkpath(self.dist_dir)
     fullname = self.distribution.get_fullname()
     if os.path.exists(self.target_name):
         os.unlink(self.target_name)
     metadata = self.distribution.metadata
     author = metadata.author or metadata.maintainer or "UNKNOWN"
     version = metadata.get_version()
     sversion = "%d.%d.%d" % \
             distutils.version.StrictVersion(version).version
     self.db = msilib.init_database(self.target_name, msilib.schema,
             self.distribution.metadata.name, msilib.gen_uuid(), sversion,
             author)
     msilib.add_tables(self.db, msilib.sequence)
     self.add_properties()
     self.add_config(fullname)
     self.add_upgrade_config(sversion)
     self.add_ui()
     self.add_files()
     self.db.Commit()
     if not self.keep_temp:
         distutils.dir_util.remove_tree(self.bdist_dir,
                 dry_run = self.dry_run)
Exemple #4
0
	def run(self):
		if not (os.path.isdir(self.bdist_dir) and self.skip_build):
			self.run_command('py2exe')

		fullname = self.distribution.get_fullname()
		installer_name = self.get_installer_filename(fullname)
		installer_name = os.path.abspath(installer_name)

		if os.path.exists(installer_name):
			os.unlink(installer_name)

		metadata = self.distribution.metadata
		author = metadata.author

		if not author:
			author = metadata.maintainer
		if not author:
			author = 'UNKNOWN'

		version = metadata.get_version()
		sversion = '%d.%d.%d' % StrictVersion(version).version
		product_name = self.distribution.get_name()

		log.info('creating MSI package %s', installer_name)

		self.db = msilib.init_database(installer_name, schema,
				product_name, self.product_code or msilib.gen_uuid(), sversion, author)

		msilib.add_tables(self.db, sequence)

		props = []

		if self.upgrade_code:
			props.extend([
				('UpgradeCode', self.upgrade_code),
				('SecureCustomProperties', 'REPLACE')
			])

			msilib.add_data(self.db, 'Upgrade', [(
				self.upgrade_code,  # UpgradeCode
				None,  # VersionMin, detect all
				sversion,  # VersionMax
				None,  # Language
				0,  # Attributes
				None,  # Remove, REMOVE=ALL
				'REPLACE'  # ActionProperty
			)])

		if props:
			msilib.add_data(self.db, 'Property', props)

		self.add_files()
		self.add_services()

		self.db.Commit()

		if not self.keep_temp:
			remove_tree(self.bdist_dir, dry_run=self.dry_run)
			remove_tree(self.get_finalized_command('build').build_base)
Exemple #5
0
def create_msi_installer(package,
                         run_node,
                         msi_root_node,
                         installer_name=None,
                         output_dir="dist"):
    meta = PackageMetadata.from_package(package)

    string_version = "%d.%d.%d" % (meta.version_major, meta.version_minor,
                                   meta.version_micro)

    fullname = "%s-%s" % (package.name, string_version)
    if installer_name is None:
        installer_name = "%s-%s.msi" % (package.name, string_version)
    parent_node = run_node.make_node(output_dir)
    if parent_node is None:
        raise IOError()
    installer_node = parent_node.make_node(installer_name)
    installer_name = installer_node.abspath()
    installer_node.parent.mkdir()

    author = meta.author

    short_version = sysconfig.get_python_version()

    has_ext_modules = True
    if has_ext_modules:
        target_version = short_version
    else:
        target_version = None

    if target_version:
        product_name = "Python %s %s" % (target_version, meta.fullname)
    else:
        product_name = "Python %s" % meta.fullname

    if target_version:
        versions = [target_version]
    else:
        versions = list(ALL_VERSIONS)

    db = msilib.init_database(installer_name, schema, product_name,
                              msilib.gen_uuid(), string_version, author)
    msilib.add_tables(db, sequence)

    props = [('DistVersion', meta.version)]
    email = meta.author_email or meta.maintainer_email
    if email:
        props.append(("ARPCONTACT", email))
    if meta.url:
        props.append(("ARPURLINFOABOUT", meta.url))
    if props:
        add_data(db, 'Property', props)

    add_find_python(db, versions)
    add_files(db, msi_root_node, versions, OTHER_VERSION)
    add_scripts(db)
    add_ui(db, fullname, versions, OTHER_VERSION)
    db.Commit()
Exemple #6
0
 def build_database(self):
     self.db = msilib.init_database(
         "%s%s.msi" % (self.package_name, self.current_version),
         self.schema, "%s %s" % (self.package_name, self.current_version),
         self.product_codes[self.current_version], self.current_version,
         self.package_author)
     if (self.isDebug):
         print '(build_database) :: db=(%s)' % (str(self.db))
     msilib.add_tables(self.db, self.sequence)
     self.db.Commit()
Exemple #7
0
def create_msi_installer(package, run_node, msi_root_node, installer_name=None, output_dir="dist"):
    meta = PackageMetadata.from_package(package)

    string_version = "%d.%d.%d" % (meta.version_major, meta.version_minor, meta.version_micro)

    fullname = "%s-%s" % (package.name, string_version)
    if installer_name is None:
        installer_name = "%s-%s.msi" % (package.name, string_version)
    parent_node = run_node.make_node(output_dir)
    if parent_node is None:
        raise IOError()
    installer_node = parent_node.make_node(installer_name)
    installer_name = installer_node.abspath()
    installer_node.parent.mkdir()

    author = meta.author

    short_version = sysconfig.get_python_version()

    has_ext_modules = True
    if has_ext_modules:
        target_version = short_version
    else:
        target_version = None

    if target_version:
        product_name = "Python %s %s" % (target_version, meta.fullname)
    else:
        product_name = "Python %s" % meta.fullname

    if target_version:
        versions = [target_version]
    else:
        versions = list(ALL_VERSIONS)

    db = msilib.init_database(installer_name, schema, product_name, msilib.gen_uuid(), string_version, author)
    msilib.add_tables(db, sequence)

    props = [("DistVersion", meta.version)]
    email = meta.author_email or meta.maintainer_email
    if email:
        props.append(("ARPCONTACT", email))
    if meta.url:
        props.append(("ARPURLINFOABOUT", meta.url))
    if props:
        add_data(db, "Property", props)

    add_find_python(db, versions)
    add_files(db, msi_root_node, versions, OTHER_VERSION)
    add_scripts(db)
    add_ui(db, fullname, versions, OTHER_VERSION)
    db.Commit()
    def initialize_db(self):
        dirpath, filepath = os.path.split(self.package_file)
        if not os.path.exists(dirpath):
            os.makedirs(dirpath)
        if os.path.exists(self.package_file):
            os.unlink(self.package_file)
        print self.package_file

        if not self.author:
            author = "UNKNOWN"
        else:
            author = (isinstance(self.author, (list, tuple, set)) and " and ".join([x for x in self.author])) or str(self.author)

        product_name = "%s %s" % (self.package_name, self.package_version)

        self.db = msilib.init_database(self.package_file, msilib.schema,
                                       product_name, self.uuid or msilib.gen_uuid(),
                                       self.package_version, author)
        msilib.add_tables(self.db, msilib.sequence)
        props = [('DistVersion', self.package_version)]
        if self.email:
            props.append(("ARPCONTACT", self.email))
        if self.url:
            props.append(("ARPURLINFOABOUT", self.url))
        print 'install_location', self.install_location
        props.append(("TARGETDIR", self.install_location.replace('/', '\\')))
        if props:
            add_data(self.db, 'Property', props)

        # for some reason, we need to add our own error icon, so do that
        add_data(self.db, "Binary", [
            ("dlgerror.ico", msilib.Binary("./dialog-error.ico")),     # 22x22
            ])
        if self.bitmap:
            add_data(self.db, "Binary", [
                ("InstallerBitmap", msilib.Binary(self.bitmap)),     # 22x22
                ])            
        self.db.Commit()
Exemple #9
0
    def run(self):
        if not self.skip_build:
            self.run_command('build')

        install = self.reinitialize_command('install', reinit_subcommands=1)
        install.prefix = self.bdist_dir
        install.skip_build = self.skip_build
        install.warn_dir = 0

        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 = '%d.%d' % sys.version_info[:2]
            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)

        log.info("installing to %s", self.bdist_dir)
        install.ensure_finalized()

        # avoid warning of 'install_lib' about installing
        # into a directory not in sys.path
        sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB'))

        install.run()

        del sys.path[0]

        self.mkpath(self.dist_dir)
        fullname = self.distribution.get_fullname()
        installer_name = self.get_installer_filename(fullname)
        installer_name = os.path.abspath(installer_name)
        if os.path.exists(installer_name): os.unlink(installer_name)

        metadata = self.distribution.metadata
        author = metadata.author
        if not author:
            author = metadata.maintainer
        if not author:
            author = "UNKNOWN"
        version = metadata.get_version()
        # ProductVersion must be strictly numeric
        # XXX need to deal with prerelease versions
        sversion = "%d.%d.%d" % StrictVersion(version).version
        # Prefix ProductName with Python x.y, so that
        # it sorts together with the other Python packages
        # in Add-Remove-Programs (APR)
        fullname = self.distribution.get_fullname()
        if self.target_version:
            product_name = "Python %s %s" % (self.target_version, fullname)
        else:
            product_name = "Python %s" % (fullname)
        self.db = msilib.init_database(installer_name, schema,
                product_name, msilib.gen_uuid(),
                sversion, author)
        msilib.add_tables(self.db, sequence)
        props = [('DistVersion', version)]
        email = metadata.author_email or metadata.maintainer_email
        if email:
            props.append(("ARPCONTACT", email))
        if metadata.url:
            props.append(("ARPURLINFOABOUT", metadata.url))
        if props:
            add_data(self.db, 'Property', props)

        self.add_find_python()
        self.add_files()
        self.add_scripts()
        self.add_ui()
        self.db.Commit()

        if hasattr(self.distribution, 'dist_files'):
            tup = 'bdist_msi', self.target_version or 'any', fullname
            self.distribution.dist_files.append(tup)

        if not self.keep_temp:
            remove_tree(self.bdist_dir, dry_run=self.dry_run)
Exemple #10
0
    def run(self):
        if not self.skip_build:
            self.run_command('build')

        install = self.reinitialize_command('install', reinit_subcommands=1)
        install.prefix = self.bdist_dir
        install.skip_build = self.skip_build
        install.warn_dir = 0

        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 = '%d.%d' % sys.version_info[:2]
            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)

        log.info("installing to %s", self.bdist_dir)
        install.ensure_finalized()

        # avoid warning of 'install_lib' about installing
        # into a directory not in sys.path
        sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB'))

        install.run()

        del sys.path[0]

        self.mkpath(self.dist_dir)
        fullname = self.distribution.get_fullname()
        installer_name = self.get_installer_filename(fullname)
        installer_name = os.path.abspath(installer_name)
        if os.path.exists(installer_name): os.unlink(installer_name)

        metadata = self.distribution.metadata
        author = metadata.author
        if not author:
            author = metadata.maintainer
        if not author:
            author = "UNKNOWN"
        version = metadata.get_version()
        # ProductVersion must be strictly numeric
        # XXX need to deal with prerelease versions
        sversion = "%d.%d.%d" % StrictVersion(version).version
        # Prefix ProductName with Python x.y, so that
        # it sorts together with the other Python packages
        # in Add-Remove-Programs (APR)
        fullname = self.distribution.get_fullname()
        if self.target_version:
            product_name = "Python %s %s" % (self.target_version, fullname)
        else:
            product_name = "Python %s" % (fullname)
        self.db = msilib.init_database(installer_name, schema, product_name,
                                       msilib.gen_uuid(), sversion, author)
        msilib.add_tables(self.db, sequence)
        props = [('DistVersion', version)]
        email = metadata.author_email or metadata.maintainer_email
        if email:
            props.append(("ARPCONTACT", email))
        if metadata.url:
            props.append(("ARPURLINFOABOUT", metadata.url))
        if props:
            add_data(self.db, 'Property', props)

        self.add_find_python()
        self.add_files()
        self.add_scripts()
        self.add_ui()
        self.db.Commit()

        if hasattr(self.distribution, 'dist_files'):
            tup = 'bdist_msi', self.target_version or 'any', fullname
            self.distribution.dist_files.append(tup)

        if not self.keep_temp:
            remove_tree(self.bdist_dir, dry_run=self.dry_run)
 def run(self):
     if not self.skip_build:
         self.run_command('build')
     install = self.reinitialize_command('install', reinit_subcommands=1)
     install.prefix = self.bdist_dir
     install.skip_build = self.skip_build
     install.warn_dir = 0
     install_lib = self.reinitialize_command('install_lib')
     install_lib.compile = 0
     install_lib.optimize = 0
     if self.distribution.has_ext_modules():
         target_version = self.target_version
         if not target_version:
             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)
     log.info('installing to %s', self.bdist_dir)
     install.ensure_finalized()
     sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB'))
     install.run()
     del sys.path[0]
     self.mkpath(self.dist_dir)
     fullname = self.distribution.get_fullname()
     installer_name = self.get_installer_filename(fullname)
     installer_name = os.path.abspath(installer_name)
     if os.path.exists(installer_name):
         os.unlink(installer_name)
     metadata = self.distribution.metadata
     author = metadata.author
     if not author:
         author = metadata.maintainer
     if not author:
         author = 'UNKNOWN'
     version = metadata.get_version()
     sversion = '%d.%d.%d' % StrictVersion(version).version
     fullname = self.distribution.get_fullname()
     if self.target_version:
         product_name = 'Python %s %s' % (self.target_version, fullname)
     else:
         product_name = 'Python %s' % fullname
     self.db = msilib.init_database(installer_name, schema, product_name,
                                    msilib.gen_uuid(), sversion, author)
     msilib.add_tables(self.db, sequence)
     props = [('DistVersion', version)]
     email = metadata.author_email or metadata.maintainer_email
     if email:
         props.append(('ARPCONTACT', email))
     if metadata.url:
         props.append(('ARPURLINFOABOUT', metadata.url))
     if props:
         add_data(self.db, 'Property', props)
     self.add_find_python()
     self.add_files()
     self.add_scripts()
     self.add_ui()
     self.db.Commit()
     if hasattr(self.distribution, 'dist_files'):
         tup = ('bdist_msi', self.target_version or 'any', fullname)
         self.distribution.dist_files.append(tup)
     if not self.keep_temp:
         remove_tree(self.bdist_dir, dry_run=self.dry_run)
Exemple #12
0
 def run(self):
     if not self.skip_build:
         self.run_command("build")
     install = self.reinitialize_command("install", reinit_subcommands=1)
     install.prefix = self.bdist_dir
     install.skip_build = self.skip_build
     install.warn_dir = 0
     install_lib = self.reinitialize_command("install_lib")
     install_lib.compile = 0
     install_lib.optimize = 0
     if self.distribution.has_ext_modules():
         target_version = self.target_version
         if not target_version:
             if not self.skip_build:
                 raise AssertionError("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)
         log.info("installing to %s", self.bdist_dir)
         install.ensure_finalized()
         sys.path.insert(0, os.path.join(self.bdist_dir, "PURELIB"))
         install.run()
         del sys.path[0]
         self.mkpath(self.dist_dir)
         fullname = self.distribution.get_fullname()
         installer_name = self.get_installer_filename(fullname)
         installer_name = os.path.abspath(installer_name)
         if os.path.exists(installer_name):
             os.unlink(installer_name)
         metadata = self.distribution.metadata
         author = metadata.author
         if not author:
             author = metadata.maintainer
         if not author:
             author = "UNKNOWN"
         version = metadata.get_version()
         sversion = "%d.%d.%d" % StrictVersion(version).version
         fullname = self.distribution.get_fullname()
         if self.target_version:
             product_name = "Python %s %s" % (self.target_version, fullname)
         else:
             product_name = "Python %s" % fullname
         self.db = msilib.init_database(installer_name, schema, product_name, msilib.gen_uuid(), sversion, author)
         msilib.add_tables(self.db, sequence)
         props = [("DistVersion", version)]
         email = metadata.author_email or metadata.maintainer_email
         if email:
             props.append(("ARPCONTACT", email))
         if metadata.url:
             props.append(("ARPURLINFOABOUT", metadata.url))
         if props:
             add_data(self.db, "Property", props)
         self.add_find_python()
         self.add_files()
         self.add_scripts()
         self.add_ui()
         self.db.Commit()
         if hasattr(self.distribution, "dist_files"):
             tup = ("bdist_msi", self.target_version or "any", fullname)
             self.distribution.dist_files.append(tup)
         self.keep_temp or remove_tree(self.bdist_dir, dry_run=self.dry_run)