Skip to content

Commit

Permalink
[py] Remove precompiled binaries from sdist (#14233)
Browse files Browse the repository at this point in the history
Python sdist's should not contain precompiled architecture
binaries that are architecture specific. They should contain
the sources needed to build the binaries instead.
  • Loading branch information
jameshilliard authored Jul 10, 2024
1 parent 6b28a8c commit 785914e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions py/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,17 @@ pkg_files(
"CHANGES",
"MANIFEST.in",
"README.rst",
"pyproject.toml",
"setup.py",
":license",
":selenium-pkg",
":selenium-pkginfo",
"//rust:selenium_manager_srcs",
],
excludes = [
":manager-linux",
":manager-macos",
":manager-windows",
],
strip_prefix = strip_prefix.from_pkg(),
)
Expand Down
3 changes: 3 additions & 0 deletions py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "setuptools-rust"]
build-backend = "setuptools.build_meta"
8 changes: 8 additions & 0 deletions py/selenium/webdriver/common/selenium_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import platform
import subprocess
import sys
import sysconfig
from pathlib import Path
from typing import List

Expand Down Expand Up @@ -61,9 +62,16 @@ def _get_binary() -> Path:
:Raises: WebDriverException if the platform is unsupported
"""

compiled_path = Path(__file__).parent.joinpath("selenium-manager")
exe = sysconfig.get_config_var("EXE")
if exe is not None:
compiled_path = compiled_path.with_suffix(exe)

if (path := os.getenv("SE_MANAGER_PATH")) is not None:
logger.debug("Selenium Manager set by env SE_MANAGER_PATH to: %s", path)
path = Path(path)
elif compiled_path.exists():
path = compiled_path
else:
allowed = {
("darwin", "any"): "macos/selenium-manager",
Expand Down
7 changes: 7 additions & 0 deletions py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from os.path import dirname, join, abspath
from setuptools import setup
from setuptools.command.install import install
from setuptools_rust import Binding, RustExtension


for scheme in INSTALL_SCHEMES.values():
Expand Down Expand Up @@ -83,6 +84,12 @@
"typing_extensions~= 4.9.0",
"websocket-client==1.8.0",
],
'rust_extensions': [
RustExtension(
{"selenium-manager": "selenium.webdriver.common.selenium-manager"},
binding=Binding.Exec
)
],
'zip_safe': False
}

Expand Down
15 changes: 15 additions & 0 deletions rust/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ rust_library(
deps = all_crate_deps(normal = True),
)

filegroup(
name = "selenium_manager_srcs",
srcs = [
"Cargo.lock",
"Cargo.toml",
":selenium_manager_rs_srcs",
],
visibility = ["//visibility:public"],
)

filegroup(
name = "selenium_manager_rs_srcs",
srcs = glob(["src/**/*.rs"]),
)

rust_test(
name = "unit",
size = "small",
Expand Down

0 comments on commit 785914e

Please sign in to comment.