forked from maurosoria/dirsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·120 lines (106 loc) · 3.86 KB
/
setup.py
File metadata and controls
executable file
·120 lines (106 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
# Author: Mauro Soria
import ast
import os
import shutil
import tempfile
from pathlib import Path
import setuptools
ROOT = Path(__file__).resolve().parent
# Preserve the historical packaged layout until the repository is reorganized.
# The built distribution expects a top-level "dirsearch" package that contains
# the entry module, config.ini, db/, and the lib/ package tree.
env_dir = tempfile.mkdtemp(prefix="dirsearch-install-")
package_root = Path(env_dir, "dirsearch")
shutil.copytree(
ROOT,
package_root,
ignore=shutil.ignore_patterns(
".git",
".github",
".cache",
".venv",
"build",
"dist",
"__pycache__",
"*.pyc",
"*.pyo",
"*.pyd",
"tests",
"sessions",
),
)
os.chdir(env_dir)
def package_files(directory: Path) -> list[str]:
files: list[str] = []
for path in sorted(directory.rglob("*")):
if path.is_file():
files.append(str(path.relative_to(package_root)))
return files
def read_version(path: Path) -> str:
module = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
for node in module.body:
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name) and target.id == "VERSION":
value = ast.literal_eval(node.value)
if isinstance(value, str):
return value
raise RuntimeError(f"Unable to find VERSION in {path}")
def read_requirements(path: Path) -> list[str]:
requirements: list[str] = []
for line in path.read_text(encoding="utf-8").splitlines():
requirement = line.strip()
if requirement and not requirement.startswith("#"):
requirements.append(requirement)
return requirements
setuptools.setup(
name="dirsearch",
description="Advanced web path scanner",
version=read_version(ROOT / "lib/core/settings.py"),
python_requires=">=3.11",
classifiers=[
"Programming Language :: Python",
"Environment :: Console",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Operating System :: OS Independent",
"Topic :: Security",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
],
install_requires=read_requirements(ROOT / "requirements/runtime.txt"),
extras_require={
"mysql": ["mysql-connector-python==9.6.0"],
"postgresql": ["psycopg[binary]==3.3.3"],
"db": read_requirements(ROOT / "requirements/db.txt"),
},
entry_points={"console_scripts": ["dirsearch=dirsearch.dirsearch:main"]},
packages=setuptools.find_packages(exclude=("dirsearch.tests", "dirsearch.tests.*")),
package_data={
"dirsearch": [
"config.ini",
*package_files(package_root / "db"),
],
"dirsearch.lib.report": ["templates/*.html"],
},
include_package_data=False,
)