-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace whltool.par with whltool_wrapper.py
- Loading branch information
Doug Greiman
committed
Mar 28, 2018
1 parent
045f37c
commit ee2e83a
Showing
3 changed files
with
62 additions
and
5 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,59 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright 2018 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Wrapper to invoke whl.py with vendored third-party dependencies. | ||
This wrapper must work under Python 2.7.*, or any Python 3.* >= 3.4.0. | ||
It must also work under Linux, Mac OS, Windows, and any other | ||
operating system. It must work inside or outside a virtualenv, inside | ||
or outside a runfiles tree, and inside or outside a Bazel execroot. | ||
It must work with arbitrary other packages on the Python import path. | ||
""" | ||
|
||
import os | ||
import sys | ||
|
||
# Add our first-party source, and vendored third_party packages, to | ||
# the start of sys.path, so that we win any collision with already | ||
# installed modules. | ||
|
||
_this_file = __file__ | ||
if (_this_file is None) or not os.path.isfile(_this_file): | ||
sys.exit("whltool_wrapper.py failed. Cannot determine __file__") | ||
|
||
_tool_dir = os.path.dirname(_this_file) | ||
_root_dir = os.path.abspath(os.path.join(_tool_dir, '..')) | ||
sys.path[0:0] = [ | ||
# Vendored third_party packages | ||
os.path.join(_root_dir, 'third_party'), | ||
# First party source (not a Python import package, just a directory) | ||
os.path.join(_root_dir, 'rules_python'), | ||
] | ||
|
||
# Safe to import | ||
import setuptools | ||
import pkg_resources | ||
import wheel | ||
import pip | ||
|
||
# Sanity check that vendoring logic worked | ||
assert setuptools.__version__ == '38.5.1' | ||
assert wheel.__version__ == '0.30.0' | ||
assert pip.__version__ == '9.0.1' | ||
|
||
# Invoke tool | ||
import whl | ||
whl.main() |