from gitdb.pack import PackEntity
from gitdb.util import bin_to_hex, hex_to_bin
ldb = LooseObjectDB(sys.argv[1] + '/.git/objects')
PackEntity.create((ldb.stream(sha) for sha in ldb.sha_iter()), sys.argv[1] +
    '/.git/objects/pack', object_count=ldb.size(), zlib_compression=zlib.
    Z_BEST_COMPRESSION)
How to get a list of Ostream or Oinfo in a variable from a repository path in gitpython?