Example #1
0
 def save_version_info(self, filename):
     values = dict(egg_info=dict(
         tag_svn_revision=0,
         tag_date=0,
         tag_build=self.tags(),
     ))
     edit_config(filename, values)
Example #2
0
    def run(self):
        aliases = self.distribution.get_option_dict('aliases')

        if not self.args:
            print("Command Aliases")
            print("---------------")
            for alias in aliases:
                print("setup.py alias", format_alias(alias, aliases))
            return

        elif len(self.args) == 1:
            alias, = self.args
            if self.remove:
                command = None
            elif alias in aliases:
                print("setup.py alias", format_alias(alias, aliases))
                return
            else:
                print("No alias definition found for %r" % alias)
                return
        else:
            alias = self.args[0]
            command = ' '.join(map(shquote, self.args[1:]))

        edit_config(self.filename, {'aliases': {alias: command}}, self.dry_run)
Example #3
0
 def _set_fetcher_options(self, base):
     """
     When easy_install is about to run bdist_egg on a source dist,
     that source dist might have 'setup_requires' directives,
     requiring additional fetching. Ensure the fetcher options given
     to easy_install are available to that command as well.
     """
     from setuptools.command import setopt
     # find the fetch options from easy_install and write them out
     #  to the setup.cfg file.
     ei_opts = self.distribution.get_option_dict('easy_install'
                                                 ).copy()
     fetch_directives = (
         'find_links', 'site_dirs', 'index_url', 'optimize',
         'site_dirs', 'allow_hosts',
     )
     fetch_options = {}
     for key, val in ei_opts.items():
         if key not in fetch_directives:
             continue
         fetch_options[key.replace('_', '-')] = val[1]
     # create a settings dictionary suitable for `edit_config`
     settings = dict(easy_install=fetch_options)
     cfg_filename = os.path.join(base, 'setup.cfg')
     setopt.edit_config(cfg_filename, settings)
Example #4
0
 def _set_fetcher_options(self, base):
     """
     When easy_install is about to run bdist_egg on a source dist,
     that source dist might have 'setup_requires' directives,
     requiring additional fetching. Ensure the fetcher options given
     to easy_install are available to that command as well.
     """
     from setuptools.command import setopt
     # find the fetch options from easy_install and write them out
     #  to the setup.cfg file.
     ei_opts = self.distribution.get_option_dict(
         'easy_install').copy()
     fetch_directives = (
         'find_links',
         'site_dirs',
         'index_url',
         'optimize',
         'site_dirs',
         'allow_hosts',
     )
     fetch_options = {}
     for key, val in ei_opts.items():
         if key not in fetch_directives:
             continue
         fetch_options[key.replace('_', '-')] = val[1]
     # create a settings dictionary suitable for `edit_config`
     settings = dict(easy_install=fetch_options)
     cfg_filename = os.path.join(base, 'setup.cfg')
     setopt.edit_config(cfg_filename, settings)
Example #5
0
    def run(self):
        aliases = self.distribution.get_option_dict('aliases')

        if not self.args:
            print("Command Aliases")
            print("---------------")
            for alias in aliases:
                print("setup.py alias", format_alias(alias, aliases))
            return

        elif len(self.args)==1:
            alias, = self.args
            if self.remove:
                command = None
            elif alias in aliases:
                print("setup.py alias", format_alias(alias, aliases))
                return
            else:
                print("No alias definition found for %r" % alias)
                return
        else:
            alias = self.args[0]
            command = ' '.join(map(shquote,self.args[1:]))

        edit_config(self.filename, {'aliases': {alias:command}}, self.dry_run)
Example #6
0
 def save_version_info(self, filename):
     from setuptools.command.setopt import edit_config
     values = dict(egg_info=dict(
         tag_svn_revision=0,
         tag_date=0,
         tag_build=self.tags(),
     ))
     edit_config(filename, values)
Example #7
0
 def save_version_info(self, filename):
     from setuptools.command.setopt import edit_config
     edit_config(
         filename,
         {'egg_info':
             {'tag_svn_revision':0, 'tag_date': 0, 'tag_build': self.tags()}
         }
     )
Example #8
0
 def save_version_info(self, filename):
     values = dict(
         egg_info=dict(
             tag_svn_revision=0,
             tag_date=0,
             tag_build=self.tags(),
         )
     )
     edit_config(filename, values)
Example #9
0
 def test_case_retained(self, tmpdir):
     """
     When editing a file, case of keys should be retained.
     """
     config = tmpdir.join('setup.cfg')
     self.write_text(str(config), '[names]\nFoO=bAr')
     setopt.edit_config(str(config), dict(names=dict(oTher='yes')))
     actual = config.read_text(encoding='ascii')
     assert 'FoO' in actual
     assert 'oTher' in actual
 def save_version_info(self, filename):
     from setuptools.command.setopt import edit_config
     edit_config(
         filename, {
             'egg_info': {
                 'tag_svn_revision': 0,
                 'tag_date': 0,
                 'tag_build': self.tags()
             }
         })
