You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#funcsimport pip._internal as pipdef from_pack(file): file = open(file) packages = set(file.read().split('\n')) - set(package.key for package in pip.get_installed_distributions()) file.close() for package in packages: pip.main(['install',package])
def to_pack(file): file = open(file,'w') s = '\n'.join(map(lambda p: p.key,pip.get_installed_distributions())) file.write(s) file.close()#argumentsif __name__ == "__main__": import argparse parser = argparse.ArgumentParser() parser.add_argument("mode",metavar = "action",help="what you wanna do") parser.add_argument("path",metavar = "dir",help="fullpath to pack") args = parser.parse_args() if args.mode == "to_pack": to_pack(args.path) elif args.mode == "from_pack": from_pack(args.path)
|