update setup.py

- add 'cloudflare' and 'video' extra install target (#460)
  (e.g. 'pip install gallery-dl[cloudflare]')
- remove py2exe and distutils code
- get version without calling exec()
- inline variables
pull/465/head
Mike Fährmann 5 years ago
parent e877ca97c3
commit e782b4b230
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1,22 +1,15 @@
#!/usr/bin/env python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function import re
import sys import sys
import os.path import os.path
import warnings import warnings
from setuptools import setup
if sys.hexversion < 0x3040000: if sys.hexversion < 0x3040000:
sys.exit("Python 3.4+ required") sys.exit("Python 3.4+ required")
try:
from setuptools import setup
has_setuptools = True
except ImportError:
from distutils.core import setup
has_setuptools = False
def read(fname): def read(fname):
path = os.path.join(os.path.dirname(__file__), fname) path = os.path.join(os.path.dirname(__file__), fname)
@ -24,7 +17,8 @@ def read(fname):
return file.read() return file.read()
def check_file(fname): def check_file(fname):
if os.path.exists(fname): path = os.path.join(os.path.dirname(__file__), fname)
if os.path.exists(path):
return True return True
warnings.warn( warnings.warn(
"Not including file '{}' since it is not present. " "Not including file '{}' since it is not present. "
@ -34,51 +28,12 @@ def check_file(fname):
# get version without importing the package # get version without importing the package
exec(read("gallery_dl/version.py")) VERSION = re.search(
r'__version__\s*=\s*"([^"]+)"',
DESCRIPTION = ("Command-line program to download image-galleries and " read("gallery_dl/version.py"),
"-collections from several image hosting sites") ).group(1)
LONG_DESCRIPTION = read("README.rst")
if "py2exe" in sys.argv:
try:
import py2exe
except ImportError:
sys.exit("Error importing 'py2exe'")
params = {
"console": [{
"script": "./gallery_dl/__main__.py",
"dest_base": "gallery-dl",
"version": __version__,
"description": DESCRIPTION,
"comments": LONG_DESCRIPTION,
"product_name": "gallery-dl",
"product_version": __version__,
}],
"options": {"py2exe": {
"bundle_files": 0,
"compressed": 1,
"optimize": 1,
"dist_dir": ".",
"packages": ["gallery_dl"],
"dll_excludes": ["w9xpopen.exe"],
}},
"zipfile": None,
}
elif has_setuptools:
params = {
"entry_points": {
"console_scripts": [
"gallery-dl = gallery_dl:main"
]
}
}
else:
params = {
"scripts": ["bin/gallery-dl"]
}
data_files = [ FILES = [
(path, [f for f in files if check_file(f)]) (path, [f for f in files if check_file(f)])
for (path, files) in [ for (path, files) in [
('etc/bash_completion.d', ['gallery-dl.bash_completion']), ('etc/bash_completion.d', ['gallery-dl.bash_completion']),
@ -90,9 +45,10 @@ data_files = [
setup( setup(
name="gallery_dl", name="gallery_dl",
version=__version__, version=VERSION,
description=DESCRIPTION, description=("Command-line program to download image-galleries and "
long_description=LONG_DESCRIPTION, "-collections from several image hosting sites"),
long_description=read("README.rst"),
url="https://github.com/mikf/gallery-dl", url="https://github.com/mikf/gallery-dl",
download_url="https://github.com/mikf/gallery-dl/releases/latest", download_url="https://github.com/mikf/gallery-dl/releases/latest",
author="Mike Fährmann", author="Mike Fährmann",
@ -104,13 +60,27 @@ setup(
install_requires=[ install_requires=[
"requests>=2.11.0", "requests>=2.11.0",
], ],
extras_require={
"cloudflare": [
"pyOpenSSL>=19.0.0",
"cryptography>=2.8.0",
],
"video": [
"youtube-dl",
],
},
packages=[ packages=[
"gallery_dl", "gallery_dl",
"gallery_dl.extractor", "gallery_dl.extractor",
"gallery_dl.downloader", "gallery_dl.downloader",
"gallery_dl.postprocessor", "gallery_dl.postprocessor",
], ],
data_files=data_files, entry_points={
"console_scripts": [
"gallery-dl = gallery_dl:main",
],
},
data_files=FILES,
keywords="image gallery downloader crawler scraper", keywords="image gallery downloader crawler scraper",
classifiers=[ classifiers=[
"Development Status :: 5 - Production/Stable", "Development Status :: 5 - Production/Stable",
@ -124,11 +94,11 @@ setup(
"Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3 :: Only",
"Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP",
"Topic :: Multimedia :: Graphics", "Topic :: Multimedia :: Graphics",
"Topic :: Utilities", "Topic :: Utilities",
], ],
test_suite="test", test_suite="test",
**params
) )

Loading…
Cancel
Save