diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 13217111..ae6472c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 @@ -30,6 +30,4 @@ jobs: python-version: ${{ matrix.python-version }} - name: Local build checking - run: | - pip install twine wheel - cd src/ && python setup.py sdist bdist_wheel + run: make build diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 3c681b69..20574950 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 @@ -33,4 +33,4 @@ jobs: run: make install - name: PYPI install checking - run: pip install python3-capsolver + run: pip3 install python3-capsolver diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 65db0f76..4a920caf 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,7 +24,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 @@ -35,8 +35,8 @@ jobs: - name: Install dependencies run: | - pip install --upgrade pip - pip install -r requirements.style.txt + pip3 install --upgrade pip + pip3 install -r requirements.style.txt - name: Lint run: make lint diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 5c6516a9..a7d41d19 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -27,7 +27,7 @@ jobs: run: make doc - name: Deploy - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: publish_branch: gh-pages github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ccb682e..8710ca82 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,17 +38,17 @@ jobs: - name: Install dependencies run: | - pip install --upgrade pip + pip install --upgrade pip build setuptools pip install -r requirements.test.txt - pip install -r src/requirements.txt + pip install . - name: Test run: make tests - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - files: /home/runner/work/python3-capsolver/python3-capsolver/src/coverage/coverage.xml + files: ${{github.workspace}}/src/coverage/coverage.xml fail_ci_if_error: true verbose: true diff --git a/.python-version b/.python-version new file mode 100644 index 00000000..871f80a3 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12.3 diff --git a/Makefile b/Makefile index 54c311a1..0b372aa8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ install: - cd src/ && pip install -e . + pip3 install -e . remove: pip uninstall python3_capsolver -y @@ -22,9 +22,13 @@ lint: black src/ --check isort src/ --check-only +build: + pip3 install --upgrade build setuptools + python3 -m build + upload: - pip install twine wheel - cd src/ && python setup.py upload + pip3 install twine wheel setuptools build + twine upload dist/* tests: install coverage run --rcfile=.coveragerc -m pytest -vv --showlocals --pastebin=all \ diff --git a/docs/requirements.txt b/docs/requirements.txt index 0a305ba3..47821447 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,6 +1,6 @@ sphinx==7.2.6 pallets_sphinx_themes==2.1.1 myst-parser==2.0.0 -autodoc_pydantic==2.0.1 -pydantic==2.4.2 -pydantic-settings==2.0.3 +autodoc_pydantic==2.1.0 +pydantic==2.7.0 +pydantic-settings==2.2.1 diff --git a/pyproject.toml b/pyproject.toml index 7e5ef0b1..396b785a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,3 +28,77 @@ testpaths = [ "tests", ] addopts = "-vv --tb=short --durations=10" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "python3-capsolver" +dynamic = ["version"] +authors = [ + {name = "AndreiDrang", email = "python-captcha@pm.me"}, +] +description = "Python 3.8+ Capsolver library with AIO module." +readme = "README.md" +requires-python = ">=3.8" +keywords = [ "captcha", + "recaptcha", + "geetest", + "hcaptcha", + "capypuzzle", + "rotatecaptcha", + "funcaptcha", + "keycaptcha", + "python3", + "python-library", + "capsolver", + "datadomeslider", + "datadome", + "mtcaptcha", + "turnstile", + "cloudflare", + "amazon", + "amazon_waf", + "akamai", + "imperva", + "binance" + ] +license = {text = "MIT License"} +classifiers = [ + "License :: OSI Approved :: MIT License", + "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Framework :: AsyncIO", + "Operating System :: Unix", + "Operating System :: Microsoft :: Windows", + "Operating System :: MacOS", +] +dependencies = [ + "requests>=2.21.0", + "aiohttp>=3.9.2", + "pydantic==2.7.0", + "tenacity==8.*" +] + +[tool.setuptools.packages.find] +where = ["src"] +include = ["python3_capsolver*"] + +[tool.setuptools.dynamic] +version = {attr = "python3_capsolver.__version__"} + +[project.urls] +Homepage = "https://andreidrang.github.io/python3-capsolver/" +Documentation = "https://andreidrang.github.io/python3-capsolver/" +Repository = "https://github.com/AndreiDrang/python3-capsolver" +Issues = "https://github.com/AndreiDrang/python3-capsolver/issues" +Changelog = "https://github.com/AndreiDrang/python3-capsolver/releases" diff --git a/requirements.style.txt b/requirements.style.txt index c6f5d3fb..8bb21fad 100644 --- a/requirements.style.txt +++ b/requirements.style.txt @@ -1,4 +1,4 @@ # codestyle isort==5.* -black==23.10.1 +black==24.4.0 autoflake==2.* diff --git a/requirements.test.txt b/requirements.test.txt index 7ca81d83..93fd10c3 100644 --- a/requirements.test.txt +++ b/requirements.test.txt @@ -1,3 +1,3 @@ -pytest==7.* +pytest==8.* coverage==7.* pytest-asyncio==0.* diff --git a/src/python3_capsolver/__init__.py b/src/python3_capsolver/__init__.py index e69de29b..b6b45ac3 100644 --- a/src/python3_capsolver/__init__.py +++ b/src/python3_capsolver/__init__.py @@ -0,0 +1 @@ +from python3_capsolver.__version__ import __version__ # noqa diff --git a/src/python3_capsolver/__version__.py b/src/python3_capsolver/__version__.py index a2fecb45..c5981731 100644 --- a/src/python3_capsolver/__version__.py +++ b/src/python3_capsolver/__version__.py @@ -1 +1 @@ -__version__ = "0.9.2" +__version__ = "0.9.3" diff --git a/src/python3_capsolver/core/serializer.py b/src/python3_capsolver/core/serializer.py index 29314895..5af2f8d2 100644 --- a/src/python3_capsolver/core/serializer.py +++ b/src/python3_capsolver/core/serializer.py @@ -45,7 +45,7 @@ class CaptchaResponseSer(ResponseSer): solution: Dict[str, Any] = Field(None, description="Task result data. Different for each type of task.") class Config: - allow_population_by_field_name = True + populate_by_name = True class ControlResponseSer(ResponseSer): @@ -120,8 +120,7 @@ class DatadomeSliderSer(TaskSer): userAgent: str = Field(..., description="Browser's User-Agent which is used in emulation") -class CloudflareTurnstileSer(WebsiteDataOptionsSer): - ... +class CloudflareTurnstileSer(WebsiteDataOptionsSer): ... class CyberSiAraSer(WebsiteDataOptionsSer): diff --git a/src/requirements.txt b/src/requirements.txt deleted file mode 100644 index 7b5e5852..00000000 --- a/src/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -requests>=2.21.0 -aiohttp>=3.7.4 -pydantic==2.4.2 -tenacity==8.* diff --git a/src/setup.py b/src/setup.py deleted file mode 100644 index ea93669b..00000000 --- a/src/setup.py +++ /dev/null @@ -1,141 +0,0 @@ -import io -import os -import sys -import shutil -import logging - -from setuptools import Command, setup -from pkg_resources import parse_requirements - -from python3_capsolver.__version__ import __version__ - -# Package meta-data. -NAME = "python3-capsolver" -DESCRIPTION = "Python 3.8+ Capsolver library with AIO module." -URL = "https://andreidrang.github.io/python3-capsolver/" -EMAIL = "python-captcha@pm.me" -AUTHOR = "AndreiDrang" -REQUIRES_PYTHON = ">=3.8.0" -VERSION = __version__ -with open("requirements.txt", "rt") as requirements_txt: - REQUIRED = [str(requirement) for requirement in parse_requirements(requirements_txt)] - - -here = os.path.abspath(os.path.dirname(__file__)) - -# Import the README and use it as the long-description. -# Note: this will only work if 'README.md' is present in your MANIFEST.in file! -try: - with io.open(os.path.join(here, "../README.md"), encoding="utf-8") as f: - long_description = "\n" + f.read() -except FileNotFoundError: - long_description = DESCRIPTION - - -class UploadCommand(Command): - """Support setup.py upload.""" - - description = "Build and publish the package." - user_options = [] - - @staticmethod - def status(s): - """Prints things in bold.""" - print("\033[1m{0}\033[0m".format(s)) - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - logging.info("Prepapre wheel") - os.system("pip install wheel") - - logging.info("Building Source and Wheel distribution . . .") - os.system("python setup.py sdist bdist_wheel") - - logging.info("Uploading the package to PyPI via Twin . . .") - os.system("twine upload dist/* --verbose") - - logging.info("🤖 Uploaded . . .") - - logging.info("Clean dist . . .") - shutil.rmtree("dist/", ignore_errors=True) - - logging.info("Clean build . . .") - shutil.rmtree("build/", ignore_errors=True) - - logging.info("Clean python_rucaptcha.egg-info . . .") - shutil.rmtree("python3_capsolver.egg-info/", ignore_errors=True) - sys.exit() - - -setup( - name=NAME, - version=VERSION, - author=AUTHOR, - packages=["python3_capsolver", "python3_capsolver.core"], - install_requires=REQUIRED, - description=DESCRIPTION, - long_description=long_description, - long_description_content_type="text/markdown", - author_email=EMAIL, - project_urls={ - "Documentation": URL, - "Source": "https://github.com/AndreiDrang/python3-capsolver", - }, - package_dir={"python3-capsolver": "python3_capsolver"}, - include_package_data=True, - py_modules=["python3_capsolver"], - url=URL, - license="MIT", - keywords=""" - captcha - recaptcha - geetest - hcaptcha - capypuzzle - rotatecaptcha - funcaptcha - keycaptcha - python3 - python-library - capsolver - datadomeslider - datadome - mtcaptcha - turnstile - cloudflare - amazon - amazon_waf - akamai - imperva - binance - """, - python_requires=REQUIRES_PYTHON, - zip_safe=False, - classifiers=[ - # Trove classifiers - # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers - "License :: OSI Approved :: MIT License", - "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Framework :: AsyncIO", - "Operating System :: Unix", - "Operating System :: Microsoft :: Windows", - "Operating System :: MacOS", - ], - # Build - `python setup.py bdist_wheel` - # Upload package: `python3 setup.py upload` - cmdclass={"upload": UploadCommand}, -) -print("🤖 Success install ...")