Including .gitignore in setup? - Error: doesn't exist or not a regular file
Including .gitignore in setup? - Error: doesn't exist or not a regular file
setup.py
from setuptools import setup, find_packages
from os import path
from functools import partial
if __name__ == '__main__':
package_name = 'gen'
templates_join = partial(path.join, path.dirname(__file__), package_name,
'templates')
setup(
name=package_name,
test_suite=package_name + '.tests',
packages=find_packages(),
package_dir={package_name: package_name},
package_data={package_name: [templates_join('.gitignore')]}
)
树
.
├── gen
│ ├── __init__.py
│ ├── templates
│ │ ├── __init__.py
│ │ ├── .gitignore
└── setup.py
错误
error: can't copy 'gen/ld/gen/templates/.gitignore': doesn't exist or not a regular file
请尝试使用 abspath(split(__file__)[0])
。
from setuptools import setup, find_packages
from functools import partial
from os.path import join, abspath, split
if __name__ == '__main__':
package_name = 'gen'
templates_join = partial(join, abspath(split(__file__)[0]), 'gen', 'templates')
setup(
name=package_name,
test_suite=package_name + '.tests',
packages=find_packages(),
package_dir={package_name: package_name},
package_data={package_name: [templates_join('.gitignore')]}
)
让我知道它是否有效。
确认使用 data_files
在 Linux 和 Windows 上工作 inside/outside a virtualenv
:
from setuptools import setup, find_packages
from os import path
from functools import partial
from pip import __file__ as pip_loc
if __name__ == '__main__':
package_name = 'gen'
templates_join = partial(path.join, path.dirname(__file__),
package_name, 'templates')
install_to = path.join(path.split(path.split(pip_loc)[0])[0],
package_name, 'templates')
setup(
name=package_name,
version='0.0.1',
test_suite=package_name + '.tests',
packages=find_packages(),
package_dir={package_name: package_name},
data_files=[(install_to, [templates_join('.gitignore'),
templates_join('logging.conf')])]
)
setup.py
from setuptools import setup, find_packages
from os import path
from functools import partial
if __name__ == '__main__':
package_name = 'gen'
templates_join = partial(path.join, path.dirname(__file__), package_name,
'templates')
setup(
name=package_name,
test_suite=package_name + '.tests',
packages=find_packages(),
package_dir={package_name: package_name},
package_data={package_name: [templates_join('.gitignore')]}
)
树
.
├── gen
│ ├── __init__.py
│ ├── templates
│ │ ├── __init__.py
│ │ ├── .gitignore
└── setup.py
错误
error: can't copy 'gen/ld/gen/templates/.gitignore': doesn't exist or not a regular file
请尝试使用 abspath(split(__file__)[0])
。
from setuptools import setup, find_packages
from functools import partial
from os.path import join, abspath, split
if __name__ == '__main__':
package_name = 'gen'
templates_join = partial(join, abspath(split(__file__)[0]), 'gen', 'templates')
setup(
name=package_name,
test_suite=package_name + '.tests',
packages=find_packages(),
package_dir={package_name: package_name},
package_data={package_name: [templates_join('.gitignore')]}
)
让我知道它是否有效。
确认使用 data_files
在 Linux 和 Windows 上工作 inside/outside a virtualenv
:
from setuptools import setup, find_packages
from os import path
from functools import partial
from pip import __file__ as pip_loc
if __name__ == '__main__':
package_name = 'gen'
templates_join = partial(path.join, path.dirname(__file__),
package_name, 'templates')
install_to = path.join(path.split(path.split(pip_loc)[0])[0],
package_name, 'templates')
setup(
name=package_name,
version='0.0.1',
test_suite=package_name + '.tests',
packages=find_packages(),
package_dir={package_name: package_name},
data_files=[(install_to, [templates_join('.gitignore'),
templates_join('logging.conf')])]
)