Metadata-Version: 2.4
Name: py3createtorrent
Version: 2.0.0b2
Summary: Create torrents via command line!
Keywords: torrents,commandline,shell,script
Author: Robert Nitsch
Author-email: Robert Nitsch <mail@robertnitsch.de>
License-Expression: LGPL-3.0-or-later
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: System Administrators
Classifier: Topic :: Communications :: File Sharing
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Typing :: Typed
Requires-Dist: bencode-py~=4.1
Requires-Python: >=3.11
Project-URL: Homepage, https://github.com/rsnitsch/py3createtorrent
Project-URL: Documentation, https://py3createtorrent.readthedocs.io/en/latest/user.html
Project-URL: Bug Reports, https://github.com/rsnitsch/py3createtorrent/issues
Project-URL: Source, https://github.com/rsnitsch/py3createtorrent
Description-Content-Type: text/x-rst

py3createtorrent
================

|pypi| |python| |tests| |coverage| |audit| |docs| |uv| |ruff| |license|

.. |pypi| image:: https://img.shields.io/pypi/v/py3createtorrent.svg
   :target: https://pypi.org/project/py3createtorrent/
   :alt: PyPI

.. |python| image:: https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13%20%7C%203.14%20%7C%203.15-blue.svg
   :target: https://pypi.org/project/py3createtorrent/#history
   :alt: Python Versions

.. |tests| image:: https://github.com/rsnitsch/py3createtorrent/actions/workflows/test.yml/badge.svg?branch=master
   :target: https://github.com/rsnitsch/py3createtorrent/actions/workflows/test.yml
   :alt: Tests

.. |coverage| image:: https://codecov.io/gh/rsnitsch/py3createtorrent/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/rsnitsch/py3createtorrent/branch/master
   :alt: Test Coverage

.. |audit| image:: https://github.com/rsnitsch/py3createtorrent/actions/workflows/pip-audit.yml/badge.svg?branch=master
   :target: https://github.com/rsnitsch/py3createtorrent/actions/workflows/pip-audit.yml
   :alt: Dependency Security Audit

.. |docs| image:: https://img.shields.io/readthedocs/py3createtorrent/latest.svg
   :target: https://py3createtorrent.readthedocs.io/en/latest/
   :alt: Documentation Status

.. |uv| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json
   :target: https://github.com/astral-sh/uv
   :alt: uv

.. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
   :target: https://github.com/astral-sh/ruff
   :alt: Ruff

.. |license| image:: https://img.shields.io/badge/License-LGPL_v3-blue.svg
   :target: https://www.gnu.org/licenses/lgpl-3.0
   :alt: License: LGPL v3

Create torrents via command line — classic v1, modern v2 or hybrid (BEP 52).

Features
--------

.. features-start

- **BitTorrent v1, v2, and hybrid support:** Generate classic v1, pure v2, or BEP 52 hybrid torrents.
- **Fast multithreaded hashing:** Utilizes multiple worker threads by default (configurable via ``--threads``)
  while reading file data in a single pass.
- **Flexible tracker & peer setup:** Add multiple trackers, automatically fetch the best trackers from
  `ngosang/trackerslist <https://github.com/ngosang/trackerslist>`_ (``bestN``), add DHT bootstrap nodes, or
  create trackerless torrents.
- **Webseed support:** Embed HTTP/FTP GetRight-style webseeds (``url-list``).
- **Private torrents & custom metadata:** Set the private flag (disabling DHT/PEX), add comments, source tags
  (for cross-seeding), custom torrent names, or custom ISO 8601 creation dates.
- **Fine-grained file filtering:** Exclude specific paths or match relative paths using case-sensitive or
  case-insensitive regular expressions.
- **Automatic or custom piece sizes:** Automatically selects a sensible piece size or lets you specify an
  exact power-of-two size.
- **Lightweight & scriptable:** Requires only Python 3.11+ and ``bencode.py``; usable both as a CLI tool and
  via a clean Python API (``TorrentSpec``, ``create_torrent``).

.. features-end

Basic usage
-----------

Creating a torrent is as simple as::

    py3createtorrent -t udp://tracker.opentrackr.org:1337/announce file_or_folder

The shortcut ``bestN`` can be used for conveniently adding the best N trackers
from `ngosang/trackerslist <https://github.com/ngosang/trackerslist>`_. Example::

    py3createtorrent -t best3 file_or_folder

Multiple trackers can also be specified manually by using ``-t`` multiple times, for example::

    py3createtorrent -t udp://tracker.opentrackr.org:1337/announce -t udp://tracker.cyberia.is:6969/announce file_or_folder

Install py3createtorrent 2.0 (beta)
-----------------------------------

*The 2.0 release is only available as a pre-release (beta).*

**Recommended (isolated CLI installation via uv or pipx):**

Using `uv <https://docs.astral.sh/uv/>`_::

    uv tool install --prerelease=allow py3createtorrent
    py3createtorrent --help

    # or without installation
    uvx --prerelease=allow py3createtorrent --help

Using `pipx <https://pipx.pypa.io/>`_::

    pipx install --pip-args="--pre" py3createtorrent
    py3createtorrent --help
    
    # or without installation
    pipx run --pip-args="--pre" py3createtorrent --help

Via ``pip``::

    pip install --pre py3createtorrent
    py3createtorrent --help

Install py3createtorrent 1.2 (stable)
-------------------------------------

py3createtorrent 1.2 requires Python 3.8 or later. Python 3.5 to Python 3.7 might be possible if you
install the ``typing-extensions`` module.

Note: The stable 1.2 version comes without v2/hybrid torrent support.

**Recommended (isolated CLI installation via uv or pipx):**

Using `uv <https://docs.astral.sh/uv/>`_::

    uv tool install py3createtorrent
    py3createtorrent --help

    # or without installation
    uvx py3createtorrent --help

Using `pipx <https://pipx.pypa.io/>`_::

    pipx install py3createtorrent
    py3createtorrent --help

    # or without installation
    pipx run py3createtorrent --help

Via ``pip``::

    pip install py3createtorrent
    py3createtorrent --help

Full documentation
------------------

For 2.x (beta):

https://py3createtorrent.readthedocs.io/en/latest/index.html

For 1.2 (stable):

https://py3createtorrent.readthedocs.io/en/v1.2.1/user.html

Performance
-----------

py3createtorrent v2.0 is one of the fastest torrent creation tools available.

Here are the benchmark results for creating a torrent for a folder containing 10.5 GB in 101 files:

============================= ================== ====== ======
Command                       Mean Wall Time [s] Change Factor
============================= ================== ====== ======
``py3createtorrent v2.0.0a2`` 7.516 ± 0.137             1
``mkbrr 1.28.0``              7.133 ± 0.063      -5.1%  0.95
``torf-cli 5.2.1``            9.618 ± 0.096      +28.0% 1.28
``torrenttools v0.6.2``       9.632 ± 0.051      +28.2% 1.28
============================= ================== ====== ======

Plot:

.. image:: ./docs/benchmark.png
   :alt: Plot of benchmark results

System specs:

- AMD Ryzen 7 7735HS (3.2 GHz, 8 cores)
- 16 GB DDR5 RAM
- Micron 2400 SSD

The benchmarking code is in ``scripts/benchmark.ps1``.
