File tree Expand file tree Collapse file tree 5 files changed +61
-0
lines changed Expand file tree Collapse file tree 5 files changed +61
-0
lines changed 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__ )]
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" )
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" )
Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ async def run(self) -> None:
105105 creationflags = subprocess .CREATE_NO_WINDOW
106106
107107 try :
108+ # For pyinstaller
109+ env = os .environ .copy ()
110+ if getattr (sys , "frozen" , False ):
111+ env ["PLAYWRIGHT_BROWSERS_PATH" ] = "0"
112+
108113 self ._proc = proc = await asyncio .create_subprocess_exec (
109114 str (self ._driver_executable ),
110115 "run-driver" ,
@@ -113,6 +118,7 @@ async def run(self) -> None:
113118 stderr = _get_stderr_fileno (),
114119 limit = 32768 ,
115120 creationflags = creationflags ,
121+ env = env ,
116122 )
117123 except Exception as exc :
118124 self .on_error_future .set_exception (exc )
Original file line number Diff line number Diff line change @@ -168,5 +168,6 @@ def run(self) -> None:
168168 "console_scripts" : [
169169 "playwright=playwright.__main__:main" ,
170170 ],
171+ "pyinstaller40" : ["hook-dirs=playwright._impl.__pyinstaller:get_hook_dirs" ],
171172 },
172173)
You can’t perform that action at this time.
0 commit comments