Python setuptools无法在user_config_dir中安装data_files

时间:2019-04-16 13:55:44

标签: python setuptools

我希望从软件包中安装子目录中的一组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文件代替data_files中的通配符,这消除了该错误,但是没有在AppData\\Local中安装任何文件。这有点令人沮丧。

0 个答案:

没有答案