Zip Jupyter Notebook

import os
import tarfile
tarFileName='currdir.tar'
def RecursiveFiles(dn='.',ignoreTarFile=tarFileName):
ignore={'.pynb_checkpoints','pycache',ignoreTarFile}
for dirname,subdirs,files in os.walk(dn):
if os.path.basename(dirname) in ignore: continue
for fn in files:
fname=os.path.join(dirname,fn)
yield(fname)

def makeTarFile(dn='.',tfn=tarFileName):
tar=tarfile.open(tfn,'w')
for name in RecursiveFiles(dn,tfn):
tar.add(name)
tar.close()

makeTarFile()