import os

__version__ = '0.5.0'


# Module level variables.
ffmpeg = ''
"""The path to the installed FFmpeg binary."""
ffprobe = ''
"""The path to the installed FFprobe binary."""
packager = ''
"""The path to the installed Shaka Packager binary."""


# Get the directory path where this __init__.py file resides.
_dir_path = os.path.abspath(os.path.dirname(__file__))

# This will be executed at import time.
for _file in os.listdir(_dir_path):
  if _file.startswith('ffmpeg'):
    ffmpeg = os.path.join(_dir_path, _file)
  elif _file.startswith('ffprobe'):
    ffprobe = os.path.join(_dir_path, _file)
  elif _file.startswith('packager'):
    packager = os.path.join(_dir_path, _file)

import os
import platform

__version__ = '0.5.0'


# Get the directory path where this __init__.py file resides.
_dir_path = os.path.abspath(os.path.dirname(__file__))

# Compute the part of the file name that indicates the OS.
_os = {
  'Linux': 'linux',
  'Windows': 'win',
  'Darwin': 'osx',
}[platform.system()]

# Compute the part of the file name that indicates the CPU architecture.
_cpu = {
  'x86_64': 'x64',  # Linux/Mac report this key
  'AMD64': 'x64',  # Windows reports this key
  'aarch64': 'arm64',
}[platform.machine()]

# Module level variables.
ffmpeg = os.path.join(_dir_path, 'ffmpeg-{}-{}'.format(_os, _cpu))
"""The path to the installed FFmpeg binary."""

ffprobe = os.path.join(_dir_path, 'ffprobe-{}-{}'.format(_os, _cpu))
"""The path to the installed FFprobe binary."""

packager = os.path.join(_dir_path, 'packager-{}-{}'.format(_os, _cpu))
"""The path to the installed Shaka Packager binary."""


Fix usage of local streamer_binaries module
build: Fix usage of local streamer_binaries module

The old code would search the directory for the binary to use.  This
worked fine if the package were installed, but when adding the module
path to PYTHONPATH, this technique would fail because the folder would
have executables for all architetures.

Now we will compute the exact filename we expect for each exectuable,
allowing the module to be used locally without installation.  This is
useful for testing pre-release versions of the module.

Change-Id: I35d3a1009b677ef9d29379147312abe3d0a7f8b2

  import os
+ import platform
  
  __version__ = '0.5.0'
- 
- 
- # Module level variables.
- ffmpeg = ''
- """The path to the installed FFmpeg binary."""
- ffprobe = ''
- """The path to the installed FFprobe binary."""
- packager = ''
- """The path to the installed Shaka Packager binary."""
  
  
  # Get the directory path where this __init__.py file resides.
  _dir_path = os.path.abspath(os.path.dirname(__file__))
  
+ # Compute the part of the file name that indicates the OS.
+ _os = {
+   'Linux': 'linux',
+   'Windows': 'win',
+   'Darwin': 'osx',
+ }[platform.system()]
- # This will be executed at import time.
- for _file in os.listdir(_dir_path):
-   if _file.startswith('ffmpeg'):
-     ffmpeg = os.path.join(_dir_path, _file)
-   elif _file.startswith('ffprobe'):
-     ffprobe = os.path.join(_dir_path, _file)
-   elif _file.startswith('packager'):
-     packager = os.path.join(_dir_path, _file)
  
+ # Compute the part of the file name that indicates the CPU architecture.
+ _cpu = {
+   'x86_64': 'x64',  # Linux/Mac report this key
+   'AMD64': 'x64',  # Windows reports this key
+   'aarch64': 'arm64',
+ }[platform.machine()]
+ 
+ # Module level variables.
+ ffmpeg = os.path.join(_dir_path, 'ffmpeg-{}-{}'.format(_os, _cpu))
+ """The path to the installed FFmpeg binary."""
+ 
+ ffprobe = os.path.join(_dir_path, 'ffprobe-{}-{}'.format(_os, _cpu))
+ """The path to the installed FFprobe binary."""
+ 
+ packager = os.path.join(_dir_path, 'packager-{}-{}'.format(_os, _cpu))
+ """The path to the installed Shaka Packager binary."""
+ 
+ 
Fix usage of local streamer_binaries module
## Code Before:
import os

__version__ = '0.5.0'


# Module level variables.
ffmpeg = ''
"""The path to the installed FFmpeg binary."""
ffprobe = ''
"""The path to the installed FFprobe binary."""
packager = ''
"""The path to the installed Shaka Packager binary."""


# Get the directory path where this __init__.py file resides.
_dir_path = os.path.abspath(os.path.dirname(__file__))

# This will be executed at import time.
for _file in os.listdir(_dir_path):
  if _file.startswith('ffmpeg'):
    ffmpeg = os.path.join(_dir_path, _file)
  elif _file.startswith('ffprobe'):
    ffprobe = os.path.join(_dir_path, _file)
  elif _file.startswith('packager'):
    packager = os.path.join(_dir_path, _file)

## Instruction:
Fix usage of local streamer_binaries module
## Code After:
import os
import platform

__version__ = '0.5.0'


# Get the directory path where this __init__.py file resides.
_dir_path = os.path.abspath(os.path.dirname(__file__))

# Compute the part of the file name that indicates the OS.
_os = {
  'Linux': 'linux',
  'Windows': 'win',
  'Darwin': 'osx',
}[platform.system()]

# Compute the part of the file name that indicates the CPU architecture.
_cpu = {
  'x86_64': 'x64',  # Linux/Mac report this key
  'AMD64': 'x64',  # Windows reports this key
  'aarch64': 'arm64',
}[platform.machine()]

# Module level variables.
ffmpeg = os.path.join(_dir_path, 'ffmpeg-{}-{}'.format(_os, _cpu))
"""The path to the installed FFmpeg binary."""

ffprobe = os.path.join(_dir_path, 'ffprobe-{}-{}'.format(_os, _cpu))
"""The path to the installed FFprobe binary."""

packager = os.path.join(_dir_path, 'packager-{}-{}'.format(_os, _cpu))
"""The path to the installed Shaka Packager binary."""

