Skip to content

Aria2 Wheel

python wheel for aria2 static build

CI/CD CI: lint-test pre-commit.ci status
CI: docs CI: publish
Code codecov Code style: black Ruff Checked with pyright
Package PyPI - Version PyPI - Downloads PyPI - Python Version
Meta Hatch project GitHub License

Documentation: https://wsh032.github.io/aria2-wheel/

Source Code: https://github.com/WSH032/aria2-wheel/


Introduction

aria2 is a lightweight multi-protocol & multi-source command-line download utility.

It's easy to install aria2 on Linux (apt install aria2), however it's not easy to install aria2 on Windows (at least can't one-click to install).

So I build this python wheel to binding aria2 static build. You can install it by pip from pypi on Windows.

Now, we support:

  • manylinux_2_17_x86_64
  • musllinux_1_1_x86_64
  • manylinux_2_17_aarch64
  • musllinux_1_1_aarch64
  • win_amd64
  • win32

Features

aria2-wheel internally bundles the aria2c binary and utilizes the entry_point technology.

Therefore, it does not modify your system's PATH environment variable, and there is no need for sudo permissions.

You can completely uninstall it by running pip uninstall aria2.

Credits

  • aria2
    • This project is not aria2 official project.
  • aria2-static-build
    • The bound aria2 executable file directly comes from aria2-static-build project, and aria2-wheel assumes no responsibility for your use.
    • The license of aria2-wheel project is consistent with aria2-static-build project.

check hatch_build.py and .github/workflows/publish.yml to know how we build the wheel.

Install

pip install aria2

or install in global environment with pipx

# https://pypa.github.io/pipx/
pipx install aria2

Usage

cli usage

All api is the same as aria2

aria2c --help

or

python -m aria2c --help

ctrl + c , ctrl + break , kill <pid> will work well, even exit code.

subprocess.Popen

Do not shutdown the subprocess by Popen.terminate() or Popen.kill(), which can not shutdown aria2 subprocess properly.

Use following code instead:

import os
import signal
import subprocess
import sys
from subprocess import Popen
from typing import TypedDict


class Win32PopenKwargs(TypedDict):
    """Popen kwargs for Windows."""

    creationflags: int


class UnixPopenKwargs(TypedDict):
    """Popen kwargs for Unix."""

    start_new_session: bool


popen_kwargs = (
    UnixPopenKwargs(start_new_session=True)
    if sys.platform != "win32"
    else Win32PopenKwargs(creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
)


with Popen(args=("aria2c", "--enable-rpc"), **popen_kwargs) as p:
    try:
        # Do whatever you want here.
        ...
    finally:
        # following code can shutdown the subprocess gracefully.
        if sys.platform == "win32":
            # https://stackoverflow.com/questions/44124338/trying-to-implement-signal-ctrl-c-event-in-python3-6
            os.kill(p.pid, signal.CTRL_BREAK_EVENT)
        else:
            os.killpg(os.getpgid(p.pid), signal.SIGINT)

development

English is not the native language of the author (me), so if you find any areas for improvement in the documentation, your feedback is welcome.

If you think this project helpful, consider giving it a star GitHub Repo stars, which makes me happy. 😄