Skip to content

Commit

Permalink
Merge "build: Make binary wheel builder runnable from root dir"
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish authored and Gerrit Code Review committed Sep 8, 2021
2 parents 7afe61e + e0ece17 commit c54e181
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions binaries/build_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
PACKAGER_DL_PREFIX + '/packager',
]

BINARIES_ROOT_DIR = os.path.dirname(__file__)


def build_bdist_wheel(platform_name, platform_binaries):
"""Builds a wheel distribution for `platform_name` adding the files
Expand All @@ -72,12 +74,15 @@ def build_bdist_wheel(platform_name, platform_binaries):
# Run quietly.
'--quiet',
]

# After '--', we send the platform specific binaries that we want to include.
args += ['--']
args += platform_binaries
subprocess.check_call(args)

subprocess.check_call(args, cwd=BINARIES_ROOT_DIR)

# Remove the build directory so that it is not reused by 'setup.py'.
shutil.rmtree('build')
shutil.rmtree(os.path.join(BINARIES_ROOT_DIR, 'build'))

def download_binary(download_url: str, download_dir: str) -> str:
"""Downloads a file and writes it to the file system.
Expand All @@ -99,19 +104,20 @@ def main():
# For each platform(OS+CPU), we download the its binaries and
# create a binary wheel distribution that contains the executable
# binaries specific to this platform.
download_dir = os.path.join(BINARIES_ROOT_DIR, streamer_binaries.__name__)
for platform_name, suffix in PLATFORM_SUFFIXES.items():
binaries_to_include = []
# Use the `suffix` specific to this platfrom to achieve
# the full download link for each binary.
for binary_dl in BINARIES_DL:
download_link = binary_dl + suffix
binary_name = download_binary(download_url=download_link,
download_dir=streamer_binaries.__name__)
download_dir=download_dir)
binaries_to_include.append(binary_name)
# Build a wheel distribution for this platform
# and include the binaries we have just downloaded.
build_bdist_wheel(platform_name, binaries_to_include)


if __name__ == '__main__':
main()
main()

0 comments on commit c54e181

Please sign in to comment.