Skip to content

Change code for handling relative short_paths to fix bug #225. #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions experimental/python/wheel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
"""Rules for building wheels."""

def _path_inside_wheel(input_file):
# input_file.short_path is relative ("../${repository_root}/foobar")
# so it can't be a valid path within a zip file. Thus strip out the root
# manually instead of using short_path here.
root = input_file.root.path
if root != "":
# TODO: '/' is wrong on windows, but the path separator is not available in skylark.
# Fix this once ctx.configuration has directory separator information.
root += "/"
if not input_file.path.startswith(root):
fail("input_file.path '%s' does not start with expected root '%s'" % (input_file.path, root))
return input_file.path[len(root):]
# input_file.short_path is sometimes relative ("../${repository_root}/foobar")
# which is not a valid path within a zip file. Fix that.
short_path = input_file.short_path
if short_path.startswith('..') and len(short_path) >= 3:
# Path separator. '/' on linux.
separator = short_path[2]
# Consume '../' part.
short_path = short_path[3:]
# Find position of next '/' and consume everything up to that character.
pos = short_path.find(separator)
short_path = short_path[pos+1:]
return short_path

def _input_file_to_arg(input_file):
"""Converts a File object to string for --input_file argument to wheelmaker"""
Expand Down
5 changes: 4 additions & 1 deletion experimental/rules_python/wheelmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ def main():
# add_wheelfile and add_metadata currently assume pure-Python.
assert arguments.platform == 'any', "Only pure-Python wheels are supported"

input_files = [i.split(';') for i in arguments.input_file]
if arguments.input_file:
input_files = [i.split(';') for i in arguments.input_file]
else:
input_files = []
all_files = get_files_to_package(input_files)
# Sort the files for reproducible order in the archive.
all_files = sorted(all_files.items())
Expand Down