def test_find_files_stop_at_root_hg(wd): wd.commit_testfile() wd.cwd.ensure("project/setup.cfg") # setup.cfg has not been committed assert integration.find_files(str(wd.cwd / "project")) == [] # issue 251 wd.add_and_commit() with (wd.cwd / "project").as_cwd(): assert integration.find_files() == ["setup.cfg"]
def test_find_files_stop_at_root_hg(wd, monkeypatch): wd.commit_testfile() project = wd.cwd / "project" project.mkdir() project.joinpath("setup.cfg").touch() # setup.cfg has not been committed assert integration.find_files(str(project)) == [] # issue 251 wd.add_and_commit() monkeypatch.chdir(project) assert integration.find_files() == ["setup.cfg"]
def test_basic(inwd): assert set(find_files()) == _sep({ 'file1', 'adir/filea', 'bdir/fileb', }) assert set(find_files('.')) == _sep({ './file1', './adir/filea', './bdir/fileb', }) assert set(find_files('adir')) == _sep({ 'adir/filea', })
def test_empty_subdir(inwd): subdir = inwd.cwd / "adir" / "emptysubdir" / "subdir" subdir.mkdir(parents=True) (subdir / "xfile").touch() inwd.add_and_commit() assert set(find_files("adir")) == _sep( {"adir/filea", "adir/emptysubdir/subdir/xfile"})
def setup_args(config_path=Path("pyproject.toml")): cfg = config.read_flit_config(config_path) module = common.Module(cfg.module, config_path.parent) metadata = common.make_metadata(module, cfg) kwargs = {} for st_field, metadata_field in field_map.items(): val = getattr(metadata, metadata_field, None) if val is not None: kwargs[st_field] = val else: msg = f"{metadata_field} not found in {dir(metadata)}" assert metadata_field in {"license"}, msg kwargs["packages"] = setuptools.find_packages( include=[metadata.name + "*"]) if metadata.requires_dist: kwargs["install_requires"] = [ req for req in metadata.requires_dist if "extra ==" not in req ] if cfg.reqs_by_extra: kwargs["extras_require"] = cfg.reqs_by_extra scripts = cfg.entrypoints.get("console_scripts") if scripts is not None: kwargs["entry_points"] = dict( console_scipts=[" = ".join(ep) for ep in scripts.items()]) kwargs["include_package_data"] = True kwargs["package_data"] = { module.name: [re.escape(f[len(module.name) + 1:]) for f in find_files(module.path)] } return kwargs
def test_symlink_dir_out_of_git(inwd): (inwd.cwd / 'adir' / 'outsidedirlink').\ mksymlinkto(os.path.join(__file__, '..')) inwd.add_and_commit() assert set(find_files('adir')) == _sep({ 'adir/filea', })
def test_whitespace(inwd): (inwd.cwd / 'adir' / 'space file').ensure(file=True) inwd.add_and_commit() assert set(find_files('adir')) == _sep({ 'adir/space file', 'adir/filea', })
def test_git_archive_run_from_subdirectory(wd, monkeypatch): wd("mkdir foobar") wd.write("foobar/test1.txt", "test") wd("git add foobar") wd.commit() monkeypatch.chdir(wd.cwd / "foobar") assert integration.find_files(".") == [opj(".", "test1.txt")]
def test_symlink_loop(inwd): (inwd.cwd / 'adir' / 'loop').mksymlinkto('../adir') inwd.add_and_commit() assert set(find_files('adir')) == _sep({ 'adir/filea', 'adir/loop', # -> ../adir })
def test_case(inwd): (inwd.cwd / "CamelFile").touch() (inwd.cwd / "file2").touch() inwd.add_and_commit() assert set(find_files()) == _sep( {"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"} )
def test_git_archive_run_from_subdirectory(wd): wd("mkdir foobar") wd.write("foobar/test1.txt", "test") wd("git add foobar") wd.commit() with (wd.cwd / "foobar").as_cwd(): assert integration.find_files(".") == [opj(".", "test1.txt")]
def test_find_files_stop_at_root_git(wd): wd('git init') wd.write('test.txt', 'test') wd('git add .') wd('git commit -m test -u test') wd.cwd.ensure('project/setup.cfg') assert integration.find_files(str(wd.cwd/'project')) == []
def test_find_files_stop_at_root_git(wd): wd('git init') wd.write('test.txt', 'test') wd('git add .') wd('git commit -m test -u test') wd.cwd.ensure('project/setup.cfg') assert integration.find_files(str(wd.cwd / 'project')) == []
def test_git_archive_run_from_subdirectory(wd): wd('mkdir foobar') wd.write('foobar/test1.txt', 'test') wd('git add foobar') wd.commit() with (wd.cwd / 'foobar').as_cwd(): assert integration.find_files('.') == [opj('.', 'test1.txt')]
def test_symlink_file(inwd): (inwd.cwd / 'adir' / 'file1link').mksymlinkto('../file1') inwd.add_and_commit() assert set(find_files('adir')) == _sep({ 'adir/filea', 'adir/file1link', # -> ../file1 })
def test_symlink_dir(inwd): (inwd.cwd / 'adir' / 'bdirlink').mksymlinkto('../bdir') inwd.add_and_commit() assert set(find_files('adir')) == _sep({ 'adir/filea', 'adir/bdirlink/fileb', })
def test_empty_subdir(inwd): subdir = inwd.cwd / "adir" / "emptysubdir" / "subdir" subdir.ensure(dir=True) (subdir / "xfile").ensure(file=True) inwd.add_and_commit() assert ( set(find_files("adir")) == _sep({"adir/filea", "adir/emptysubdir/subdir/xfile"}) )
def test_empty_root(inwd): subdir = inwd.cwd / 'cdir' / 'subdir' subdir.ensure(dir=True) (subdir / 'filec').ensure(file=True) inwd.add_and_commit() assert set(find_files('cdir')) == _sep({ 'cdir/subdir/filec', })
def test_case(inwd): (inwd.cwd / "CamelFile").ensure(file=True) (inwd.cwd / "file2").ensure(file=True) inwd.add_and_commit() assert ( set(find_files()) == _sep({"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"}) )
def test_empty_subdir(inwd): subdir = inwd.cwd / 'adir' / 'emptysubdir' / 'subdir' subdir.ensure(dir=True) (subdir / 'xfile').ensure(file=True) inwd.add_and_commit() assert set(find_files('adir')) == _sep({ 'adir/filea', 'adir/emptysubdir/subdir/xfile', })
def test_case(inwd): (inwd.cwd / 'CamelFile').ensure(file=True) (inwd.cwd / 'file2').ensure(file=True) inwd.add_and_commit() assert set(find_files()) == _sep({ 'CamelFile', 'file2', 'file1', 'adir/filea', 'bdir/fileb', })
def test_git_archive_export_ignore(wd): wd.write('test1.txt', 'test') wd.write('test2.txt', 'test') wd.write( '.git/info/attributes', # Explicitly include test1.txt so that the test is not affected by # a potentially global gitattributes file on the test machine. '/test1.txt -export-ignore\n/test2.txt export-ignore') wd('git add test1.txt test2.txt') wd.commit() assert integration.find_files(str(wd.cwd)) == ['test1.txt']
def test_git_archive_export_ignore(wd): wd.write("test1.txt", "test") wd.write("test2.txt", "test") wd.write( ".git/info/attributes", # Explicitly include test1.txt so that the test is not affected by # a potentially global gitattributes file on the test machine. "/test1.txt -export-ignore\n/test2.txt export-ignore", ) wd("git add test1.txt test2.txt") wd.commit() with wd.cwd.as_cwd(): assert integration.find_files(".") == [opj(".", "test1.txt")]
def test_double_include_through_symlink(inwd): (inwd.cwd / 'data').ensure(dir=True) (inwd.cwd / 'data' / 'datafile').ensure(file=True) (inwd.cwd / 'adir' / 'datalink').mksymlinkto('../data') (inwd.cwd / 'adir' / 'filealink').mksymlinkto('filea') inwd.add_and_commit() assert set(find_files()) == _sep({ 'file1', 'adir/datalink', # -> ../data 'adir/filealink', # -> filea 'adir/filea', 'bdir/fileb', 'data/datafile', })
def test_symlink_not_in_scm_while_target_is(inwd): (inwd.cwd / "data").mkdir() (inwd.cwd / "data" / "datafile").touch() inwd.add_and_commit() (inwd.cwd / "adir" / "datalink").symlink_to("../data") (inwd.cwd / "adir" / "filealink").symlink_to("filea") assert set(find_files()) == _sep({ "file1", "adir/filea", # adir/datalink and adir/afilelink not included # because the symlink_to themselves are not in scm "bdir/fileb", "data/datafile", })
def test_double_include_through_symlink(inwd): (inwd.cwd / "data").mkdir() (inwd.cwd / "data" / "datafile").touch() (inwd.cwd / "adir" / "datalink").symlink_to("../data") (inwd.cwd / "adir" / "filealink").symlink_to("filea") inwd.add_and_commit() assert set(find_files()) == _sep({ "file1", "adir/datalink", # -> ../data "adir/filealink", # -> filea "adir/filea", "bdir/fileb", "data/datafile", })
def test_symlink_not_in_scm_while_target_is(inwd): (inwd.cwd / 'data').ensure(dir=True) (inwd.cwd / 'data' / 'datafile').ensure(file=True) inwd.add_and_commit() (inwd.cwd / 'adir' / 'datalink').mksymlinkto('../data') (inwd.cwd / 'adir' / 'filealink').mksymlinkto('filea') assert set(find_files()) == _sep({ 'file1', 'adir/filea', # adir/datalink and adir/afilelink not included # because the symlink themselves are not in scm 'bdir/fileb', 'data/datafile', })
def test_double_include_through_symlink(inwd): (inwd.cwd / "data").ensure(dir=True) (inwd.cwd / "data" / "datafile").ensure(file=True) (inwd.cwd / "adir" / "datalink").mksymlinkto("../data") (inwd.cwd / "adir" / "filealink").mksymlinkto("filea") inwd.add_and_commit() assert ( set(find_files()) == _sep( { "file1", "adir/datalink", # -> ../data "adir/filealink", # -> filea "adir/filea", "bdir/fileb", "data/datafile", } ) )
from __future__ import print_function import sys from setuptools_scm import get_version from setuptools_scm.integration import find_files from setuptools_scm.version import _warn_if_setuptools_outdated if __name__ == '__main__': _warn_if_setuptools_outdated() print('Guessed Version', get_version()) if 'ls' in sys.argv: for fname in find_files('.'): print(fname)
def test_find_files_stop_at_root_git(wd): wd.commit_testfile() wd.cwd.ensure("project/setup.cfg") assert integration.find_files(str(wd.cwd / "project")) == []
def main(): _warn_if_setuptools_outdated() print('Guessed Version', get_version()) if 'ls' in sys.argv: for fname in find_files('.'): print(fname)
def test_symlink_loop(inwd): (inwd.cwd / "adir" / "loop").symlink_to("../adir") inwd.add_and_commit() assert set(find_files("adir")) == _sep({"adir/filea", "adir/loop"}) # -> ../adir
def test_find_files_stop_at_root_git(wd): wd.commit_testfile() wd.cwd.ensure('project/setup.cfg') assert integration.find_files(str(wd.cwd/'project')) == []
def main(): _warn_if_setuptools_outdated() print("Guessed Version", get_version()) if "ls" in sys.argv: for fname in find_files("."): print(fname)