Skip to content

Commit

Permalink
rename to pyrogramv1
Browse files Browse the repository at this point in the history
  • Loading branch information
illvart committed Jan 21, 2024
1 parent 4998221 commit ca843f7
Show file tree
Hide file tree
Showing 443 changed files with 1,798 additions and 5,630 deletions.
5 changes: 2 additions & 3 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github: delivrance
liberapay: delivrance
open_collective: pyrogram
github: [illvart]
custom: ["https://linktr.ee/illvart"]
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Upload Python Package

on:
push:
workflow_dispatch:

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Build package
run: hatch build
- name: Publish package
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }}
run: |
hatch publish
21 changes: 8 additions & 13 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
name: Pyrogram
name: PyrogramV1

on: [push, pull_request]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]

os: [ubuntu-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Generate API
run: |
python setup.py generate --api
make venv
make api
- name: Run tests
run: |
tox
tox
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ main.py
unknown_errors.txt

# Pyrogram generated code
pyrogram/errors/exceptions/
pyrogram/raw/functions/
pyrogram/raw/types/
pyrogram/raw/base/
pyrogram/raw/all.py
pyrogramv1/errors/exceptions/
pyrogramv1/raw/functions/
pyrogramv1/raw/types/
pyrogramv1/raw/base/
pyrogramv1/raw/all.py
docs/source/telegram
docs/source/api/methods/
docs/source/api/bound-methods/
Expand Down
12 changes: 6 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## Include
include README.md COPYING COPYING.lesser NOTICE requirements.txt
include README.md COPYING COPYING.lesser NOTICE
recursive-include compiler *.py *.tl *.tsv *.txt
recursive-include tests *.py

## Exclude
prune pyrogram/errors/exceptions
prune pyrogram/raw/functions
prune pyrogram/raw/types
prune pyrogram/raw/base
exclude pyrogram/raw/all.py
prune pyrogramv1/errors/exceptions
prune pyrogramv1/raw/functions
prune pyrogramv1/raw/types
prune pyrogramv1/raw/base
exclude pyrogramv1/raw/all.py
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
VENV := venv
PYTHON := $(VENV)/bin/python
HOST = $(shell ifconfig | grep "inet " | tail -1 | cut -d\ -f2)
TAG = v$(shell grep -E '__version__ = ".*"' pyrogramv1/__init__.py | cut -d\" -f2)

RM := rm -rf

.PHONY: venv clean-build clean-api clean api build

venv:
$(RM) $(VENV)
python3 -m venv $(VENV)
$(PYTHON) -m pip install -U pip wheel setuptools
$(PYTHON) -m pip install -U -e .
@echo "Created venv with $$($(PYTHON) --version)"

clean-build:
$(RM) *.egg-info build dist

clean-api:
$(RM) pyrogramv1/errors/exceptions pyrogramv1/raw/all.py pyrogramv1/raw/base pyrogramv1/raw/functions pyrogramv1/raw/types

clean:
make clean-build
make clean-api

api:
cd compiler/api && ../../$(PYTHON) compiler.py
cd compiler/errors && ../../$(PYTHON) compiler.py

build:
make clean
$(PYTHON) setup.py sdist
$(PYTHON) setup.py bdist_wheel

tag:
git tag $(TAG)
git push origin $(TAG)

dtag:
git tag -d $(TAG)
git push origin -d $(TAG)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
</a>
</p>

## Pyrogram
## PyrogramV1

> Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
``` python
from pyrogram import Client, filters
from pyrogramv1 import Client, filters

app = Client("my_account")

Expand Down Expand Up @@ -61,7 +61,7 @@ If you'd like to support Pyrogram, you can consider:
### Installing

``` bash
pip3 install pyrogram
pip3 install pyrogramv1
```

### Resources
Expand Down
38 changes: 19 additions & 19 deletions compiler/api/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# from black import format_str, FileMode

HOME_PATH = Path("compiler/api")
DESTINATION_PATH = Path("pyrogram/raw")
DESTINATION_PATH = Path("pyrogramv1/raw")
NOTICE_PATH = "NOTICE"

SECTION_RE = re.compile(r"---(\w+)---")
Expand Down Expand Up @@ -149,7 +149,7 @@ def remove_whitespaces(source: str) -> str:
return "\n".join(lines)


def get_docstring_arg_type(t: str, is_list: bool = False, is_pyrogram_type: bool = False):
def get_docstring_arg_type(t: str, is_list: bool = False, is_pyrogramv1_type: bool = False):
if t in CORE_TYPES:
if t == "long":
return "``int`` ``64-bit``"
Expand All @@ -165,13 +165,13 @@ def get_docstring_arg_type(t: str, is_list: bool = False, is_pyrogram_type: bool
else:
return f"``{t.lower()}``"
elif t == "TLObject" or t == "X":
return "Any object from :obj:`~pyrogram.raw.types`"
return "Any object from :obj:`~pyrogramv1.raw.types`"
elif t == "!X":
return "Any method from :obj:`~pyrogram.raw.functions`"
return "Any method from :obj:`~pyrogramv1.raw.functions`"
elif t.lower().startswith("vector"):
return "List of " + get_docstring_arg_type(t.split("<", 1)[1][:-1], True)
else:
return f":obj:`{t} <pyrogram.raw.base.{t}>`"
return f":obj:`{t} <pyrogramv1.raw.base.{t}>`"


def get_references(t: str, kind: str):
Expand All @@ -184,7 +184,7 @@ def get_references(t: str, kind: str):

if t:
return "\n ".join(
f"- :obj:`{i} <pyrogram.raw.functions.{i}>`"
f"- :obj:`{i} <pyrogramv1.raw.functions.{i}>`"
for i in t
), len(t)

Expand Down Expand Up @@ -315,7 +315,7 @@ def start(format: bool = False):

constructors = sorted(types_to_constructors[qualtype])
constr_count = len(constructors)
items = "\n ".join([f"- :obj:`{c} <pyrogram.raw.types.{c}>`" for c in constructors])
items = "\n ".join([f"- :obj:`{c} <pyrogramv1.raw.types.{c}>`" for c in constructors])

docstring = f"This base type has {constr_count} constructor{'s' if constr_count > 1 else ''} available.\n\n"
docstring += f" Constructors:\n .. hlist::\n :columns: 2\n\n {items}"
Expand Down Expand Up @@ -369,12 +369,12 @@ def start(format: bool = False):
"{}{}: {}".format(
arg_name,
" (optional)".format(flag_number) if is_optional else "",
get_docstring_arg_type(arg_type, is_pyrogram_type=c.namespace == "pyrogram")
get_docstring_arg_type(arg_type, is_pyrogramv1_type=c.namespace == "pyrogramv1")
)
)

if c.section == "types":
docstring += f"This object is a constructor of the base type :obj:`~pyrogram.raw.base.{c.qualtype}`.\n\n"
docstring += f"This object is a constructor of the base type :obj:`~pyrogramv1.raw.base.{c.qualtype}`.\n\n"
else:
docstring += f"Telegram API method.\n\n"

Expand Down Expand Up @@ -580,23 +580,23 @@ def start(format: bool = False):
f.write("objects = {")

for c in combinators:
f.write(f'\n {c.id}: "pyrogram.raw.{c.section}.{c.qualname}",')
f.write(f'\n {c.id}: "pyrogramv1.raw.{c.section}.{c.qualname}",')

f.write('\n 0xbc799737: "pyrogram.raw.core.BoolFalse",')
f.write('\n 0x997275b5: "pyrogram.raw.core.BoolTrue",')
f.write('\n 0x1cb5c415: "pyrogram.raw.core.Vector",')
f.write('\n 0x73f1f8dc: "pyrogram.raw.core.MsgContainer",')
f.write('\n 0xae500895: "pyrogram.raw.core.FutureSalts",')
f.write('\n 0x0949d9dc: "pyrogram.raw.core.FutureSalt",')
f.write('\n 0x3072cfa1: "pyrogram.raw.core.GzipPacked",')
f.write('\n 0x5bb8e511: "pyrogram.raw.core.Message",')
f.write('\n 0xbc799737: "pyrogramv1.raw.core.BoolFalse",')
f.write('\n 0x997275b5: "pyrogramv1.raw.core.BoolTrue",')
f.write('\n 0x1cb5c415: "pyrogramv1.raw.core.Vector",')
f.write('\n 0x73f1f8dc: "pyrogramv1.raw.core.MsgContainer",')
f.write('\n 0xae500895: "pyrogramv1.raw.core.FutureSalts",')
f.write('\n 0x0949d9dc: "pyrogramv1.raw.core.FutureSalt",')
f.write('\n 0x3072cfa1: "pyrogramv1.raw.core.GzipPacked",')
f.write('\n 0x5bb8e511: "pyrogramv1.raw.core.Message",')

f.write("\n}\n")


if "__main__" == __name__:
HOME_PATH = Path(".")
DESTINATION_PATH = Path("../../pyrogram/raw")
DESTINATION_PATH = Path("../../pyrogramv1/raw")
NOTICE_PATH = Path("../../NOTICE")

start(format=False)
6 changes: 3 additions & 3 deletions compiler/api/template/combinator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from io import BytesIO

from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
from pyrogram.raw.core import TLObject
from pyrogram import raw
from pyrogramv1.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
from pyrogramv1.raw.core import TLObject
from pyrogramv1 import raw
from typing import List, Optional, Any

{warning}
Expand Down
6 changes: 3 additions & 3 deletions compiler/api/template/type.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{warning}

from typing import Union
from pyrogram import raw
from pyrogram.raw.core import TLObject
from pyrogramv1 import raw
from pyrogramv1.raw.core import TLObject

{name} = Union[{types}]

Expand All @@ -14,7 +14,7 @@ class {name}: # type: ignore
"""{docstring}
"""

QUALNAME = "pyrogram.raw.base.{qualname}"
QUALNAME = "pyrogramv1.raw.base.{qualname}"

def __init__(self):
raise TypeError("Base types can only be used for type checking purposes: "
Expand Down
Loading

0 comments on commit ca843f7

Please sign in to comment.