From 1cf7e0547b28b50d0095fb59060b46d165c73695 Mon Sep 17 00:00:00 2001 From: Hitalo Date: Fri, 8 Dec 2023 00:06:21 +0700 Subject: [PATCH] Pyrofork: pyproject.toml migration Signed-off-by: wulan17 Co-authored-by: Alisson Lauffer Co-authored-by: wulan17 --- MANIFEST.in | 2 +- Makefile | 2 +- dev-requirements.txt | 6 --- hatch_build.py | 21 +++++++++++ pyproject.toml | 82 +++++++++++++++++++++++++++++++++++++++++ requirements.txt | 3 -- setup.py | 88 -------------------------------------------- tox.ini | 4 -- 8 files changed, 105 insertions(+), 103 deletions(-) delete mode 100644 dev-requirements.txt create mode 100644 hatch_build.py create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py delete mode 100644 tox.ini diff --git a/MANIFEST.in b/MANIFEST.in index b1f5bc04f..e028d6337 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ ## 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 diff --git a/Makefile b/Makefile index e3d5d265c..a391f84ba 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ venv: $(RM) $(VENV) python3 -m venv $(VENV) $(PYTHON) -m pip install -U pip wheel setuptools - $(PYTHON) -m pip install -U -r requirements.txt -r dev-requirements.txt + $(PYTHON) -m pip install -U -e . @echo "Created venv with $$($(PYTHON) --version)" clean-docs: diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index d8968085b..000000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ --r requirements.txt - -pytest -pytest-asyncio -pytest-cov -twine \ No newline at end of file diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 000000000..c4a6b59fe --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,21 @@ +import sys + +from hatchling.builders.hooks.plugin.interface import BuildHookInterface + +# Add the current directory to the path, so we can import the compiler. +sys.path.insert(0, ".") + + +class CustomHook(BuildHookInterface): + """A custom build hook for pyrofork.""" + + def initialize(self, version, build_data): + """Initialize the hook.""" + if self.target_name not in {"wheel", "install"}: + return + + from compiler.api.compiler import start as compile_api + from compiler.errors.compiler import start as compile_errors + + compile_api() + compile_errors() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..9215e2a3c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,82 @@ +[project] +name = "pyrofork" +dynamic = ["version"] +description = "Fork of pyrogram. Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots" +authors = [{ name = "wulan17", email = "wulan17@nusantararom.org" }] +dependencies = ["pyaes==1.6.1", "pysocks==1.7.1", "pymediainfo-pyrofork>=6.0.1,<7.0.0"] +readme = "README.md" +license = "LGPL-3.0-or-later" +requires-python = "~=3.7" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Natural Language :: English", + "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Internet", + "Topic :: Communications", + "Topic :: Communications :: Chat", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: Libraries :: Application Frameworks", +] +keywords = ["telegram chat messenger mtproto api client library python"] + +[tool.hatch.version] +path = "pyrogram/__init__.py" + +# Used to call hatch_build.py +[tool.hatch.build.hooks.custom] + +[project.urls] +Tracker = "https://github.com/Mayuri-Chan/PyroFork/issues" +Community = "https://t.me/MayuriChan_Chat" +Source = "https://github.com/Mayuri-Chan/PyroFork" +Documentation = "https://pyrofork.mayuri.my.id" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.rye] +managed = true +dev-dependencies = [ + "pytest>=7.4.3", + "pytest-asyncio>=0.21.1", + "pytest-cov>=4.1.0", + "twine>=4.0.2", +] + +[tool.hatch.metadata] +allow-direct-references = true + +[tool.hatch.build.targets.sdist] +exclude = [ + ".github/", + "docs/", + "tests/", + ".editorconfig", + ".gitignore", + ".pre-commit-config.yaml", + "CODE_OF_CONDUCT.rst", + "CONTRIBUTING.rst", + "requirements.lock", + "requirements-dev.lock", +] +packages = [ + "pyrogram" +] + +[tool.hatch.build.targets.wheel] +ignore-vcs = true +package = "pyrofork" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e832ea0b7..000000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pyaes==1.6.1 -pymediainfo-pyrofork>=6.0.1,<7.0.0 -pysocks==1.7.1 diff --git a/setup.py b/setup.py deleted file mode 100644 index a049ce753..000000000 --- a/setup.py +++ /dev/null @@ -1,88 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-present Dan -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -import re -from sys import argv - -from setuptools import setup, find_packages - -from compiler.api import compiler as api_compiler -from compiler.errors import compiler as errors_compiler - -with open("requirements.txt", encoding="utf-8") as r: - requires = [i.strip() for i in r] - -with open("pyrogram/__init__.py", encoding="utf-8") as f: - version = re.findall(r"__version__ = \"(.+)\"", f.read())[0] - -with open("README.md", encoding="utf-8") as f: - readme = f.read() - -if len(argv) > 1 and argv[1] in ["bdist_wheel", "install", "develop"]: - api_compiler.start() - errors_compiler.start() - -setup( - name="PyroFork", - version=version, - description="Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots", - long_description=readme, - long_description_content_type="text/markdown", - url="https://github.com/Mayuri-Chan/pyrofork", - download_url="https://github.com/Mayuri-Chan/pyrofork/releases/latest", - author="wulan17", - author_email="mayuri@mayuri.my.id", - license="LGPLv3", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Natural Language :: English", - "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Topic :: Internet", - "Topic :: Communications", - "Topic :: Communications :: Chat", - "Topic :: Software Development :: Libraries", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Software Development :: Libraries :: Application Frameworks" - ], - keywords="telegram chat messenger mtproto api client library python", - project_urls={ - "Tracker": "https://github.com/Mayuri-Chan/pyrofork/issues", - "Community": "https://t.me/MayuriChan_Chat", - "Source": "https://github.com/Mayuri-Chan/pyrofork", - "Documentation": "https://pyrofork.mayuri.my.id", - }, - python_requires="~=3.7", - package_data={ - "pyrogram": ["py.typed"], - }, - packages=find_packages(exclude=["compiler*", "tests*"]), - zip_safe=False, - install_requires=requires -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 1795b1f22..000000000 --- a/tox.ini +++ /dev/null @@ -1,4 +0,0 @@ -[testenv] -deps = -rdev-requirements.txt -commands = coverage run -m pytest {posargs} -skip_install = true \ No newline at end of file