Compare commits

...

15 Commits

Author SHA1 Message Date
bashonly
1be72886b7
Fix TOML syntax in optional dependencies
Authored by: bashonly
2024-01-13 21:53:25 -06:00
bashonly
1411597572
Add py2exe optional dependency group
Authored by: bashonly
2024-01-13 21:08:15 -06:00
bashonly
6ab6c893c4
Remove requirements.txt
Authored by: bashonly
2024-01-13 20:56:11 -06:00
bashonly
5d1a8ed447
Remove setup.py
Authored by: bashonly
2024-01-13 20:54:56 -06:00
bashonly
561a4db9c1
Replace requirements.txt with pyproject.toml in MANIFEST.in
Authored by: bashonly
2024-01-13 20:54:49 -06:00
bashonly
612ac465be
[Makefile] Replace requirements.txt and setup.py usage with pyproject.toml
Authored by: bashonly
2024-01-13 20:54:32 -06:00
bashonly
358d57e40a
[Makefile] Add pyproject.toml recipes to pypi-files and clean-dist
Authored by: bashonly
2024-01-13 20:53:00 -06:00
bashonly
f5343dc654
[devscripts] Add include_data_files.py
Authored by: bashonly
2024-01-13 15:52:30 -06:00
bashonly
11968f55b2
Add py2exe.py
Authored by: bashonly
2024-01-13 15:22:05 -06:00
bashonly
2c323bd112
Add project.entry-points.pyinstaller40
Authored by: bashonly
2024-01-12 17:34:13 -06:00
bashonly
46f86b13da
Add build, pyinst, ci, dev optional dependencies groups
Authored by: bashonly
2024-01-12 17:15:52 -06:00
bashonly
e1279978ba
Move mutagen to dependencies
Authored by: bashonly
2024-01-12 17:14:28 -06:00
bashonly
3d3abae173
readme does not need to be dynamic
Authored by: bashonly
2024-01-12 17:06:26 -06:00
bashonly
877d9c4dbd
Add "Python :: 3 :: Only" classifier
Authored by: bashonly
2024-01-12 17:03:03 -06:00
bashonly
90d42358a3
Bump required setuptools to >=61
Authored by: bashonly
2024-01-12 17:02:29 -06:00
7 changed files with 157 additions and 212 deletions

View File

