Skip to content

Commit

Permalink
chore: CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Two Dev committed Dec 11, 2024
1 parent 8196011 commit 501c53d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: false
max-parallel: 3
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
Expand All @@ -23,16 +24,15 @@ jobs:

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
make init
- name: Lint
run: |
make lint
- name: Tests
run: |
python -m pytest tests
make pytest
deploy:
needs: build
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.PHONY: docs
init:
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt

test:
Expand All @@ -14,6 +15,9 @@ lint:
python -m isort tls_requests
python -m flake8 tls_requests

pytest:
python -m pytest tests

coverage:
python -m pytest --cov-config .coveragerc --verbose --cov-report term --cov-report xml --cov=tls_requests tests

Expand All @@ -25,11 +29,11 @@ publish-test-pypi:
python -m pip install 'twine>=6.0.1'
python setup.py sdist bdist_wheel
twine upload --repository testpypi dist/*
rm -rf build dist .egg *.egg-info
rm -rf build dist .egg wrapper_tls_requests.egg-info

publish-pypi:
python -m pip install -r requirements-dev.txt
python -m pip install 'twine>=6.0.1'
python setup.py sdist bdist_wheel
twine upload dist/*
rm -rf build dist .egg *.egg-info
rm -rf build dist .egg wrapper_tls_requests.egg-info
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TLS REQUESTS
**A powerful and lightweight Python library for making secure and reliable HTTP/TLS Fingerprint requests.**
# TLS Requests
TLS Requests is a powerful Python library for secure HTTP requests, offering browser-like TLS fingerprinting, anti-bot bypassing, and high performance.

* * *

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Base
chardet~=5.2.0
requests>=2.28.0
requests~=2.32.3
tqdm~=4.67.1
idna~=3.10
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
import tls_requests

pytest_plugins = ['pytest_httpserver', 'pytest_asyncio']


def pytest_configure(config):
tls_requests.TLSLibrary.load()
21 changes: 15 additions & 6 deletions tls_requests/models/libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@

BIN_DIR = os.path.join(Path(__file__).resolve(strict=True).parent.parent / "bin")
GITHUB_API_URL = "https://api.github.com/repos/bogdanfinn/tls-client/releases"
OS_PLATFORM = platform
OS_MACHINE = machine()
if OS_PLATFORM == "linux" and OS_MACHINE == "x86_64":
OS_MACHINE = "amd64"

PATTERN_RE = re.compile(
r"xgo[a-zA-Z0-9.-]+%s-%s\.(so|dll|dylib)" % (platform, machine()), re.I
r"[a-zA-Z0-9.-]+%s-%s\.(so|dll|dylib)" % (OS_PLATFORM, OS_MACHINE), re.I
)


Expand Down Expand Up @@ -58,6 +63,7 @@ def from_kwargs(cls, **kwargs):
class TLSLibrary:
@classmethod
def fetch_api(cls, version: str = None, retries: int = 3):

for _ in range(retries):
try:
response = requests.get(GITHUB_API_URL)
Expand All @@ -70,14 +76,16 @@ def fetch_api(cls, version: str = None, retries: int = 3):
asset
for release in releases
for asset in release.assets
if "xgo" in str(asset.browser_download_url)
if PATTERN_RE.search(asset.browser_download_url)
]
if version is not None:
for asset in assets:
if str(version) == asset.name:
return [asset.browser_download_url]
yield asset.browser_download_url

for asset in assets:
yield asset.browser_download_url

return [asset.browser_download_url for asset in assets]
except Exception as e:
print("Unable to fetch GitHub API: %s" % e)

Expand All @@ -96,11 +104,12 @@ def find_all(cls) -> list[str]:
@classmethod
def download(cls, version: str = None) -> str:
try:
print("System Info - Platform: %s, Machine: %s." % (OS_PLATFORM, OS_MACHINE))
download_url = None
for download_url in cls.fetch_api(version):
if PATTERN_RE.search(download_url):
break
break

print("Library Download URL: %s" % download_url)
if download_url:
destination = os.path.join(BIN_DIR, download_url.split("/")[-1])
with requests.get(download_url, stream=True) as response:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{39,310,311,312,313}-{default, use_chardet_on_py3}
envlist = py{39,310,311,312,313}-default

[testenv]
deps = -r requirements-dev.txt
Expand Down

0 comments on commit 501c53d

Please sign in to comment.