-
-
Notifications
You must be signed in to change notification settings - Fork 597
Incrementally download wheels at workspace time. #432
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
aa85289
Create support for incremental repo's.
hrfuller 66e28f6
Lint changes.
hrfuller 49be121
add mypy type annotations to new code
hrfuller 0eae217
add tests for new incremental repo functions.
hrfuller 2257c3f
add example
hrfuller 4e1c72f
update readme
hrfuller 93301f2
f-strings not allowed in CI. Fix syntax error introduced fixing linting.
hrfuller 06a2a6d
fix one more f string and buildifier function docs
hrfuller 64e74c5
Fix typo, and hopefully buildifier
hrfuller 01ba525
fix readme
hrfuller 432da9a
Rename pip_install_incremental to pip_parse
hrfuller 23ed27b
Appease buildifier
hrfuller 6f950b8
Handle the serialized args passed from pip_resository rule.
hrfuller 7c2ee0c
Merge branch 'master' into hrfuller/incremental_deps_import
hrfuller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -37,3 +37,7 @@ bazel-bin | |
bazel-genfiles | ||
bazel-out | ||
bazel-testlogs | ||
|
||
# vim swap files | ||
*.swp | ||
*.swo |
This file contains hidden or 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 hidden or 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 hidden or 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,42 @@ | ||
load("@pip_parsed_deps//:requirements.bzl", "requirement") | ||
load("@rules_python//python:defs.bzl", "py_binary", "py_test") | ||
|
||
# Toolchain setup, this is optional. | ||
# Demonstrate that we can use the same python interpreter for the toolchain and executing pip in pip install (see WORKSPACE). | ||
# | ||
#load("@rules_python//python:defs.bzl", "py_runtime_pair") | ||
# | ||
#py_runtime( | ||
# name = "python3_runtime", | ||
# files = ["@python_interpreter//:files"], | ||
# interpreter = "@python_interpreter//:python_bin", | ||
# python_version = "PY3", | ||
# visibility = ["//visibility:public"], | ||
#) | ||
# | ||
#py_runtime_pair( | ||
# name = "my_py_runtime_pair", | ||
# py2_runtime = None, | ||
# py3_runtime = ":python3_runtime", | ||
#) | ||
# | ||
#toolchain( | ||
# name = "my_py_toolchain", | ||
# toolchain = ":my_py_runtime_pair", | ||
# toolchain_type = "@bazel_tools//tools/python:toolchain_type", | ||
#) | ||
# End of toolchain setup. | ||
|
||
py_binary( | ||
name = "main", | ||
srcs = ["main.py"], | ||
deps = [ | ||
requirement("requests"), | ||
], | ||
) | ||
|
||
py_test( | ||
name = "test", | ||
srcs = ["test.py"], | ||
deps = [":main"], | ||
) |
This file contains hidden or 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,39 @@ | ||
workspace(name = "example_repo") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "rules_python", | ||
url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz", | ||
hrfuller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0", | ||
) | ||
|
||
load("@rules_python//python:pip.bzl", "pip_parse") | ||
|
||
pip_parse( | ||
# (Optional) You can provide extra parameters to pip. | ||
# Here, make pip output verbose (this is usable with `quiet = False`). | ||
# extra_pip_args = ["-v"], | ||
|
||
# (Optional) You can exclude custom elements in the data section of the generated BUILD files for pip packages. | ||
# Exclude directories with spaces in their names in this example (avoids build errors if there are such directories). | ||
#pip_data_exclude = ["**/* */**"], | ||
|
||
# (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that | ||
# acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.: | ||
# 1. Python interpreter that you compile in the build file (as above in @python_interpreter). | ||
# 2. Pre-compiled python interpreter included with http_archive | ||
# 3. Wrapper script, like in the autodetecting python toolchain. | ||
#python_interpreter_target = "@python_interpreter//:python_bin", | ||
|
||
# (Optional) You can set quiet to False if you want to see pip output. | ||
#quiet = False, | ||
|
||
# Uses the default repository name "pip_incremental" | ||
hrfuller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
requirements_lock = "//:requirements_lock.txt", | ||
) | ||
|
||
load("@pip_parsed_deps//:requirements.bzl", "install_deps") | ||
|
||
# Initialize repositories for all packages in requirements_lock.txt. | ||
install_deps() |
This file contains hidden or 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,5 @@ | ||
import requests | ||
|
||
|
||
def version(): | ||
return requests.__version__ |
This file contains hidden or 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 @@ | ||
requests==2.24.0 |
This file contains hidden or 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,16 @@ | ||
# | ||
# This file is autogenerated by pip-compile | ||
# To update, run: | ||
# | ||
# pip-compile --output-file=requirements_lock.txt requirements.txt | ||
# | ||
certifi==2020.12.5 | ||
# via requests | ||
chardet==3.0.4 | ||
# via requests | ||
idna==2.10 | ||
# via requests | ||
requests==2.24.0 | ||
# via -r requirements.txt | ||
urllib3==1.25.11 | ||
# via requests |
This file contains hidden or 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,11 @@ | ||
import unittest | ||
import main | ||
|
||
|
||
class ExampleTest(unittest.TestCase): | ||
def test_main(self): | ||
self.assertEqual("2.24.0", main.version()) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
from argparse import ArgumentParser | ||
|
||
|
||
def parse_common_args(parser: ArgumentParser) -> ArgumentParser: | ||
parser.add_argument( | ||
"--repo", | ||
action="store", | ||
required=True, | ||
help="The external repo name to install dependencies. In the format '@{REPO_NAME}'", | ||
) | ||
parser.add_argument( | ||
"--extra_pip_args", action="store", help="Extra arguments to pass down to pip.", | ||
) | ||
parser.add_argument( | ||
"--pip_data_exclude", | ||
action="store", | ||
help="Additional data exclusion parameters to add to the pip packages BUILD file.", | ||
) | ||
parser.add_argument( | ||
"--enable_implicit_namespace_pkgs", | ||
action="store_true", | ||
help="Disables conversion of implicit namespace packages into pkg-util style packages.", | ||
) | ||
return parser |
This file contains hidden or 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,27 @@ | ||
import argparse | ||
import json | ||
import unittest | ||
|
||
from python.pip_install.extract_wheels.lib import arguments | ||
from python.pip_install.parse_requirements_to_bzl import deserialize_structured_args | ||
|
||
< 6EA8 td id="diff-6c1bebf4cdf069284f914d65b050aa3ad18253fd70c82542fd44579d4ce8c5bcR8" data-line-number="8" class="blob-num blob-num-addition js-linkable-line-number js-blob-rnum"> |
|
|
class ArgumentsTestCase(unittest.TestCase): | ||
def test_arguments(self) -> None: | ||
parser = argparse.ArgumentParser() | ||
parser = arguments.parse_common_args(parser) | ||
repo_name = "foo" | ||
index_url = "--index_url=pypi.org/simple" | ||
args_dict = vars(parser.parse_args( | ||
args=["--repo", repo_name, "--extra_pip_args={index_url}".format(index_url=json.dumps({"args": index_url}))])) | ||
args_dict = deserialize_structured_args(args_dict) | ||
self.assertIn("repo", args_dict) | ||
self.assertIn("extra_pip_args", args_dict) | ||
self.assertEqual(args_dict["pip_data_exclude"], None) | ||
self.assertEqual(args_dict["enable_implicit_namespace_pkgs"], False) | ||
self.assertEqual(args_dict["repo"], repo_name) | ||
self.assertEqual(args_dict["extra_pip_args"], index_url) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.