def bootstrap_cfg(): src_dir = os.path.join(__location__, 'src') egg_info_dir = os.path.join(__location__, 'PyScaffold.egg-info') has_entrypoints = os.path.isdir(egg_info_dir) sys.path.insert(0, src_dir) from pyscaffold.utils import check_setuptools_version from pyscaffold.contrib.setuptools_scm import get_version from pyscaffold.contrib.setuptools_scm.hacks import parse_pkginfo from pyscaffold.contrib.setuptools_scm.git import parse as parse_git from pyscaffold.integration import local_version2str, version2str check_setuptools_version() def parse(root): try: return parse_pkginfo(root) except IOError: return parse_git(root) config = dict( version_scheme=version2str, local_scheme=local_version2str, ) if has_entrypoints: return dict(use_pyscaffold=True) else: return dict(version=get_version( root=__location__, parse=parse, **config))
def pyscaffold_keyword(dist, keyword, value): """ Handles the `use_pyscaffold` keyword of the setup(...) command :param dist: distribution object as :obj:`setuptools.dist` :param keyword: keyword argument = 'use_pyscaffold' :param value: value of the keyword argument """ check_setuptools_version() if value: # If value is a dictionary we keep it otherwise use for configuration value = value if isinstance(value, dict) else dict() command_options = dist.command_options.copy() cmdclass = dist.cmdclass.copy() deactivate_pbr_authors_changelog() read_setup_cfg(dist, keyword, True) try: dist.metadata.version = get_version( version_scheme=value.get('version_scheme', version2str), local_scheme=value.get('local_scheme', local_version2str)) except Exception as e: trace('error', e) # Adding old command classes and options since pbr seems to drop these dist.cmdclass['doctest'] = build_cmd_docs() dist.command_options['doctest'] = {'builder': ('setup.py', 'doctest')} dist.cmdclass['test'] = PyTest dist.cmdclass.update(cmdclass) dist.cmdclass.update(command_options)
def pyscaffold_keyword(dist, keyword, value): """ Handles the `use_pyscaffold` keyword of the setup(...) command :param dist: distribution object as :obj:`setuptools.dist` :param keyword: keyword argument = 'use_pyscaffold' :param value: value of the keyword argument """ check_setuptools_version() if value: # If value is a dictionary we keep it otherwise use for configuration value = value if isinstance(value, dict) else dict() value.setdefault('root', get_git_root(default='.')) value.setdefault('version_scheme', version2str) value.setdefault('local_scheme', local_version2str) if os.path.exists('PKG-INFO'): value.pop('root', None) command_options = dist.command_options.copy() cmdclass = dist.cmdclass.copy() deactivate_pbr_authors_changelog() pbr_read_setup_cfg(dist, keyword, True) dist.metadata.version = scm_get_version(**value) # Adding old command classes and options since pbr seems to drop these dist.cmdclass['doctest'] = build_cmd_docs() dist.command_options['doctest'] = {'builder': ('setup.py', 'doctest')} dist.cmdclass['test'] = PyTest dist.cmdclass.update(cmdclass) dist.cmdclass.update(command_options)
def bootstrap_cfg(): """Allow PyScaffold to be used to package itself. Usually, running ``python setup.py egg_info --egg-base .`` first is a good idea. """ src_dir = os.path.join(__location__, 'src') egg_info_dir = os.path.join(__location__, 'PyScaffold.egg-info') has_entrypoints = os.path.isdir(egg_info_dir) import pkg_resources sys.path.insert(0, src_dir) pkg_resources.working_set.add_entry(src_dir) from pyscaffold.utils import check_setuptools_version from pyscaffold.contrib.setuptools_scm import get_version from pyscaffold.contrib.setuptools_scm.hacks import parse_pkginfo from pyscaffold.contrib.setuptools_scm.git import parse as parse_git from pyscaffold.integration import local_version2str, version2str check_setuptools_version() def parse(root): try: return parse_pkginfo(root) except IOError: return parse_git(root) config = dict( version_scheme=version2str, local_scheme=local_version2str, ) if has_entrypoints: return dict(use_pyscaffold=True) else: return dict( version=get_version( root=__location__, parse=parse, **config) )
def bootstrap_cfg(): """Allow PyScaffold to be used to package itself. Usually, running ``python setup.py egg_info --egg-base .`` first is a good idea. """ src_dir = os.path.join(__location__, "src") egg_info_dir = os.path.join(__location__, "PyScaffold.egg-info") has_entrypoints = os.path.isdir(egg_info_dir) import pkg_resources sys.path.insert(0, src_dir) pkg_resources.working_set.add_entry(src_dir) from pyscaffold.contrib.setuptools_scm import get_version from pyscaffold.contrib.setuptools_scm.git import parse as parse_git from pyscaffold.contrib.setuptools_scm.hacks import parse_pkginfo from pyscaffold.integration import local_version2str, version2str from pyscaffold.utils import check_setuptools_version check_setuptools_version() def parse(root): try: return parse_pkginfo(root) except IOError: return parse_git(root) config = dict( version_scheme=version2str, local_scheme=local_version2str, ) if has_entrypoints: return dict(use_pyscaffold=True) else: return dict( version=get_version(root=__location__, parse=parse, **config))