|
16 | 16 | import shutil
|
17 | 17 | import tempfile
|
18 | 18 | import time
|
| 19 | + |
19 | 20 | from collections import defaultdict
|
20 | 21 | from typing import List
|
21 | 22 | from typing import NamedTuple
|
|
27 | 28 | import attr
|
28 | 29 | import packageurl
|
29 | 30 | import requests
|
| 31 | + |
30 | 32 | from bs4 import BeautifulSoup
|
31 | 33 | from commoncode import fileutils
|
32 | 34 | from commoncode.hash import multi_checksums
|
@@ -215,7 +217,6 @@ def get_python_dot_version(version):
|
215 | 217 | class DistributionNotFound(Exception):
|
216 | 218 | pass
|
217 | 219 |
|
218 |
| - |
219 | 220 | def download_wheel(
|
220 | 221 | name,
|
221 | 222 | version,
|
@@ -252,6 +253,7 @@ def download_wheel(
|
252 | 253 | )
|
253 | 254 | continue
|
254 | 255 | for wheel in supported_and_valid_wheels:
|
| 256 | + wheel.credentials = repo.credentials |
255 | 257 | fetched_wheel_filename = wheel.download(
|
256 | 258 | dest_dir=dest_dir,
|
257 | 259 | verbose=verbose,
|
@@ -1130,7 +1132,8 @@ def to_filename(self):
|
1130 | 1132 | pyvers = ".".join(self.python_versions)
|
1131 | 1133 | abis = ".".join(self.abis)
|
1132 | 1134 | plats = ".".join(self.platforms)
|
1133 |
| - return f"{self.name}-{self.version}{build}-{pyvers}-{abis}-{plats}.whl" |
| 1135 | + name = f"{self.name}-{self.version}{build}-{pyvers}-{abis}-{plats}.whl" |
| 1136 | + return name |
1134 | 1137 |
|
1135 | 1138 | def is_pure(self):
|
1136 | 1139 | """
|
@@ -1593,16 +1596,6 @@ def fetch_links(
|
1593 | 1596 | name using the `index_url` of this repository.
|
1594 | 1597 | """
|
1595 | 1598 | package_url = f"{self.index_url}/{normalized_name}"
|
1596 |
| - if len(package_url) >= 256: |
1597 |
| - base64_re = re.compile(f"https://(.*:.*)@(.*){normalized_name}") |
1598 |
| - match = base64_re.search(self.index_url) |
1599 |
| - if match: |
1600 |
| - auth = match.group(1) |
1601 |
| - username = auth.split(":")[0] |
1602 |
| - token = auth,split(":")[1] |
1603 |
| - remainder = match.group(2) |
1604 |
| - new_index_url = f"https://{username}:{token}@{remainder}" |
1605 |
| - package_url = f"{new_index_url}/{normalized_name}" |
1606 | 1599 | text = CACHE.get(
|
1607 | 1600 | path_or_url=package_url,
|
1608 | 1601 | credentials=self.credentials,
|
@@ -1645,7 +1638,10 @@ def resolve_relative_url(package_url, url):
|
1645 | 1638 | path = urlunparse(
|
1646 | 1639 | ("", "", url_parts.path, url_parts.params, url_parts.query, url_parts.fragment)
|
1647 | 1640 | )
|
1648 |
| - resolved_url_parts = base_url_parts._replace(path=path) |
| 1641 | + if base_url_parts.path != "": |
| 1642 | + resolved_url_parts = base_url_parts._replace(path=base_url_parts.path + "/" + path) |
| 1643 | + else: |
| 1644 | + resolved_url_parts = base_url_parts._replace(path=path) |
1649 | 1645 | url = urlunparse(resolved_url_parts)
|
1650 | 1646 | return url
|
1651 | 1647 |
|
@@ -1688,6 +1684,8 @@ def get(
|
1688 | 1684 | True otherwise as treat as binary. `path_or_url` can be a path or a URL
|
1689 | 1685 | to a file.
|
1690 | 1686 | """
|
| 1687 | + |
| 1688 | + |
1691 | 1689 | cache_key = quote_plus(path_or_url.strip("/"))
|
1692 | 1690 | cached = os.path.join(self.directory, cache_key)
|
1693 | 1691 |
|
@@ -1792,21 +1790,25 @@ def get_remote_file_content(
|
1792 | 1790 | if verbose:
|
1793 | 1791 | echo_func(f"DOWNLOADING: {url}")
|
1794 | 1792 |
|
1795 |
| - auth = None |
| 1793 | + if TRACE: |
| 1794 | + print(f"DOWNLOADING: {url}") |
| 1795 | + |
1796 | 1796 | if credentials:
|
1797 | 1797 | auth = (credentials.get("login"), credentials.get("password"))
|
| 1798 | + else: |
| 1799 | + auth = None |
1798 | 1800 |
|
1799 | 1801 | stream = requests.get(
|
1800 | 1802 | url,
|
1801 | 1803 | allow_redirects=True,
|
1802 | 1804 | stream=True,
|
1803 | 1805 | headers=headers,
|
1804 |
| - auth=auth, |
| 1806 | + auth=auth |
1805 | 1807 | )
|
1806 | 1808 |
|
1807 | 1809 | with stream as response:
|
1808 | 1810 | status = response.status_code
|
1809 |
| - if status != requests.codes.ok: # NOQA |
| 1811 | + if status != requests.codes.ok: # NOQA |
1810 | 1812 | if status == 429 and _delay < 20:
|
1811 | 1813 | # too many requests: start some exponential delay
|
1812 | 1814 | increased_delay = (_delay * 2) or 1
|
|
0 commit comments