py3createtorrent

raw JSON →
1.2.1 verified Mon Apr 27 auth: no python

Command-line tool and Python module for creating torrent files. Version 1.2.1 supports multithreading, trackerless torrents, and bestN trackers shortcut. Requires Python 3.5-3.11. Active development on GitHub.

pip install py3createtorrent
error ModuleNotFoundError: No module named 'py3bencode'
cause Missing dependency py3bencode, though it should be installed automatically.
fix
Run: pip install py3bencode
error py3createtorrent 1.2.0 requires typing-extensions, which is not installed.
cause Python <3.8 lacks typing-extensions, but it's not listed as automatic dependency for old Python versions.
fix
Install typing-extensions: pip install typing-extensions
error UnicodeEncodeError: 'charmap' codec can't encode character
cause File paths contain characters not supported by terminal's encoding.
fix
Upgrade to py3createtorrent>=1.2.1 or set environment variable PYTHONIOENCODING=utf-8 before running.
breaking License changed from GPL to LGPL in v1.2.0. If you relied on GPL, check compatibility.
fix No action needed unless license compliance is an issue; LGPL is more permissive.
gotcha Python 3.7 and earlier require typing-extensions. Without it, import may fail.
fix Install typing-extensions: pip install typing-extensions or upgrade to Python 3.8+.
gotcha UnicodeEncodeError when printing paths with rare characters. Fixed in v1.2.1b1.
fix Upgrade to py3createtorrent>=1.2.1 or set PYTHONIOENCODING=utf-8.
deprecated Old default piece size maximum (16 MiB) increased to 64 MiB in v1.2.0. Torrents created with older version may have different piece sizes.
fix Review piece size if backward compatibility needed; use --piece-size-min/--piece-size-max to override.
breaking Specifying trackers became optional (--trackers flag) in v1.0.0; trackerless torrents now possible.
fix Update scripts that always passed trackers; now you can omit them.

Create a torrent file with trackers.

from py3createtorrent import createTorrent

createTorrent(
    source='/path/to/files',
    output='/path/to/output.torrent',
    trackers=['udp://tracker.opentrackr.org:1337/announce'],
    name='My Torrent'
)