Skip to content

fix: Installation from source using GitHub #537

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

Merged
merged 1 commit into from
Apr 19, 2021
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
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r local-requirements.txt
pip install -e .
python setup.py bdist_wheel
python setup.py bdist_wheel --all
python -m playwright install-deps
- name: Publish package
env:
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repos:
- id: end-of-file-fixer
exclude: ^playwright/drivers/browsers.json$
- id: check-yaml
- id: check-toml
- id: requirements-txt-fixer
- repo: https://github.com/psf/black
rev: 20.8b1
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Build and install drivers:
```sh
pip install -e.
python setup.py bdist_wheel
# For all platforms
python setup.py bdist_wheel --all
```

Run tests:
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools-scm", "wheel", "auditwheel"]
build-backend = "setuptools.build_meta"
39 changes: 26 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ def extractall(zip: zipfile.ZipFile, path: str) -> None:


class PlaywrightBDistWheelCommand(BDistWheelCommand):
user_options = BDistWheelCommand.user_options + [
("all", "a", "create wheels for all platforms")
]
boolean_options = BDistWheelCommand.boolean_options + ["all"]

def initialize_options(self) -> None:
super().initialize_options()
self.all = False

def run(self) -> None:
if os.path.exists("build"):
shutil.rmtree("build")
Expand All @@ -47,7 +56,16 @@ def run(self) -> None:
super().run()
os.makedirs("driver", exist_ok=True)
os.makedirs("playwright/driver", exist_ok=True)
for platform in ["mac", "linux", "win32", "win32_x64"]:
platform_map = {
"darwin": "mac",
"linux": "linux",
"win32": "win32_x64" if sys.maxsize > 2 ** 32 else "win32",
}
if self.all:
platforms = ["mac", "linux", "win32", "win32_x64"]
else:
platforms = [platform_map[sys.platform]]
for platform in platforms:
zip_file = f"playwright-{driver_version}-{platform}.zip"
if not os.path.exists("driver/" + zip_file):
url = "https://playwright.azureedge.net/builds/driver/"
Expand All @@ -56,14 +74,10 @@ def run(self) -> None:
print("Fetching ", url)
# Don't replace this with urllib - Python won't have certificates to do SSL on all platforms.
subprocess.check_call(["curl", url, "-o", "driver/" + zip_file])
base_wheel_location = glob.glob("dist/*.whl")[0]
base_wheel_location = glob.glob(os.path.join(self.dist_dir, "*.whl"))[0]
without_platform = base_wheel_location[:-7]
platform_map = {
"darwin": "mac",
"linux": "linux",
"win32": "win32_x64" if sys.maxsize > 2 ** 32 else "win32",
}
for platform in ["mac", "linux", "win32", "win32_x64"]:

for platform in platforms:
zip_file = f"driver/playwright-{driver_version}-{platform}.zip"
with zipfile.ZipFile(zip_file, "r") as zip:
extractall(zip, f"driver/{platform}")
Expand All @@ -88,26 +102,25 @@ def run(self) -> None:
from_path = os.path.join(dir_path, file)
to_path = os.path.relpath(from_path, driver_root)
zip.write(from_path, f"playwright/driver/{to_path}")
if platform == "mac":
if platform == "mac" and self.all:
# Ship mac both as 10_13 as and 11_0 universal to work across Macs.
universal_location = without_platform + "macosx_11_0_universal2.whl"
shutil.copyfile(wheel_location, universal_location)
with zipfile.ZipFile(universal_location, "a") as zip:
zip.writestr("playwright/driver/README.md", "Universal Mac package")

os.remove(base_wheel_location)
for whlfile in glob.glob("dist/*.whl"):

for whlfile in glob.glob(os.path.join(self.dist_dir, "*.whl")):
os.makedirs("wheelhouse", exist_ok=True)
with InWheel(
in_wheel=whlfile,
out_wheel=os.path.join("wheelhouse", os.path.basename(whlfile)),
ret_self=True,
):
print("Updating RECORD file of %s" % whlfile)
shutil.rmtree("dist")
shutil.rmtree(self.dist_dir)
print("Copying new wheels")
shutil.move("wheelhouse", "dist")
shutil.move("wheelhouse", self.dist_dir)


setuptools.setup(
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy