Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mikf
GitHub Repository: mikf/gallery-dl
Path: blob/master/setup.py
5399 views
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
4
import re
5
import sys
6
import os.path
7
import warnings
8
9
10
def read(fname):
11
path = os.path.join(os.path.dirname(__file__), fname)
12
with open(path, encoding="utf-8") as fp:
13
return fp.read()
14
15
16
def check_file(fname):
17
path = os.path.join(os.path.dirname(__file__), fname)
18
if os.path.exists(path):
19
return True
20
warnings.warn(
21
"Not including file '{}' since it is not present. "
22
"Run 'make' to build all automatically generated files.".format(fname)
23
)
24
return False
25
26
27
# get version without importing the package
28
VERSION = re.search(
29
r'__version__\s*=\s*"([^"]+)"',
30
read("gallery_dl/version.py"),
31
)[1]
32
33
FILES = [
34
(path, [f for f in files if check_file(f)])
35
for (path, files) in [
36
("share/bash-completion/completions", ["data/completion/gallery-dl"]),
37
("share/zsh/site-functions" , ["data/completion/_gallery-dl"]),
38
("share/fish/vendor_completions.d" , ["data/completion/gallery-dl.fish"]),
39
("share/man/man1" , ["data/man/gallery-dl.1"]),
40
("share/man/man5" , ["data/man/gallery-dl.conf.5"]),
41
]
42
]
43
44
PACKAGES = [
45
"gallery_dl",
46
"gallery_dl.extractor",
47
"gallery_dl.downloader",
48
"gallery_dl.postprocessor",
49
]
50
51
DESCRIPTION = ("Command-line program to download image galleries and "
52
"collections from several image hosting sites")
53
LONG_DESCRIPTION = read("README.rst").replace(
54
"<docs/", "<https://github.com/mikf/gallery-dl/blob/master/docs/")
55
56
57
def build_py2exe():
58
from py2exe import freeze
59
60
# py2exe dislikes version specifiers with a trailing '-dev'
61
VERSION_ = VERSION.partition("-")[0]
62
63
freeze(
64
console=[{
65
"script" : "./gallery_dl/__main__.py",
66
"dest_base" : "gallery-dl",
67
}],
68
version_info={
69
"version" : VERSION_,
70
"description" : DESCRIPTION,
71
"comments" : LONG_DESCRIPTION,
72
"product_name" : "gallery-dl",
73
"product_version": VERSION_,
74
},
75
options={
76
"bundle_files" : 0,
77
"compressed" : 1,
78
"optimize" : 1,
79
"dist_dir" : "./dist",
80
"packages" : PACKAGES,
81
"includes" : ["youtube_dl"],
82
"dll_excludes" : ["w9xpopen.exe"],
83
},
84
zipfile=None,
85
)
86
87
88
def build_setuptools():
89
from setuptools import setup
90
91
setup(
92
name="gallery_dl",
93
version=VERSION,
94
description=DESCRIPTION,
95
long_description=LONG_DESCRIPTION,
96
url="https://github.com/mikf/gallery-dl",
97
download_url="https://github.com/mikf/gallery-dl/releases/latest",
98
author="Mike Fährmann",
99
author_email="[email protected]",
100
maintainer="Mike Fährmann",
101
maintainer_email="[email protected]",
102
license="GPLv2",
103
python_requires=">=3.8",
104
install_requires=[
105
"requests>=2.11.0",
106
],
107
extras_require={
108
"video": [
109
"yt-dlp",
110
],
111
"extra": [
112
"requests[socks]",
113
"yt-dlp[default]",
114
"jinja2",
115
"pyyaml",
116
"toml; python_version < '3.11'",
117
"truststore; python_version >= '3.10'",
118
"secretstorage; sys_platform == 'linux'",
119
],
120
},
121
entry_points={
122
"console_scripts": [
123
"gallery-dl = gallery_dl:main",
124
],
125
},
126
packages=PACKAGES,
127
data_files=FILES,
128
test_suite="test",
129
keywords="image gallery downloader crawler scraper",
130
classifiers=[
131
"Development Status :: 5 - Production/Stable",
132
"Environment :: Console",
133
"Intended Audience :: End Users/Desktop",
134
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
135
"Operating System :: OS Independent",
136
"Programming Language :: Python",
137
"Programming Language :: Python :: 3",
138
"Programming Language :: Python :: 3 :: Only",
139
"Programming Language :: Python :: 3.8",
140
"Programming Language :: Python :: 3.9",
141
"Programming Language :: Python :: 3.10",
142
"Programming Language :: Python :: 3.11",
143
"Programming Language :: Python :: 3.12",
144
"Programming Language :: Python :: 3.13",
145
"Programming Language :: Python :: Implementation :: CPython",
146
"Programming Language :: Python :: Implementation :: PyPy",
147
"Topic :: Internet :: WWW/HTTP",
148
"Topic :: Multimedia :: Graphics",
149
"Topic :: Utilities",
150
],
151
)
152
153
154
if "py2exe" in sys.argv:
155
build_py2exe()
156
else:
157
build_setuptools()
158
159