Skip to content

Commit

Permalink
Fix windows build (#199)
Browse files Browse the repository at this point in the history
* Fix windows download url, reversed typo

* Mark tests as skipped

* Bump version

* Remove redundant debugging statement

* Fix curl_ws_frame

* Make it flexiable again

* Does this hack work?
  • Loading branch information
perklet authored Dec 31, 2023
1 parent 9d83c94 commit d8bb7f2
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.ONESHELL:
SHELL := bash
VERSION := 0.6.0b6
VERSION := 0.6.0b7
CURL_VERSION := curl-8.1.1

.preprocessed: curl_cffi/include/curl/curl.h .so_downloaded
Expand Down Expand Up @@ -37,8 +37,8 @@ preprocess: .preprocessed
upload: dist/*.whl
twine upload dist/*.whl

test: install-local
pytest tests/unittest
test:
python -bb -m pytest tests/unittest

install-local: .preprocessed
pip install -e .
Expand Down
2 changes: 1 addition & 1 deletion curl_cffi/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
# __description__ = metadata.metadata("curl_cffi")["Summary"]
# __version__ = metadata.version("curl_cffi")
__description__ = "libcurl ffi bindings for Python, with impersonation support"
__version__ = "0.6.0b6"
__version__ = "0.6.0b7"
__curl_version__ = Curl().version().decode()
5 changes: 3 additions & 2 deletions curl_cffi/ffi/cdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ extern "Python" void timer_function(void *curlm, int timeout_ms, void *clientp);
struct curl_ws_frame {
int age; /* zero */
int flags; /* See the CURLWS_* defines */
long offset; /* the offset of this data into the frame */
long bytesleft; /* number of pending bytes left of the payload */
uint64_t offset; /* the offset of this data into the frame */
uint64_t bytesleft; /* number of pending bytes left of the payload */
size_t len;
...;
};

Expand Down
2 changes: 1 addition & 1 deletion preprocess/download_so.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def reporthook(blocknum, blocksize, totalsize):
else:
url = f"https://github.com/yifeikong/curl-impersonate/releases/download/v{VERSION}/libcurl-impersonate-v{VERSION}.{uname.machine}-macos.tar.gz"
elif uname.system == "Windows":
url = f"https://github.com/yifeikong/curl-impersonate/releases/download/v{VERSION}/libcurl-impersonate-v{VERSION}.AMD64-win32.tar.gz"
url = f"https://github.com/yifeikong/curl-impersonate/releases/download/v{VERSION}/libcurl-impersonate-v{VERSION}.x86_64-win32.tar.gz"
else:
url = f"https://github.com/yifeikong/curl-impersonate/releases/download/v{VERSION}/libcurl-impersonate-v{VERSION}.{uname.machine}-linux-gnu.tar.gz"

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "curl_cffi"
version = "0.6.0b6"
version = "0.6.0b7"
authors = [{ name = "Yifei Kong", email = "[email protected]" }]
description = "libcurl ffi bindings for Python, with impersonation support"
license = { file = "LICENSE" }
Expand Down
25 changes: 13 additions & 12 deletions tests/unittest/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ def test_stream_options_persist(server):
assert data["User-agent"][0] == "foo/1.0"


@pytest.mark.skip(reason="External url unstable")
def test_stream_close_early(server):
s = requests.Session()
# url = str(server.url.copy_with(path="/large"))
Expand All @@ -621,18 +622,18 @@ def test_stream_close_early(server):
assert end - start < 50


# Does not work
# def test_max_recv_speed(server):
# s = requests.Session()
# s.curl.setopt(CurlOpt.BUFFERSIZE, 1024 * 1024)
# url = str(server.url.copy_with(path="/large"))
# # from http://xcal1.vodafone.co.uk/
# url = "http://212.183.159.230/200MB.zip"
# start = time.time()
# r = s.get(url, max_recv_speed=10 * 1024 * 1024)
# end = time.time()
# # assert len(r.content) == 20 * 1024 * 1024
# assert end - start > 10
@pytest.mark.skip(reason="External url unstable")
def test_max_recv_speed(server):
s = requests.Session()
s.curl.setopt(CurlOpt.BUFFERSIZE, 1024 * 1024)
url = str(server.url.copy_with(path="/large"))
# from http://xcal1.vodafone.co.uk/
url = "http://212.183.159.230/200MB.zip"
start = time.time()
r = s.get(url, max_recv_speed=10 * 1024 * 1024)
end = time.time()
# assert len(r.content) == 20 * 1024 * 1024
assert end - start > 10


def test_curl_infos(server):
Expand Down
2 changes: 0 additions & 2 deletions tests/unittest/test_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ def test_hello_twice(ws_server):

w.send(b"Bar")
reply, _ = w.recv()
print(reply)

for _ in range(10):
w.send(b"Bar")
reply, _ = w.recv()
assert reply == b"Bar"
print(reply)

0 comments on commit d8bb7f2

Please sign in to comment.