[英]Setup.py is not installing my package_data
On both Ubuntu 16.04 and Windows 7 (pip 18.1, python 2.7.15) , I am encountering an issue where I have package data
that makes its way into the tar.gz file, but they do not get installed to my scripts directory when I install with pip.在 Ubuntu 16.04 和 Windows 7 (pip 18.1, python 2.7.15) 上,我遇到了一个问题,我的package data
进入了 tar.gz 文件,但是当我将它们安装到我的脚本目录时用pip安装。 My scripts directory on windows is \\Python27\\Scripts
.我在 Windows 上的脚本目录是\\Python27\\Scripts
。 I also checked in site-packages
and the file doesn't show up there.我还签入了site-packages
,但该文件没有显示在那里。 I want to have a textfile appear alongside the python scripts when installed via pip, and I think that using data_files
does not achieve this (according to setup.py not installing data files ?通过 pip 安装时,我希望在 python 脚本旁边显示一个文本文件,我认为使用data_files
无法实现这一点(根据setup.py 未安装数据文件?
My package structure has all files ( hello.py, MANIFEST.IN, setup.py
)in the one root folder called fakeapp
.我的包结构在一个名为fakeapp
根文件夹中包含所有文件( hello.py, MANIFEST.IN, setup.py
)。 I would like to keep this structure as the project that I actually am trying to fix has this structure.我想保留这种结构,因为我实际尝试修复的项目具有这种结构。
I have looked up many answers and tried:我查了很多答案并尝试过:
__init__.py
to the root of the repo and this didn't fix it.将一个空的__init__.py
添加到 repo 的根目录,但这并没有解决它。include_package_files=True
to no avail我试过添加和删除include_package_files=True
无济于事package_data={'':['texto.txt']}
as well as我试过指定package_data={'':['texto.txt']}
以及include texto.txt
to MANIFEST.in
to no avail.将include texto.txt
添加到MANIFEST.in
无济于事。I'm sure that this is a duplicate question but I have not been able to get any solution to work.我确定这是一个重复的问题,但我无法找到任何解决方案。
So here's my test case: setup.py所以这是我的测试用例:setup.py
from setuptools import setup
setup(
author='hi',
author_email='hi@hi.com',
description="test",
scripts=['hello.py',],
license='MIT',
name='hi',
version='v2018.12.02',
include_package_data=True
)
hello.py:你好.py:
#!/usr/bin/env python
def main():
print('hello world!')
if __name__ == '__main__':
main()
MANIFEST.in:清单.in:
include texto.txt
I created a tar.gz in dist/ with我在 dist/ 中创建了一个 tar.gz
python setup.py sdist
and my texto.txt is in that tarball.而我的 texto.txt 就在那个 tarball 中。
and then i installed with然后我安装了
pip install dist\hi-2018.12.2.tar.gz
and only hello.py
makes its way into C:\\Python2.7\\Scripts
只有hello.py
进入C:\\Python2.7\\Scripts
What am I doing wrong?我究竟做错了什么?
Directory tree :目录树:
│ hello.py
│ MANIFEST.in
│ setup.py
│ texto.txt
│
├───dist
│ hi-2018.12.2.tar.gz
│
└───hi.egg-info
dependency_links.txt
PKG-INFO
SOURCES.txt
top_level.txt
texto.txt
is not actually package data, as it is not inside a package (a directory with an __init__.py
), and thus it will not be installed. texto.txt
实际上不是包数据,因为它不在包内(带有__init__.py
的目录),因此不会被安装。 The simplest way to get what you want is to restructure your code so that it installs a package hello
instead of a flat module hello.py
, with hello.py
being moved to hello/__init__.py
and texto.txt
being moved to hello/texto.txt
.获得所需内容的最简单方法是重构代码,使其安装包hello
而不是平面模块hello.py
,将hello.py
移至hello/__init__.py
并将texto.txt
移至hello/texto.txt
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.