Skip to content

Commit 785914e

Browse files
[py] Remove precompiled binaries from sdist (#14233)
Python sdist's should not contain precompiled architecture binaries that are architecture specific. They should contain the sources needed to build the binaries instead.
1 parent 6b28a8c commit 785914e

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

py/BUILD.bazel

+7
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,17 @@ pkg_files(
230230
"CHANGES",
231231
"MANIFEST.in",
232232
"README.rst",
233+
"pyproject.toml",
233234
"setup.py",
234235
":license",
235236
":selenium-pkg",
236237
":selenium-pkginfo",
238+
"//rust:selenium_manager_srcs",
239+
],
240+
excludes = [
241+
":manager-linux",
242+
":manager-macos",
243+
":manager-windows",
237244
],
238245
strip_prefix = strip_prefix.from_pkg(),
239246
)

py/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools", "setuptools-rust"]
3+
build-backend = "setuptools.build_meta"

py/selenium/webdriver/common/selenium_manager.py

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import platform
2121
import subprocess
2222
import sys
23+
import sysconfig
2324
from pathlib import Path
2425
from typing import List
2526

@@ -61,9 +62,16 @@ def _get_binary() -> Path:
6162
:Raises: WebDriverException if the platform is unsupported
6263
"""
6364

65+
compiled_path = Path(__file__).parent.joinpath("selenium-manager")
66+
exe = sysconfig.get_config_var("EXE")
67+
if exe is not None:
68+
compiled_path = compiled_path.with_suffix(exe)
69+
6470
if (path := os.getenv("SE_MANAGER_PATH")) is not None:
6571
logger.debug("Selenium Manager set by env SE_MANAGER_PATH to: %s", path)
6672
path = Path(path)
73+
elif compiled_path.exists():
74+
path = compiled_path
6775
else:
6876
allowed = {
6977
("darwin", "any"): "macos/selenium-manager",

py/setup.py

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from os.path import dirname, join, abspath
2020
from setuptools import setup
2121
from setuptools.command.install import install
22+
from setuptools_rust import Binding, RustExtension
2223

2324

2425
for scheme in INSTALL_SCHEMES.values():
@@ -83,6 +84,12 @@
8384
"typing_extensions~= 4.9.0",
8485
"websocket-client==1.8.0",
8586
],
87+
'rust_extensions': [
88+
RustExtension(
89+
{"selenium-manager": "selenium.webdriver.common.selenium-manager"},
90+
binding=Binding.Exec
91+
)
92+
],
8693
'zip_safe': False
8794
}
8895

rust/BUILD.bazel

+15
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ rust_library(
9595
deps = all_crate_deps(normal = True),
9696
)
9797

98+
filegroup(
99+
name = "selenium_manager_srcs",
100+
srcs = [
101+
"Cargo.lock",
102+
"Cargo.toml",
103+
":selenium_manager_rs_srcs",
104+
],
105+
visibility = ["//visibility:public"],
106+
)
107+
108+
filegroup(
109+
name = "selenium_manager_rs_srcs",
110+
srcs = glob(["src/**/*.rs"]),
111+
)
112+
98113
rust_test(
99114
name = "unit",
100115
size = "small",

0 commit comments

Comments
 (0)