Using BrightSign Python-Only Builds
BrightSign provides "Python-only" builds that can installed on players as an addition to our base operating system. Python packages are installed on the developer’s machine, published to the player, and executed by the Python application installed by the Python-only build.
Downloading BrightSign Python-Only Builds
To download BrightSignOS and the Python production build that can be used with your Series 4 player, see BrightSign Python-Only Builds.
Series 2 and 3 players are not compatible with Python, but Series 5 players and operating systems will be compatible with Python in the near future.
Installing BrightSign Python-Only Builds
The base OS version and the Python-only version should be kept in sync. To install:
Copy BrightSignOS to the root of the SD card, then reboot your player.
Copy the Python update to the root of the SD card, then reboot your player.
Installing Third-Party Python Libraries
To show you how to install third-party Python-only libraries on a BrightSign player, we have included the following package and instructions that include a specific module (“requests”).
To use this example:
Download the zip file below.
Open the pkgex directory. The simple pkgex.py script executes a user loaded package (
request
).Copy the ./ directory, which contains /autorun.brs and /pkgex, to your SD card.
Run /pkgex/pkgex.py using roPython (the autorun.brs included in this example will execute this).
We recommend pip to download any third-party modules, but other methods can be used instead.
Included modules must not contain binaries. To ensure that your module does not contain binaries, use the pip download
command with the --no-binary
flag. See https://pip.pypa.io/en/stable/cli/pip_download/ for more information.
Example
This .brs example uses the roPython object within BrightScript to execute a Python script:
Sub main()
p = CreateObject("roPython")
mp = CreateObject("roMessagePort")
p.SetPort(mp)
res = p.AsyncExecute("pkgex/pkgex.py")
print "p.AsyncExecute() results, ";res
' if res is false then print p.GetFailureReason() will provide more info
if res = false then
failureReason = p.GetFailureReason()
print "python execute failure reason";failureReason
end if
while true
msg = wait(1000, mp)
end while
End Sub
Notes
BrightSign runs Python with a -E flag. In this example the modules are in the same directory as the script. If your modules are not in the same working directory as your script, add your directories as entries to sys.path (the list of directories that are examined for Python packages). For example:
sys.path.append('/path to my directory')
A number of modules come with our Python (mostly built ins). You can see this list by opening the Python interpreter and typing
help("modules")
Â