The CachedWheelsCommand plugs into the default bdist wheel, which is ran by pip when it cannot find an existing wheel (which is currently the case for all installs). We use the environment parameters to detect whether there is already a pre-built version of a compatible wheel availa
| 195 | |
| 196 | |
| 197 | class CachedWheelsCommand(_bdist_wheel): |
| 198 | """ |
| 199 | The CachedWheelsCommand plugs into the default bdist wheel, which is ran by pip when it cannot |
| 200 | find an existing wheel (which is currently the case for all installs). We use |
| 201 | the environment parameters to detect whether there is already a pre-built version of a compatible |
| 202 | wheel available and short-circuits the standard full build pipeline. |
| 203 | """ |
| 204 | |
| 205 | def run(self): |
| 206 | if FORCE_BUILD: |
| 207 | return super().run() |
| 208 | |
| 209 | wheel_url, wheel_filename = get_wheel_url() |
| 210 | print("Guessing wheel URL: ", wheel_url) |
| 211 | try: |
| 212 | urllib.request.urlretrieve(wheel_url, wheel_filename) |
| 213 | |
| 214 | # Make the archive |
| 215 | # Lifted from the root wheel processing command |
| 216 | # https://github.com/pypa/wheel/blob/cf71108ff9f6ffc36978069acb28824b44ae028e/src/wheel/bdist_wheel.py#LL381C9-L381C85 |
| 217 | if not os.path.exists(self.dist_dir): |
| 218 | os.makedirs(self.dist_dir) |
| 219 | |
| 220 | impl_tag, abi_tag, plat_tag = self.get_tag() |
| 221 | archive_basename = f"{self.wheel_dist_name}-{impl_tag}-{abi_tag}-{plat_tag}" |
| 222 | |
| 223 | wheel_path = os.path.join(self.dist_dir, archive_basename + ".whl") |
| 224 | print("Raw wheel path", wheel_path) |
| 225 | shutil.move(wheel_filename, wheel_path) |
| 226 | except urllib.error.HTTPError: |
| 227 | print("Precompiled wheel not found. Building from source...") |
| 228 | # If the wheel could not be downloaded, build from source |
| 229 | super().run() |
| 230 | |
| 231 | |
| 232 | setup( |
nothing calls this directly
no outgoing calls
no test coverage detected