def test_file_list(self): # Create a simple package in temp dir, and check file_list(pkg) is what # we expect _files = [ os.path.join("foo", "pkg", "__init__.py"), os.path.join("foo", "pkg", "yo.py"), os.path.join("foo", "module.py"), os.path.join("foo", "data", "foo.dat"), ] d = tempfile.mkdtemp() files = [os.path.join(d, f) for f in _files] try: for f in files: create_file(f) pkg = PackageDescription(name="foo", packages=["pkg"], py_modules=["module"], data_files={"data": DataFiles("data", files=["data/foo.dat"], target_dir="$prefix", source_dir=".") }) fl = [os.path.normpath(f) for f in file_list(pkg, root_src=os.path.join(d, "foo"))] assert_equal(sorted(fl), sorted(files)) finally: clean_tree(files) os.rmdir(d)
def create_tarball(pkg, top_node, tarname=None, topdir=None): if tarname is None: basename = tarball_basename(pkg.name, pkg.version) tarname = "%s.tar.gz" % basename if topdir is None: topdir = "%s-%s" % (pkg.name, pkg.version) ensure_dir(tarname) tf = tarfile.open(tarname, "w:gz") try: for file in file_list(pkg, top_node): tf.add(file, os.path.join(topdir, file)) finally: tf.close() return tarname