I want to add folders mydata1
and mydata2
in root package recursively when install my project. So I write this function in setup.py
:
def gen_data_files(*dirs):
results=[]
for datadir in dirs:
results.extend([(p, [os.path.join(p,f) for f in files]) for p, subdirs, files in os.walk(datadir)])
return results
And then in setup.py
:
setup(
#...
data_files=gen_data_files('mydata2', 'mydata2'),
#...
)
Creating the sdist is ok: setup.py sdist upload -r mypypi
But when I install, an exception was throw: ValueError: too many values to unpack (expected 2)
.
I'm new in Python. So I don't know why. Can you help me in this case? Thanks!
EDIT:
Those codes have the same results
:
results.extend([(p, [os.path.join(p,f) for f in files]) for p, subdirs, files in os.walk(datadir)])
results.extend((p, [os.path.join(p,f) for f in files]) for p, subdirs, files in os.walk(datadir))