Example #11
0
 def save_version_info(self, filename):
     from setuptools.command.setopt import edit_config
     values = dict(
         egg_info=dict(
             tag_svn_revision=0,
             tag_date=0,
             tag_build=self.tags(),
         )
     )
     edit_config(filename, values)
Example #12
0
def save_defaults(**kw):
    """Save in ~/.pydistutils the author name and email.
    
    To be used as default value for the next use of this template."""
    options = {}
    for option in ("author", "author_email"):
        value = kw.get(option, "")
        if value:
            options["default.%s" % option] = value
    edit_config(config_file("user"), {"paver": options})
Example #13
0
 def test_utf8_encoding_retained(self, tmpdir):
     """
     When editing a file, non-ASCII characters encoded in
     UTF-8 should be retained.
     """
     config = tmpdir.join('setup.cfg')
     self.write_text(str(config), '[names]\njaraco=джарако')
     setopt.edit_config(str(config), dict(names=dict(other='yes')))
     parser = self.parse_config(str(config))
     assert parser.get('names', 'jaraco') == 'джарако'
     assert parser.get('names', 'other') == 'yes'
Example #14
0
 def save_version_info(self, filename):
     """
     Materialize the value of date into the
     build tag. Install build keys in a deterministic order
     to avoid arbitrary reordering on subsequent builds.
     """
     egg_info = collections.OrderedDict()
     # follow the order these keys would have been added
     # when PYTHONHASHSEED=0
     egg_info['tag_build'] = self.tags()
     egg_info['tag_date'] = 0
     edit_config(filename, dict(egg_info=egg_info))
 def run_example_settings(self):
     from setuptools.command.setopt import edit_config
     dist = self.distribution
     packages = list(dist.packages)
     packages.sort(lambda a, b: cmp(len(a), len(b)))
     package_dir = os.path.join(dist.package_dir or '.', packages[0])
     settings = {
         'compress_resources':
         {'resource_dirs': os.path.join(package_dir, 'public'),
          'resource_files': 'file1.js\nfile2.js',
          'compress_js': 'True'}}
     edit_config('setup.cfg', settings, self.dry_run)
Example #16
0
 def save_version_info(self, filename):
     """
     Materialize the value of date into the
     build tag. Install build keys in a deterministic order
     to avoid arbitrary reordering on subsequent builds.
     """
     egg_info = collections.OrderedDict()
     # follow the order these keys would have been added
     # when PYTHONHASHSEED=0
     egg_info['tag_build'] = self.tags()
     egg_info['tag_date'] = 0
     edit_config(filename, dict(egg_info=egg_info))
    def run(self):
        dist = self.distribution
        settings = {}

        for cmd in dist.command_options:

            if cmd == 'saveopts':
                continue  # don't save our own options!

            for opt, (src, val) in dist.get_option_dict(cmd).items():
                if src == "command line":
                    settings.setdefault(cmd, {})[opt] = val

        edit_config(self.filename, settings, self.dry_run)
    def run(self):
        dist = self.distribution
        settings = {}

        for cmd in dist.command_options:

            if cmd == 'saveopts':
                continue  # don't save our own options!

            for opt, (src, val) in dist.get_option_dict(cmd).items():
                if src == "command line":
                    settings.setdefault(cmd, {})[opt] = val

        edit_config(self.filename, settings, self.dry_run)
 def save_version_info(self, filename):
     """
     Materialize the values of svn_revision and date into the
     build tag. Install these keys in a deterministic order
     to avoid arbitrary reordering on subsequent builds.
     """
     # python 2.6 compatibility
     odict = getattr(collections, 'OrderedDict', dict)
     egg_info = odict()
     # follow the order these keys would have been added
     # when PYTHONHASHSEED=0
     egg_info['tag_build'] = self.tags()
     egg_info['tag_date'] = 0
     egg_info['tag_svn_revision'] = 0
     edit_config(filename, dict(egg_info=egg_info))
 def save_version_info(self, filename):
     """
     Materialize the values of svn_revision and date into the
     build tag. Install these keys in a deterministic order
     to avoid arbitrary reordering on subsequent builds.
     """
     # python 2.6 compatibility
     odict = getattr(collections, 'OrderedDict', dict)
     egg_info = odict()
     # follow the order these keys would have been added
     # when PYTHONHASHSEED=0
     egg_info['tag_build'] = self.tags()
     egg_info['tag_date'] = 0
     egg_info['tag_svn_revision'] = 0
     edit_config(filename, dict(egg_info=egg_info))
class saveopts(option_base):
    """Save command-line options to a file"""

    description = "save supplied options to setup.cfg or other config file"

    f run(self):
        dist = self.distribution
        settings = {}

        for cmd in dist.command_options:

            if cmd == 'saveopts':
                continue  # don't save our own options!

            for opt, (src, val) in dist.get_option_dict(cmd).items():
                if src == "command line":
                    settings.setdefault(cmd, {})[opt] = val

        edit_config(self.filename, settings, self.dry_run)