Compare commits

..

No commits in common. "b6db88516793004a0d47bc6948a66ee90be0d9db" and "d6bf35001d8de6902f87d7457e621f5a7ec8dfa4" have entirely different histories.

6 changed files with 94 additions and 47 deletions

10
MANIFEST.in Normal file
View File

@ -0,0 +1,10 @@
include AUTHORS
include Changelog.md
include LICENSE
include README.md
include completions/*/*
include supportedsites.md
include yt-dlp.1
include pyproject.toml
recursive-include devscripts *
recursive-include test *

View File

@ -1,16 +1,25 @@
all: lazy-extractors yt-dlp doc pypi-files
clean: clean-test clean-dist
clean: clean-test clean-dist clean-pyproject
clean-all: clean clean-cache
completions: completion-bash completion-fish completion-zsh
doc: README.md CONTRIBUTING.md issuetemplates supportedsites
ot: offlinetest
tar: yt-dlp.tar.gz
# Keep this list in sync with pyproject.toml includes/artifacts
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 && python3 -m build -sn .
pypi-files: AUTHORS Changelog.md LICENSE README.md README.txt supportedsites \
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
@ -22,6 +31,8 @@ clean-test:
clean-dist:
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
clean-pyproject:
-mv -f pyproject.toml.old pyproject.toml
clean-cache:
find . \( \
-type d -name .pytest_cache -o -type d -name __pycache__ -o -name "*.pyc" -o -name "*.class" \
@ -32,12 +43,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)
@ -144,8 +149,9 @@ yt-dlp.tar.gz: all
-- \
README.md supportedsites.md Changelog.md LICENSE \
CONTRIBUTING.md Collaborators.md CONTRIBUTORS AUTHORS \
Makefile yt-dlp.1 README.txt completions .gitignore \
setup.cfg yt-dlp yt_dlp pyproject.toml devscripts test
Makefile MANIFEST.in yt-dlp.1 README.txt completions \
setup.cfg yt-dlp yt_dlp pyproject.toml \
devscripts test
AUTHORS:
git shortlog -s -n HEAD | cut -f2 | sort > AUTHORS

View File

@ -362,6 +362,7 @@ py -m bundle.py2exe
* **`devscripts/set-variant.py`** - Set the build variant of the executable.
* **`devscripts/make_changelog.py`** - Create a markdown changelog using short commit messages and update `CONTRIBUTORS` file.
* **`devscripts/make_lazy_extractors.py`** - Create lazy extractors. Running this before building the binaries (any variant) will improve their startup performance. Set the environment variable `YTDLP_NO_LAZY_EXTRACTORS=1` if you wish to forcefully disable lazy extractor loading.
* **`devscripts/include_data_files.py`** - Running this before building a wheel will ensure any generated documentation and/or shell completions will be included in the wheel.
Note: See their `--help` for more info.

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-pyproject" or "git restore pyproject.toml"',
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())

View File

@ -1,6 +1,6 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
build-backend = "setuptools.build_meta"
requires = ["setuptools>=61", "wheel"]
[project]
name = "yt-dlp"
@ -56,8 +56,8 @@ pyinstaller = ["pyinstaller>=6.3"]
py2exe = ["py2exe>=0.12"]
build = [
"build",
"hatchling",
"pip",
"setuptools>=61",
"wheel",
]
dev = [
@ -78,38 +78,10 @@ yt-dlp = "yt_dlp:main"
[project.entry-points.pyinstaller40]
hook-dirs = "yt_dlp.__pyinstaller:get_hook_dirs"
[tool.hatch.build.targets.sdist]
include = [
"/yt_dlp",
"/devscripts",
"/test",
"/.gitignore", # included by default, needed for auto-excludes
"/Changelog.md",
"/LICENSE", # included as license
"/pyproject.toml", # included by default
"/README.md", # included as readme
"/setup.cfg",
"/supportedsites.md",
]
artifacts = [
"/yt_dlp/extractor/lazy_extractors.py",
"/completions",
"/AUTHORS", # included by default
"/README.txt",
"/yt-dlp.1",
]
[tool.setuptools.packages.find]
include = ["yt_dlp*"]
exclude = ["youtube_dl*", "youtube_dlc*", "test*", "ytdlp_plugins*", "devscripts*", "bundle*"]
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
[tool.hatch.build.targets.wheel]
packages = ["yt_dlp"]
artifacts = ["/yt_dlp/extractor/lazy_extractors.py"]
[tool.hatch.build.targets.wheel.shared-data]
"completions/bash/yt-dlp" = "share/bash-completion/completions/yt-dlp"
"completions/zsh/_yt-dlp" = "share/zsh/site-functions/_yt-dlp"
"completions/fish/yt-dlp.fish" = "share/fish/vendor_completions.d/yt-dlp.fish"
"README.txt" = "share/doc/yt_dlp/README.txt"
"yt-dlp.1" = "share/man/man1/yt-dlp.1"
[tool.hatch.version]
path = "yt_dlp/version.py"
pattern = "_pkg_version = '(?P<version>[^']+)'"
[tool.setuptools.dynamic]
version = {attr = "yt_dlp.version._pkg_version"}

View File

@ -1,3 +1,7 @@
[bdist_wheel]
python-tag = py38
[flake8]
exclude = build,venv,.tox,.git,.pytest_cache
ignore = E402,E501,E731,E741,W503