Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py] Remove precompiled binaries from sdist #14233

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading