8000 Add experimental support for building wheels. by pstradomski · Pull Request #128 · bazel-contrib/rules_python · GitHub
[go: up one dir, main page]

Skip to content

Add experimental support for building wheels. #128

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

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
791f5a5
Fix documentation bug
mattmoor Sep 19, 2017
8f819ed
Update dependencies for compatibility with Bazel 0.6.0
vladmos Sep 21, 2017
ab4c256
Allow any capitalization in requirement names.
mattmoor Sep 20, 2017
79e88ea
Split on more characters when stripping the version metadata.
mattmoor Oct 4, 2017
e5e88a4
Note that "{HEAD}" is invalid, not special.
mattmoor Oct 8, 2017
6e0c4b6
Correctly decode metadata.json into a utf8 str
Oct 5, 2017
4c2b37b
Update build status badge to use https
davidstanke Oct 18, 2017
2e26ccf
Fix comment
drigz Nov 2, 2017
19c99c5
Silence a warning erroneously emitted by pip.
Nov 4, 2017
f939e95
Allow piptool to build wheels.
Nov 10, 2017
0038462
Handle METADATA files in python wheels
jac-stripe Nov 10, 2017
3cbad1a
Add test for wheels with METADATA
jac-stripe Nov 12, 2017
c847d21
Remove stale comment and redundant imports
Nov 13, 2017
22b22ef
Handle empty requirements.txt
hwright Nov 13, 2017
301b35c
Add a better error message when deps not found
hwright Nov 13, 2017
e9e2aa9
Fix typo: requirements -> _requirements
hwright Nov 13, 2017
a2c8867
This updates WORKSPACE to the latest subpar, and ./update_tools.sh.
mattmoor Nov 16, 2017
18fb4ee
This adds support for "extras".
mattmoor Sep 22, 2017
47d1642
Split the extras param by comma
jac-stripe Nov 27, 2017
fcb4913
fixes
jac-stripe Nov 28, 2017
8180a4f
Update python.md
mapx Dec 8, 2017
0214557
Evaluate PEP 508 environment markers for package dependencies (#50)
nikhaldi Jan 9, 2018
7d2bc47
Use literal '/'s to build internal zip file paths (#51)
earhart Jan 17, 2018
119482b
Add disclaimer about alpha release status (#66)
Feb 16, 2018
b1bd521
Add a simple test that the built and checked in PAR files match. (#10)
mattmoor Feb 16, 2018
d82d7c7
add new bazel ci config
buchgr Feb 23, 2018
b4dab08
Support "+" in package versions.
calder Mar 19, 2018
ff1fad4
Update .par files.
calder Mar 26, 2018
5e4405a
Remove unnecessary '\'.
calder Mar 26, 2018
d50965b
Update pip version to 9.0.3.
jkinkead Apr 6, 2018
69a02ff
Add verbose failure messages to par_test.py
Apr 5, 2018
c8d5963
Force a test failure
Apr 5, 2018
c2fcb23
Force a different test failure.
Apr 5, 2018
fc4e093
Revert "Force a different test failure."
Apr 5, 2018
6421aad
Regenerate .par file
Apr 5, 2018
4ab431b
Regenerate .par files on Python 2.7.12
Apr 5, 2018
ca5ec01
Regenerate piptool.par
Apr 7, 2018
509fbfb
Update par files in a Docker container with known-good Python interpr…
Apr 9, 2018
d469e26
Add --no-cache flag, since it's usually what you want.
Apr 16, 2018
5c5d81d
Regenerate par files with Bazel 0.12
Apr 16, 2018
67b8700
Selecting Between Python 2 and 3 (#127)
brandjon Nov 2, 2018
7fd3179
Add reviewer to py2/3 design doc
brandjon Nov 2, 2018
3c6ae62
Add proposal for custom stub template (#130)
brandjon Nov 9, 2018
a10e230
Update py2/3 proposal status to "Under review"
brandjon Nov 9, 2018
a3beac8
Add six as explicit dep of boto_test (#131)
brandjon Nov 13, 2018
f7731e4
Delete //tools:par_test (#133)
brandjon Nov 14, 2018
d5f8698
Switch to new http repo rules (#135)
brandjon Nov 16, 2018
ac338ee
Run `buildifier --lint=fix` (#138)
laurentlb Nov 27, 2018
db6e570
Update sass and skydoc dependencies (#139)
laurentlb Nov 27, 2018
9db20df
Update py2/3 proposal to address select() behavior (#141)
brandjon Dec 17, 2018
57e6b1c
Update subpar dependency (#147)
laurentlb Dec 18, 2018
602a415
Clarify plan for select() again (#149)
brandjon Dec 19, 2018
3cf08a1
Add loading of git_repository rule to README (#152)
danieljanes Jan 7, 2019
ba2b536
Update migration path for py23 proposal (#153)
brandjon Jan 10, 2019
a3925a0
Mark Py 2/3 proposal accepted (#155)
brandjon Jan 11, 2019
7227427
Py23 proposal: Update plan for py provider fields (#156)
brandjon Jan 12, 2019
3852dad
Add experimental support for building wheels.
pstradomski Nov 2, 2018
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
17 changes: 17 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
platforms:
ubuntu1404:
build_targets:
- "..."
test_targets:
- "..."
ubuntu1604:
build_targets:
- "..."
test_targets:
- "..."
macos:
build_targets:
- "..."
test_targets:
- "..."
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Bazel Python Rules
# Experimental Bazel Python Rules

[![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_python)](http://ci.bazel.io/job/rules_python)
Status: This is **ALPHA** software.

[![Build status](https://badge.buildkite.com/0bcfe58b6f5741aacb09b12485969ba7a1205955a45b53e854.svg)](https://buildkite.com/bazel/python-rules-python-postsubmit)

## Rules

Expand All @@ -21,14 +23,17 @@ dependencies typically managed via `pip`.
Add the following to your `WORKSPACE` file to add the external repositories:

```python
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "io_bazel_rules_python",
remote = "https://github.com/bazelbuild/rules_python.git",
# NOT VALID! Replace this with a Git commit SHA.
commit = "{HEAD}",
)

# Only needed for PIP support:
load("//python:pip.bzl", "pip_repositories")
load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories")

pip_repositories()
```
Expand Down Expand Up @@ -105,6 +110,10 @@ for dependencies, however, it is recommended that folks stick with the
`requirement` pattern in case the need arises for us to make changes to this
format in the future.

["Extras"](
https://packaging.python.org/tutorials/installing-packages/#installing-setuptools-extras)
will have a target of the extra name (in place of `pkg` above).

## Updating `docs/`

All of the content (except `BUILD`) under `docs/` is generated. To update the
Expand Down
119 changes: 101 additions & 18 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,59 @@
# 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.

workspace(name = "io_bazel_rules_python")

# Skydoc stuff
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")

################################
# Skydoc and its dependencies. #
################################

# Skydoc's sass dependency is not covered by skydoc_repositories(), so we have
# to redeclare it here. Watch that the version matches when updating Skydoc's
# version.

git_repository(
name = "io_bazel_rules_sass",
# Same commit as Skydoc uses in its own WORKSPACE.
commit = "8ccf4f1c351928b55d5dddf3672e3667f6978d60", # 2018-11-23
remote = "https://github.com/bazelbuild/rules_sass.git",
tag = "0.0.2",
)

load("@io_bazel_rules_sass//sass:sass.bzl", "sass_repositories")
load("@io_bazel_rules_sass//:package.bzl", "rules_sass_dependencies")

rules_sass_dependencies()

# Node is used by sass. This weird (anti-?)pattern of initializing a repo we
# didn't directly import is taken from Skydoc's WORKSPACE.
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")

node_repositories()

load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")

sass_repositories()

# We implicitly depend on Skydoc importing Skylib under `@bazel_skylib`.
# We don't redeclare it here in order to avoid repeating a definition that
# could get out of sync with Skydoc.

git_repository(
name = "io_bazel_skydoc",
commit = "1cdb612e31448c2f6eb25b8aa67d406152275482", # 2018-11-27
remote = "https://github.com/bazelbuild/skydoc.git",
tag = "0.1.3",
)

load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories")

skydoc_repositories()

# Requirements for building our piptool.
##########################################
# Requirements for building our piptool. #
##########################################

load("//python:pip.bzl", "pip_import")

pip_import(
Expand All @@ -51,39 +80,69 @@ _piptool_install()

git_repository(
name = "subpar",
# HEAD as of 2018-12-18
commit = "81d33bafbad4edcb2c9e98548888fc9815c004c4",
remote = "https://github.com/google/subpar",
tag = "1.0.0",
)

# Test data for WHL tool testing.
###################################
# Test data for WHL tool testing. #
###################################

http_file(
name = "grpc_whl",
downloaded_file_path = "grpcio-1.6.0-cp27-cp27m-manylinux1_i686.whl",
sha256 = "c232d6d168cb582e5eba8e1c0da8d64b54b041dd5ea194895a2fe76050916561",
# From https://pypi.python.org/pypi/grpcio/1.6.0
url = ("https://pypi.python.org/packages/c6/28/" +
"67651b4eabe616b27472c5518f9b2aa3f63beab8f62100b26f05ac428639/" +
"grpcio-1.6.0-cp27-cp27m-manylinux1_i686.whl"),
urls = [("https://pypi.python.org/packages/c6/28/" +
"67651b4eabe616b27472c5518f9b2aa3f63beab8f62100b26f05ac428639/" +
"grpcio-1.6.0-cp27-cp27m-manylinux1_i686.whl")],
)

http_file(
name = "futures_whl",
name = "futures_3_1_1_whl",
downloaded_file_path = "futures-3.1.1-py2-none-any.whl",
sha256 = "c4884a65654a7c45435063e14ae85280eb1f111d94e542396717ba9828c4337f",
# From https://pypi.python.org/pypi/futures
url = ("https://pypi.python.org/packages/a6/1c/" +
"72a18c8c7502ee1b38a604a5c5243aa8c2a64f4bba4e6631b1b8972235dd/" +
"futures-3.1.1-py2-none-any.whl"),
urls = [("https://pypi.python.org/packages/a6/1c/" +
"72a18c8c7502ee1b38a604a5c5243aa8c2a64f4bba4e6631b1b8972235dd/" +
"futures-3.1.1-py2-none-any.whl")],
)

http_file(
name = "futures_2_2_0_whl",
downloaded_file_path = "futures-2.2.0-py2.py3-none-any.whl",
sha256 = "9fd22b354a4c4755ad8c7d161d93f5026aca4cfe999bd2e53168f14765c02cd6",
# From https://pypi.python.org/pypi/futures/2.2.0
urls = [("https://pypi.python.org/packages/d7/1d/" +
"68874943aa37cf1c483fc61def813188473596043158faa6511c04a038b4/" +
"futures-2.2.0-py2.py3-none-any.whl")],
)

http_file(
name = "mock_whl",
downloaded_file_path = "mock-2.0.0-py2.py3-none-any.whl",
sha256 = "5ce3c71c5545b472da17b72268978914d0252980348636840bd34a00b5cc96c1",
# From https://pypi.python.org/pypi/mock
url = ("https://pypi.python.org/packages/e6/35/" +
"f187bdf23be87092bd0f1200d43d23076cee4d0dec109f195173fd3ebc79/" +
"mock-2.0.0-py2.py3-none-any.whl"),
urls = [("https://pypi.python.org/packages/e6/35/" +
"f187bdf23be87092bd0f1200d43d23076cee4d0dec109f195173fd3ebc79/" +
"mock-2.0.0-py2.py3-none-any.whl")],
)

http_file(
name = "google_cloud_language_whl",
downloaded_file_path = "google_cloud_language-0.29.0-py2.py3-none-any.whl",
sha256 = "a2dd34f0a0ebf5705dcbe34bd41199b1d0a55c4597d38ed045bd183361a561e9",
# From https://pypi.python.org/pypi/google-cloud-language
urls = [("https://pypi.python.org/packages/6e/86/" +
"cae57e4802e72d9e626ee5828ed5a646cf4016b473a4a022f1038dba3460/" +
"google_cloud_language-0.29.0-py2.py3-none-any.whl")],
)

# Imports for examples
#########################
# Imports for examples. #
#########################

pip_import(
name = "examples_helloworld",
requirements = "//examples/helloworld:requirements.txt",
Expand All @@ -107,3 +166,27 @@ load(
)

_version_install()

pip_import(
name = "examples_boto",
requirements = "//examples/boto:requirements.txt",
)

load(
"@examples_boto//:requirements.bzl",
_boto_install = "pip_install",
)

_boto_install()

pip_import(
name = "examples_extras",
requirements = "//examples/extras:requirements.txt",
)

load(
"@examples_extras//:requirements.bzl",
_extras_install = "pip_install",
)

_extras_install()
3 changes: 2 additions & 1 deletion docs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ licenses(["notice"]) # Apache 2.0
# To regenerate html docs, run:
# ./update_docs.sh

load("@io_bazel_skydoc//skylark:skylark.bzl", "skylark_doc", "skylark_library")
load("@bazel_skylib//:skylark_library.bzl", "skylark_library")
load("@io_bazel_skydoc//skylark:skylark.bzl", "skylark_doc")

skylark_library(
name = "whl",
Expand Down
1 change: 1 addition & 0 deletions docs/python/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Documentation generated by Skydoc
<li><a href="#py_test">py_test</a></li>
</ul>
</nav>

<a name="py_library"></a>
## py_library

Expand Down
30 changes: 30 additions & 0 deletions examples/boto/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2017 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.
package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # Apache 2.0

load("@examples_boto//:requirements.bzl", "requirement")
load("//python:python.bzl", "py_test")

py_test(
name = "boto_test",
srcs = ["boto_test.py"],
deps = [
requirement("boto3"),
# six is a transitive dependency via python-dateutil. Explicitly depend
# on it to work around issue #70; see issue #98.
requirement("six"),
],
)
26 changes: 26 additions & 0 deletions examples/boto/boto_test.py
2851
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2017 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.

import boto3
import unittest


class BotoTest(unittest.TestCase):

def test_version(self):
self.assertEqual(boto3.__version__, '1.4.7')


if __name__ == '__main__':
unittest.main()
1 change: 1 addition & 0 deletions examples/boto/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
boto3==1.4.7
29 changes: 29 additions & 0 deletions examples/extras/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2017 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.
package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # Apache 2.0

load("@examples_extras//:requirements.bzl", "requirement")
load("//python:python.bzl", "py_test")

py_test(
name = "extras_test",
srcs = ["extras_test.py"],
deps = [
requirement("google-cloud-language"),
# Make sure that we can resolve the "extra" dependency
requirement("googleapis-common-protos[grpc]"),
],
)
25 changes: 25 additions & 0 deletions examples/extras/extras_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2017 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.

import unittest


# The test is the build itself, which should not work if extras are missing.
class ExtrasTest(unittest.TestCase):
def test_nothing(self):
pass


if __name__ == '__main__':
unittest.main()
1 change: 1 addition & 0 deletions examples/extras/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google-cloud-language==0.27.0
26 changes: 26 additions & 0 deletions examples/extras/version_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2017 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.

import pip
import unittest


class VersionTest(unittest.TestCase):

def test_version(self):
self.assertEqual(pip.__version__, '9.0.3')


if __name__ == '__main__':
unittest.main()
Loading
0