This repository has been archived by the owner on May 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from golemhq/feature/generate_standalone
Feature/generate standalone
- Loading branch information
Showing
18 changed files
with
308 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
API Reference | ||
================================= | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:glob: | ||
|
||
webdriver-class | ||
webelement-class | ||
golem-expected-conditions | ||
|
||
|
||
.. Indices and tables | ||
.. ================== | ||
.. * :ref:`genindex` | ||
.. * :ref:`modindex` | ||
.. * :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Guides | ||
================================= | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:glob: | ||
|
||
standalone-executable | ||
|
||
|
||
.. Indices and tables | ||
.. ================== | ||
.. * :ref:`genindex` | ||
.. * :ref:`modindex` | ||
.. * :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Generate a Standalone Executable | ||
================================================== | ||
|
||
## Using PyInstaller | ||
|
||
A Golem standalone executable without any dependencies (including Python) can be generated using [PyInstaller](https://pyinstaller.readthedocs.io/). | ||
|
||
Note: the executable must be generated in the same platform that it will be used (e.g.: Windows 10 64 with Python 3.7) | ||
|
||
### Steps | ||
|
||
Create an empty virtualenv (having the required packages only reduces the final executable size): | ||
|
||
``` | ||
virtualenv env | ||
``` | ||
|
||
Clone the repo and install: | ||
|
||
``` | ||
git clone https://github.com/golemhq/golem.git | ||
cd golem | ||
pip install . | ||
``` | ||
|
||
Install PyInstaller | ||
|
||
``` | ||
pip install pyinstaller | ||
``` | ||
|
||
Install python3-dev if needed (Linux) | ||
``` | ||
apt-get install python3-dev | ||
``` | ||
|
||
Generate the executable | ||
|
||
Linux: | ||
``` | ||
pyinstaller golem/bin/golem_standalone.py --onefile -n golem --add-data "golem/gui/templates:golem/gui/templates" --add-data "golem/gui/static:golem/gui/static" | ||
``` | ||
|
||
Windows: | ||
``` | ||
pyinstaller golem\bin\golem_standalone.py --onefile -n golem --add-data "golem\gui\templates;golem\gui\templates" --add-data "golem\gui\static;golem\gui\static" | ||
``` | ||
|
||
Where: | ||
|
||
```--onefile``` generates a single file instead of a folder | ||
|
||
```-n golem``` is the name of the executable | ||
|
||
```--add-data``` includes the templates and static files required by the GUI | ||
|
||
The executable is generated in the *dist* folder. | ||
|
||
|
||
## How to Use the Standalone Executable | ||
|
||
Put the executable in your path. | ||
|
||
The executable includes the *golem*, *golem-admin*, and *webdriver-manager* interfaces. | ||
|
||
Usage: | ||
|
||
``` | ||
golem golem-admin createdirectory . | ||
golem webdriver-manager update | ||
golem gui | ||
golem run project test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,10 @@ | ||
"""A CLI script to start golem from any location | ||
""" | ||
"""CLI script to start golem""" | ||
import os | ||
import sys | ||
import subprocess | ||
|
||
from golem.main import execute_from_command_line | ||
|
||
|
||
def main(): | ||
# Starting the gui using the console script: 'golem gui' | ||
# won't work in windows there is a bug in windows when | ||
# starting the flask app from a console script | ||
# (setup.py, console_scripts) check out | ||
# https://github.com/pallets/werkzeug/issues/1136 | ||
# | ||
# In the meantime, for windows, ensure that the 'golem_start.py' | ||
# file is present otherwise create it first and use it to | ||
# kickstart golem. | ||
# TODO | ||
sys.dont_write_bytecode = True | ||
if os.name == 'nt': | ||
path = os.path.join(os.getcwd(), 'golem_start.py') | ||
if not os.path.isfile(path): | ||
golem_start_py_content = ("import os\n\n" | ||
"from golem.main import execute_from_command_line" | ||
"\n\n" | ||
"if __name__ == '__main__':\n" | ||
" execute_from_command_line(os.getcwd())\n") | ||
with open(path, 'w') as golem_start_file: | ||
golem_start_file.write(golem_start_py_content) | ||
|
||
del sys.argv[0] | ||
cmd_list = ['python', 'golem_start.py'] + sys.argv | ||
subprocess.call(cmd_list) | ||
else: | ||
execute_from_command_line(os.getcwd()) | ||
execute_from_command_line(os.getcwd()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Golem standalone script | ||
Use PyInstaller to generate an executable: | ||
pyinstaller golem/bin/golem_standalone.py --distpath . --onefile -n golem | ||
--add-data "golem/gui/templates:golem/gui/templates" | ||
--add-data "golem/gui/static:golem/gui/static" | ||
Note: use `;` (semi-colon) instead of `:` (colon) in Windows | ||
""" | ||
import os | ||
import sys | ||
from multiprocessing import freeze_support | ||
|
||
from golem.main import execute_from_command_line | ||
from golem.bin import golem_admin | ||
from webdriver_manager.main import main as webdriver_manager_main | ||
from golem.cli.messages import STANDALONE_USAGE | ||
|
||
|
||
if __name__ == '__main__': | ||
freeze_support() | ||
if len(sys.argv) > 1: | ||
if sys.argv[1] in ['golem-admin', 'admin']: | ||
del sys.argv[1] | ||
golem_admin.main() | ||
elif sys.argv[1] == 'webdriver-manager': | ||
del sys.argv[1] | ||
webdriver_manager_main() | ||
else: | ||
execute_from_command_line(os.getcwd()) | ||
else: | ||
print(STANDALONE_USAGE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.