From ecb8afb4ef9990e7b9a7acb5ef3927754adea957 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 21 Jul 2020 14:03:52 +0200 Subject: [PATCH] Use the __main__.py special filename for main.py (#118) * Use the __main__.py special filename for main.py This allows users to run the program directly with `py -m tg` instead of `py -m tg.main`. * Updated script in pyproject.toml to reflect the previous rename * Updated readme.md to reflect the previous rename * Update readme.md with a better description of how to install the software * Once installed through flit, the tg command can be used directly * Fix errors in the readme.md introduced in the previous commit * Run the folder instead of the script * Change title --- pyproject.toml | 2 +- readme.md | 93 +++++++++++++++++++++++++------------ tg/{main.py => __main__.py} | 0 3 files changed, 64 insertions(+), 31 deletions(-) rename tg/{main.py => __main__.py} (100%) diff --git a/pyproject.toml b/pyproject.toml index b0fc638..9123a83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ requires-python = ">=3.8" requires = ['python-telegram==0.12.0'] [tool.flit.scripts] -tg = "tg.main:main" +tg = "tg.__main__:main" [tool.black] line-length = 79 diff --git a/readme.md b/readme.md index 6d3fe12..f2ac39b 100644 --- a/readme.md +++ b/readme.md @@ -29,37 +29,11 @@ TODO: - [ ] create new chat - [ ] bots (bot keyboard) +## Requirements -## Installation +To use tg, you'll need to have the following installed: -`python3.8` required. - - -From pip: - -```sh -pip3 install tg -``` - -From sources: - -```sh -pip3 install python-telegram -git clone git@github.com:paul-nameless/tg.git -cd tg -PYTHONPATH=. python3 tg/main.py -``` - -Docker (voice recordings and notifications won't work): -```sh -docker run -it --rm tg -``` - -Arch Linux users can install from the AUR: https://aur.archlinux.org/packages/telegram-tg-git/ - -```bash -yay -S telegram-tg-git -``` +- [Python 3.8](https://www.python.org/downloads/release/python-380/) ## Optional dependencies @@ -76,8 +50,67 @@ yay -S telegram-tg-git ```ini image/webp; mpv %s ``` -- [ranger](https://github.com/ranger/ranger), [nnn](https://github.com/jarun/nnn) - can be used to choose file when sending, customizable with `FILE_PICKER_CMD` +- [ranger](https://github.com/ranger/ranger), [nnn](https://github.com/jarun/nnn): + can be used to choose file when sending, customizable with `FILE_PICKER_CMD` +## Installation + +### From PyPI + +This option is recommended for production: + +```sh +pip3 install tg +tg +``` + +### Using flit + +This option is recommended for development: + +> Requires [flit](https://github.com/takluyver/flit) to be installed. +> +> Install it with: +> ```sh +> pip3 install flit +> ``` + +```sh +git clone https://github.com:paul-nameless/tg.git +cd tg +flit install +tg +``` + +### Running with virtualenv + +> Ensure you have the correct version of Python installed before using this method! + +```sh +git clone https://github.com:paul-nameless/tg.git +cd tg +python3 -m venv venv +source venv/bin/activate +pip install python-telegram +python3 tg +``` + +### Using Docker + +> Please note that voice recordings and notifications won't work when using Docker. + +```sh +docker run -it --rm tg +``` + +### From the AUR + +If you're using Arch Linux, you can install tg through [its AUR package](https://aur.archlinux.org/packages/telegram-tg-git/): + +If you're using the `yay` AUR helper, you can install the package with: +```bash +yay -S telegram-tg-git +``` ## Configuration diff --git a/tg/main.py b/tg/__main__.py similarity index 100% rename from tg/main.py rename to tg/__main__.py