@ -5,6 +5,6 @@ include README.md
include completions/*/*
include supportedsites.md
include yt-dlp.1
include requirements.txt
include pyproject.toml
recursive-include devscripts *
recursive-include test *

View File

@ -6,11 +6,20 @@ doc: README.md CONTRIBUTING.md issuetemplates supportedsites
ot: offlinetest
tar: yt-dlp.tar.gz
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/man
SHAREDIR ?= $(PREFIX)/share
PYTHON ?= /usr/bin/env python3
# Keep this list in sync with MANIFEST.in
# intended use: when building a source distribution,
# make pypi-files && python setup.py sdist
# make pypi-files && python3 -m build -s .
pypi-files: AUTHORS Changelog.md LICENSE README.md README.txt supportedsites \
completions yt-dlp.1 requirements.txt setup.cfg devscripts/* test/*
completions yt-dlp.1 pyproject.toml setup.cfg devscripts/* test/*
-mv -f pyproject.toml.old pyproject.toml
cp -f pyproject.toml pyproject.toml.old
$(PYTHON) devscripts/include_data_files.py pyproject.toml
.PHONY: all clean install test tar pypi-files completions ot offlinetest codetest supportedsites
@ -20,6 +29,7 @@ clean-test:
*.3gp *.ape *.ass *.avi *.desktop *.f4v *.flac *.flv *.gif *.jpeg *.jpg *.m4a *.m4v *.mhtml *.mkv *.mov *.mp3 \
*.mp4 *.mpga *.oga *.ogg *.opus *.png *.sbv *.srt *.swf *.swp *.tt *.ttml *.url *.vtt *.wav *.webloc *.webm *.webp
clean-dist:
-mv -f pyproject.toml.old pyproject.toml
rm -rf yt-dlp.1.temp.md yt-dlp.1 README.txt MANIFEST build/ dist/ .coverage cover/ yt-dlp.tar.gz completions/ \
yt_dlp/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp yt-dlp yt-dlp.exe yt_dlp.egg-info/ AUTHORS .mailmap
clean-cache:
@ -32,12 +42,6 @@ completion-fish: completions/fish/yt-dlp.fish
completion-zsh: completions/zsh/_yt-dlp
lazy-extractors: yt_dlp/extractor/lazy_extractors.py
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/man
SHAREDIR ?= $(PREFIX)/share
PYTHON ?= /usr/bin/env python3
# set SYSCONFDIR to /etc if PREFIX=/usr or PREFIX=/usr/local
SYSCONFDIR = $(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi)
@ -145,7 +149,7 @@ yt-dlp.tar.gz: all
README.md supportedsites.md Changelog.md LICENSE \
CONTRIBUTING.md Collaborators.md CONTRIBUTORS AUTHORS \
Makefile MANIFEST.in yt-dlp.1 README.txt completions \
setup.py setup.cfg yt-dlp yt_dlp requirements.txt \
setup.cfg yt-dlp yt_dlp pyproject.toml \
devscripts test
AUTHORS: .mailmap

View File

@ -0,0 +1,54 @@
#!/usr/bin/env python3
# Allow execution from anywhere
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from pathlib import Path
from devscripts.utils import get_filename_args, read_file
TABLE_HEADER = '[tool.setuptools.data-files]'
FILES_SPEC = {
'share/bash-completion/completions': ['completions/bash/yt-dlp'],
'share/zsh/site-functions': ['completions/zsh/_yt-dlp'],
'share/fish/vendor_completions.d': ['completions/fish/yt-dlp.fish'],
'share/doc/yt_dlp': ['README.txt'],
'share/man/man1': ['yt-dlp.1'],
}
def build_data_files(input_file):
project_root = Path(input_file).resolve().parent
for dirname, files in FILES_SPEC.items():
resfiles = [fn for fn in files if (project_root / fn).is_file()]
if resfiles:
yield f'"{dirname}" = {resfiles!r}\n'
def main():
tomlfile = get_filename_args(default_outfile='pyproject.toml')
if TABLE_HEADER in read_file(tomlfile):
print(
f'{tomlfile!r} already contains a data-files table. '
+ 'Try running "make clean" or "git checkout ."',
file=sys.stderr)
return 1
data_files = list(build_data_files(tomlfile))
if not data_files:
print('No data files to include. Try running "make pypi-files"', file=sys.stderr)
return # `make` should not error here
with open(tomlfile, 'a', encoding='utf-8') as f:
f.write(f'\n{TABLE_HEADER}\n')
f.writelines(data_files)
if __name__ == '__main__':
sys.exit(main())

61
py2exe.py Normal file
View File

@ -0,0 +1,61 @@
#!/usr/bin/env python3
# Allow execution from anywhere
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import warnings
from devscripts.utils import read_version
from py2exe import freeze
VERSION = read_version(varname='_pkg_version')
def py2exe_params():
warnings.warn(
'py2exe builds do not support pycryptodomex and needs VC++14 to run. '
'It is recommended to run "pyinst.py" to build using pyinstaller instead')
return {
'console': [{
'script': './yt_dlp/__main__.py',
'dest_base': 'yt-dlp',
'icon_resources': [(1, 'devscripts/logo.ico')],
}],
'version_info': {
'version': VERSION,
'description': 'A youtube-dl fork with additional features and patches',
'comments': 'Official repository: <https://github.com/yt-dlp/yt-dlp>',
'product_name': 'yt-dlp',
'product_version': VERSION,
},
'options': {
'bundle_files': 0,
'compressed': 1,
'optimize': 2,
'dist_dir': './dist',
'excludes': [
# py2exe cannot import Crypto
'Crypto',
'Cryptodome',
# py2exe appears to confuse this with our socks library.
# We don't use pysocks and urllib3.contrib.socks would fail to import if tried.
'urllib3.contrib.socks'
],
'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'],
# Modules that are only imported dynamically must be added here
'includes': ['yt_dlp.compat._legacy', 'yt_dlp.compat._deprecated',
'yt_dlp.utils._legacy', 'yt_dlp.utils._deprecated'],
},
'zipfile': None,
}
def main():
return freeze(py2exe_params())
main()

View File

@ -1,8 +1,6 @@
[build-system]
build-backend = 'setuptools.build_meta'
# https://github.com/yt-dlp/yt-dlp/issues/5941
# https://github.com/pypa/distutils/issues/17
requires = ['setuptools > 50']
build-backend = "setuptools.build_meta"
requires = ["setuptools>=61"]
[project]
name = "yt-dlp"
@ -11,6 +9,7 @@ maintainers = [
{name = "Grub4K", email = "contact@grub4k.xyz"},
]
description = "A youtube-dl fork with additional features and patches"
readme = "README.md"
requires-python = ">=3.8"
keywords = [
"youtube-dl",
@ -26,6 +25,7 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
@ -37,12 +37,12 @@ classifiers = [
"License :: Public Domain",
"Operating System :: OS Independent",
]
dynamic = ["version", "readme"]
dynamic = ["version"]
dependencies = [
"brotli; implementation_name=='cpython'",
"brotlicffi; implementation_name!='cpython'",
"certifi",
"mutagen",
"pycryptodomex",
"requests>=2.31.0,<3",
"urllib3>=1.26.17,<3",
@ -50,8 +50,23 @@ dependencies = [
]
[project.optional-dependencies]
mutagen = ["mutagen"]
secretstorage = ["secretstorage"]
build = [
"pip",
"setuptools>=61",
"wheel",
]
pyinst = ["Pyinstaller>=6.3"]
py2exe = ["py2exe>=0.12"]
ci = [
"flake8",
"pytest",
]
dev = [
"flake8",
"isort",
"pytest",
]
[project.urls]
Documentation = "https://github.com/yt-dlp/yt-dlp#readme"
@ -59,12 +74,14 @@ Repository = "https://github.com/yt-dlp/yt-dlp"
Tracker = "https://github.com/yt-dlp/yt-dlp/issues"
Funding = "https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators"
[project.scripts]
yt-dlp = "yt_dlp:main"
[project.entry-points.pyinstaller40]
hook-dirs = "yt_dlp.__pyinstaller:get_hook_dirs"
[tool.setuptools]
packages = ["yt_dlp"]
[tool.setuptools.dynamic]
version = {attr = "yt_dlp.version._pkg_version"}
readme = {file = ["README.md"], content-type = "text/markdown"}
[project.scripts]
yt-dlp = "yt_dlp:main"

View File

@ -1,8 +0,0 @@
mutagen
pycryptodomex
brotli; implementation_name=='cpython'
brotlicffi; implementation_name!='cpython'
certifi
requests>=2.31.0,<3
urllib3>=1.26.17,<3
websockets>=12.0

183
setup.py
View File

@ -1,183 +0,0 @@
#!/usr/bin/env python3
# Allow execution from anywhere
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import subprocess
import warnings
try:
from setuptools import Command, find_packages, setup
setuptools_available = True
except ImportError:
from distutils.core import Command, setup
setuptools_available = False
from devscripts.utils import read_file, read_version
VERSION = read_version(varname='_pkg_version')
DESCRIPTION = 'A youtube-dl fork with additional features and patches'
LONG_DESCRIPTION = '\n\n'.join((
'Official repository: <https://github.com/yt-dlp/yt-dlp>',
'**PS**: Some links in this document will not work since this is a copy of the README.md from Github',
read_file('README.md')))
REQUIREMENTS = read_file('requirements.txt').splitlines()
def packages():
if setuptools_available:
return find_packages(exclude=('youtube_dl', 'youtube_dlc', 'test', 'ytdlp_plugins', 'devscripts'))
return [
'yt_dlp', 'yt_dlp.extractor', 'yt_dlp.downloader', 'yt_dlp.postprocessor', 'yt_dlp.compat',
]
def py2exe_params():
warnings.warn(
'py2exe builds do not support pycryptodomex and needs VC++14 to run. '
'It is recommended to run "pyinst.py" to build using pyinstaller instead')
return {
'console': [{
'script': './yt_dlp/__main__.py',
'dest_base': 'yt-dlp',
'icon_resources': [(1, 'devscripts/logo.ico')],
}],
'version_info': {
'version': VERSION,
'description': DESCRIPTION,
'comments': LONG_DESCRIPTION.split('\n')[0],
'product_name': 'yt-dlp',
'product_version': VERSION,
},
'options': {
'bundle_files': 0,
'compressed': 1,
'optimize': 2,
'dist_dir': './dist',
'excludes': [
# py2exe cannot import Crypto
'Crypto',
'Cryptodome',
# py2exe appears to confuse this with our socks library.
# We don't use pysocks and urllib3.contrib.socks would fail to import if tried.
'urllib3.contrib.socks'
],
'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'],
# Modules that are only imported dynamically must be added here
'includes': ['yt_dlp.compat._legacy', 'yt_dlp.compat._deprecated',
'yt_dlp.utils._legacy', 'yt_dlp.utils._deprecated'],
},
'zipfile': None,
}
def build_params():
files_spec = [
('share/bash-completion/completions', ['completions/bash/yt-dlp']),
('share/zsh/site-functions', ['completions/zsh/_yt-dlp']),
('share/fish/vendor_completions.d', ['completions/fish/yt-dlp.fish']),
('share/doc/yt_dlp', ['README.txt']),
('share/man/man1', ['yt-dlp.1'])
]
data_files = []
for dirname, files in files_spec:
resfiles = []
for fn in files:
if not os.path.exists(fn):
warnings.warn(f'Skipping file {fn} since it is not present. Try running " make pypi-files " first')
else:
resfiles.append(fn)
data_files.append((dirname, resfiles))
params = {'data_files': data_files}
if setuptools_available:
params['entry_points'] = {
'console_scripts': ['yt-dlp = yt_dlp:main'],
'pyinstaller40': ['hook-dirs = yt_dlp.__pyinstaller:get_hook_dirs'],
}
else:
params['scripts'] = ['yt-dlp']
return params
class build_lazy_extractors(Command):
description = 'Build the extractor lazy loading module'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
if self.dry_run:
print('Skipping build of lazy extractors in dry run mode')
return
subprocess.run([sys.executable, 'devscripts/make_lazy_extractors.py'])
def main():
if sys.argv[1:2] == ['py2exe']:
params = py2exe_params()
try:
from py2exe import freeze
except ImportError:
import py2exe # noqa: F401
warnings.warn('You are using an outdated version of py2exe. Support for this version will be removed in the future')
params['console'][0].update(params.pop('version_info'))
params['options'] = {'py2exe': params.pop('options')}
else:
return freeze(**params)
else:
params = build_params()
setup(
name='yt-dlp', # package name (do not change/remove comment)
version=VERSION,
maintainer='pukkandan',
maintainer_email='pukkandan.ytdlp@gmail.com',
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
long_description_content_type='text/markdown',
url='https://github.com/yt-dlp/yt-dlp',
packages=packages(),
install_requires=REQUIREMENTS,
python_requires='>=3.8',
project_urls={
'Documentation': 'https://github.com/yt-dlp/yt-dlp#readme',
'Source': 'https://github.com/yt-dlp/yt-dlp',
'Tracker': 'https://github.com/yt-dlp/yt-dlp/issues',
'Funding': 'https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators',
},
classifiers=[
'Topic :: Multimedia :: Video',
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Programming Language :: Python',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'License :: Public Domain',
'Operating System :: OS Independent',
],
cmdclass={'build_lazy_extractors': build_lazy_extractors},
**params
)
main()