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 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 test_get_git_root_with_nogit(tmpdir, nogit_mock): # noqa project = "my_project" struct = {project: { "my_file": "Some other content", "my_dir": {"my_file": "Some more content"}} } structure.create_structure(struct) with utils.chdir(project): git_root = repo.get_git_root(default='.') assert git_root == '.'
def test_get_git_root_with_nonegit(tmpfolder, nonegit_mock): project = "my_project" struct = { "my_file": "Some other content", "my_dir": {"my_file": "Some more content"}, } structure.create_structure(struct, {"project_path": project}) with chdir(project): git_root = repo.get_git_root(default=".") assert git_root == "."
def test_get_git_root_with_nonegit(tmpfolder, nonegit_mock): project = "my_project" struct = {project: { "my_file": "Some other content", "my_dir": {"my_file": "Some more content"}} } structure.create_structure(struct, {}) with utils.chdir(project): git_root = repo.get_git_root(default='.') assert git_root == '.'
def test_get_git_root(tmpdir): # noqa project = "my_project" struct = {project: { "my_file": "Some other content", "my_dir": {"my_file": "Some more content"}} } structure.create_structure(struct) repo.init_commit_repo(project, struct) with utils.chdir(project): git_root = repo.get_git_root() assert os.path.basename(git_root) == project
def test_get_git_root(tmpfolder): project = "my_project" struct = { "my_file": "Some other content", "my_dir": {"my_file": "Some more content"}, } structure.create_structure(struct, {"project_path": project}) repo.init_commit_repo(project, struct) with chdir(project): git_root = repo.get_git_root() assert Path(git_root).name == project
def test_get_git_root(tmpfolder): project = "my_project" struct = {project: { "my_file": "Some other content", "my_dir": {"my_file": "Some more content"}} } structure.create_structure(struct, {}) repo.init_commit_repo(project, struct) with utils.chdir(project): git_root = repo.get_git_root() assert os.path.basename(git_root) == project
def pyscaffold_keyword(dist, keyword, value): """Handles the `use_pyscaffold` keyword of the setup(...) command Args: dist (:obj:`setuptools.dist`): distribution object as keyword (str): keyword argument = 'use_pyscaffold' 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) matching_fallbacks = discover.iter_matching_entrypoints( '.', 'setuptools_scm.parse_scm_fallback') if any(matching_fallbacks): value.pop('root', None) dist.metadata.version = get_version(**value) dist.cmdclass['doctest'] = build_cmd_docs() dist.command_options['doctest'] = {'builder': ('setup.py', 'doctest')} dist.cmdclass['test'] = PyTest