I am trying to add data_file to setup.py project . I can use file from /tmp/ directory, and cannot use it from current directory of the script:
from setuptools import setup, find_packages
import os
packages = find_packages("src")
foo_path = os.path.dirname(os.path.abspath(__file__)) + '/foo.dat'
print foo_path # file exists and there full absolute path is printed:
# '/home/loom/myapp/foo.dat'
setup(name='myapp',
version='0.2.0',
url='http://loom.st',
author='Loom',
author_email='[email protected]',
package_dir={'': 'src'},
packages=packages,
py_modules=['my_start'],
# 1. data_files=[('lib/python', [foo_path])],
# 2. data_files=[('lib/python', [/tmp/foo.dat])],
setup_cfg=True,
)
When the line 1. is uncommented, then python setup.py bdist_rpm failed with message:
running install_data
error: can't copy '/home/loom/myapp/build/bdist.linux-x86_64/rpm/BUILD/myapp-0.2.0/foo.dat': doesn't exist or not a regular file
error: Bad exit status from /var/tmp/rpm-tmp.02mmV8 (%install)
When the line 2. is uncommented, then build is completed ok and includes foo.dat (file /tmp/foo.dat exists)
Why the line 1. induces error and how to avoid it?
/in/home/loom/myapp/foo.dat/while in/tmp/foo.datit seems to be a file and not a dirtmpis in the root directory and file/tmp/foo.datexists. I'll expand question, thank youfoo_pathas"./foo.dat"if it's in the same directory as the setup file??error: can't copy './foo.dat': doesn't exist or not a regular fileI started with it.