我有一个应用程序,当未传递命令行参数时,默认为文件夹./wordlists
中找到的默认文件。这在主机文件夹中工作正常,但是一旦我运行setup.py install
应用程序就会丢失引用,我不确定为什么。
这是我目前 setup.py:
from setuptools import find_packages, setup
def dependencies(file):
with open(file) as f:
return f.read().splitlines()
with open("README.md") as f:
setup(
name="<redacted>",
license="<redacted>",
description="<redacted>",
long_description=f.read(),
author="<redacted>",
author_email="<redacted>",
url="<redacted>",
packages=find_packages(exclude=('tests')),
package_data={'wordlists': ['*.txt', './wordlists/*.txt']},
scripts=['<redacted>'],
install_requires=dependencies('requirements.txt'),
tests_require=dependencies('test-requirements.txt'),
include_package_data=True)
如前所述,我可以使用以下方法在我的目录中运行该应用程序:
python ./VHostScan.py -t <target>
然后它将默认为单词列表:
./wordlists/virtual-host-scanning.txt
但是,在使用./setup.py install
然后尝试运行应用程序后,它会丢失指向单词列表的链接。
这是我试图添加到我的 setup.py 中的内容,但我猜我需要在这里进行更改,或者单词列表引用在哪里:
package_data={'wordlists': ['*.txt', './wordlists/*.txt']},
这是我引用默认单词列表文件的方式:
DEFAULT_WORDLIST_FILE = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'wordlists',
'virtual-host-scanning.txt'
)
如果需要,完整的代码库可在此处获得:https://github.com/codingo/VHostScan/
setup.py
和软件包中的问题:
- 你有一个模块
VHostScan.py
在顶部,但没有在setup.py
中列出;因此,它没有安装,也没有包含在二进制发行版中。
要修复:添加py_modules=['VHostScan.py']
.
- 目录
wordlists
不是 Python 包,因此find_packages
找不到它,因此不包括package_data
文件。
我看到 2 种修复方法:
a) 将目录wordlists
Python 包中(添加一个空__init__.py
);
b) 将package_data
应用于lib
包:
package_data={'lib': ['../wordlists/*.txt']},