GeezerVison is showing github.com — feat: added hooks for pyinstaller (#812) · Coder-Soder/playwright-python@bc7a802
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# Copyright (c) Microsoft Corporation. | | 2 | +# | | 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); | | 4 | +# you may not use this file except in compliance with the License. | | 5 | +# You may obtain a copy of the License at | | 6 | +# | | 7 | +# http://www.apache.org/licenses/LICENSE-2.0 | | 8 | +# | | 9 | +# Unless required by applicable law or agreed to in writing, software | | 10 | +# distributed under the License is distributed on an "AS IS" BASIS, | | 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 12 | +# See the License for the specific language governing permissions and | | 13 | +# limitations under the License. | | 14 | + | | 15 | +import os | | 16 | +from typing import List | | 17 | + | | 18 | + | | 19 | +def get_hook_dirs() -> List[str]: | | 20 | + return [os.path.dirname(__file__)] |
Collapse file Copy file name to clipboard +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# Copyright (c) Microsoft Corporation. | | 2 | +# | | 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); | | 4 | +# you may not use this file except in compliance with the License. | | 5 | +# You may obtain a copy of the License at | | 6 | +# | | 7 | +# http://www.apache.org/licenses/LICENSE-2.0 | | 8 | +# | | 9 | +# Unless required by applicable law or agreed to in writing, software | | 10 | +# distributed under the License is distributed on an "AS IS" BASIS, | | 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 12 | +# See the License for the specific language governing permissions and | | 13 | +# limitations under the License. | | 14 | + | | 15 | +from PyInstaller.utils.hooks import collect_data_files | | 16 | + | | 17 | +datas = collect_data_files("playwright") |
Collapse file Copy file name to clipboard +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# Copyright (c) Microsoft Corporation. | | 2 | +# | | 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); | | 4 | +# you may not use this file except in compliance with the License. | | 5 | +# You may obtain a copy of the License at | | 6 | +# | | 7 | +# http://www.apache.org/licenses/LICENSE-2.0 | | 8 | +# | | 9 | +# Unless required by applicable law or agreed to in writing, software | | 10 | +# distributed under the License is distributed on an "AS IS" BASIS, | | 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 12 | +# See the License for the specific language governing permissions and | | 13 | +# limitations under the License. | | 14 | + | | 15 | +from PyInstaller.utils.hooks import collect_data_files | | 16 | + | | 17 | +datas = collect_data_files("playwright") |
Collapse file Copy file name to clipboardExpand all lines: playwright/_impl/_transport.py +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -105,6 +105,11 @@ async def run(self) -> None: | 105 | 105 | creationflags = subprocess.CREATE_NO_WINDOW | 106 | 106 |
| 107 | 107 | try: | | 108 | + # For pyinstaller | | 109 | + env = os.environ.copy() | | 110 | + if getattr(sys, "frozen", False): | | 111 | + env["PLAYWRIGHT_BROWSERS_PATH"] = "0" | | 112 | + | 108 | 113 | self._proc = proc = await asyncio.create_subprocess_exec( | 109 | 114 | str(self._driver_executable), | 110 | 115 | "run-driver", | @@ -113,6 +118,7 @@ async def run(self) -> None: | 113 | 118 | stderr=_get_stderr_fileno(), | 114 | 119 | limit=32768, | 115 | 120 | creationflags=creationflags, | | 121 | + env=env, | 116 | 122 | ) | 117 | 123 | except Exception as exc: | 118 | 124 | self.on_error_future.set_exception(exc) | |
Collapse file Copy file name to clipboardExpand all lines: setup.py +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -168,5 +168,6 @@ def run(self) -> None: | 168 | 168 | "console_scripts": [ | 169 | 169 | "playwright=playwright.__main__:main", | 170 | 170 | ], | | 171 | + "pyinstaller40": ["hook-dirs=playwright._impl.__pyinstaller:get_hook_dirs"], | 171 | 172 | }, | 172 | 173 | ) |
|