python - Python setuptools 无法在 user_config_dir 中安装 data_files
问题描述
我希望从我的包中安装的子目录中有一组 sql 文件。
project\
thetask\
__init__.py
MainThing.py
sql\
foo\thingone.sql
foo\thingtwo.sql
bar\thingone.sql
bar\thingtwo.sql
README.md
MANIFEST.in
我MANIFEST.in
的仅包含recursive-include sql *.sql
.
我setup.py
尝试将文件安装在user_config_dir
由appdirs
.
import setuptools
import os
from appdirs import AppDirs
APP_DIRS = AppDirs("table_builder", "thetask")
def long_desc(path_to_md):
"""
Use markdown for description on devpi server.
"""
with open(path_to_md, "r") as _fh:
return _fh.read()
setuptools.setup(
name="mything-thetask",
version="0.1a",
description="Tools for building TheTask tables.",
long_description=long_desc("README.md"),
long_description_content_type="text/markdown",
author="Someguy SomeGuysLastName",
author_email="Someguy.SomeGuysLastName@mything.com",
license="Proprietary",
install_requires=[
"xlrd",
"pyodbc",
"appdirs",
],
include_package_data=True,
packages=setuptools.find_packages(),
scripts=[
"foo.py",
"bar.py",
],
data_files=[
(APP_DIRS.user_config_dir, [
"sql\\foo\\*.sql",
"sql\\bar\\*.sql"
])
],
)
该thetask\\table_builder
目录是在我的目录中创建的AppData\\Local
,但install_data
失败并显示:
running install_data
error: can't copy 'sql\foo\*.sql': doesn't exist or not a regular file
----------------------------------------
Command "c:\users\someguy\projects\testinstall\venv\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\someguy\\AppData\\Local\\Temp\\pip-install-bmlgs1fl\\mything-thetask\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\someguy\AppData\Local\Temp\pip-record-ia0ycbsc\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\someguy\projects\testinstall\venv\include\site\python3.7\mything-thetask" failed with error code 1 in C:\Users\someguy\AppData\Local\Temp\pip-install-bmlgs1fl\mything-thetask\
command failed
我希望看到的所有文件都在包的sql
目录中.zip
。我哪里错了?
UPDATE:
我尝试使用特定的 sql 文件而不是 in 中的通配符data_files
,这消除了错误,但没有在AppData\\Local
. 这有点令人沮丧。
解决方案
推荐阅读
- django - 如何在此处传递 ID(错误 put() 缺少 1 个必需的位置参数:'request')在表单模板 Django 中
- reactjs - 无效的挂钩调用。钩子只能在函数组件的主体内部调用。请救我脱离疯狂
- hadoop - 使用 hadoop 库在 YARN 上等待日志聚合
- javascript - 使用 Google 身份验证重定向时卡住
- vb.net - vb.net 循环遍历选定的项目列表框
- debugging - tct 命令在后台是如何工作的?
- swiftui - SwiftUI - 如何在视图上拖动和释放时获得通知
- flutter - 如何在 Flutter 应用中设置前台通知?
- c - 在 c 中使用 malloc 时的自由变量
- javascript - 使用 aframe 在 VR 中动态设置子弹模板的旋转