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

Add experimental support for building wheels. #128

wants to merge 57 commits into from

Conversation

pstradomski
Copy link
Contributor

Currently only pure python wheels are supported.

This extension builds wheels directly, invoking a simple python script that creates the zip archive in the desired format instead of using distutils/setuptools.

This will make building platform-dependent wheels easier in the future, as bazel
will have full control on how extension code is built.

mandatory=True,
allow_empty=False,
doc="""\
List of Python packages to include in the distribution.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is controversial and perhaps worth discussing.

A typical package will have dependencies on other packages; some might be first party but packaged separately, some might be third party. From bazel point of view they will probably form a tree of py_library dependencies.

When creating a wheel package one does not want to include the whole tree, so we need to tell bazel where to cut the chain. I see three ways to do that:

  1. Don't follow dependencies. Only package up the libraries listed directly in deps.
  2. Follow dependencies and only package specific python packages
    a) Including sub-packages, so e.g. if "foo" is listed then "foo.bar" gets packaged too
    b) Not including sub-packages.

The implementation here does "2a", but I could see how other options could be preferred. I'm happy to change if you think other options are better.

@pstradomski
Copy link
Contributor Author

@brandjon: any chances somebody with commit rights takes a look? Thanks!

@dsully
Copy link
dsully commented Jan 14, 2019

Would love to see this make it into the repo. Any progress here?

Thanks

@pstradomski
Copy link
Contributor Author
pstradomski commented Jan 14, 2019 via email

@pstradomski
Copy link
Contributor Author
pstradomski commented Jan 14, 2019

There's still some issues on systems where default python is py2, I'll try to get them fixed by the end of the week.

mattmoor and others added 24 commits January 15, 2019 19:06
Quoting @duggelz

> From PEP 508 it appears that you can register packages with any capitalization, and install them with any capitalization, even if it's different. I.e. you can register package 'MyPackage' and install it with mypackage, MYPACKAGE, or even mYpAcKaGe.
>
> That is not an ideal spec, but is it the spec, and the tools implement it, so we should to.
`boto3`s `metadata.json` file doesn't delimit the version specifier the way other packages I've come across seem to, so support splitting on the kinds of characters this variation might foist upon us.

Fixes: #20
The warning is:
   You are using pip version 1.5.4, however version 9.0.1 is avai
10000
lable.
   You should consider upgrading via the 'pip install --upgrade pip' command.

In reality, pip is at 9.0.1, but its bundled version of pkg_resources
doesn't know that.

See google/subpar#38
Use the skylark `fail` function instead of letting Python throw a
key-not-found exception.
This also fixes a couple bugs I hit after regenerating piptool.par:
 - os.environ['PYTHONPATH'] may result in a KeyError
 - The cert expansion logic was removed, but things fail without it (after I ./update_tools.sh).  I thought this was intentional (should the PAR changes have fixes this?), but I'm restoring for now to keep HEAD in a good state.
"Extras" are additional dependencies of a given library, which are consumed by passing the "extra" name in brackets after the distribution name, for example:
```
mock[docs]==1.0.1
```

We see this in the dependencies of several Google Cloud libraries, which depend on: `googleapis_common_protos[grpc]`

I've added a simple test that the dependency structure we synthesize for this kind of thing is correct via an "extras" test that has a `requirements.txt` of:
```
google-cloud-language==0.27.0
```

Fixes: #12
* Evaluate PEP 508 environment markers for package dependencies

Previously any wheel dependencies that had an environment marker
(such as 'python_version>3.3') were simply ignored, leading to
missing packages in the Python environment constructed by bazel.

Fixes #49

* Regenerate the piptool.par

Required after making changes to whl.py

* Pin the version of setuptools in piptool & extract whltool

Some common operators in version markers (e.g., <=) are only supported
in setuptools>=17.1. Rather than risk failing because the environment
has an old setuptools version it's better to include it. Pinning to
an exact version (currently the latest) to make things as predictable
as possible.

In addition, whl.py used during workspace setup also now depends on
setuptools. We package this in a separate whltool.par to make this
predictable as well.
* Use posixpath to build internal zip file paths

* Use literal / instead of posixpath

* Update piptool.par and whltool.par
Doug Greiman and others added 22 commits January 15, 2019 19:06
Add proposals directory and proposal for 2/3 mode
It was already in review but I didn't realize that was considered a status change.
This fixes the breakage in #98 by working around #70.
The test is brittle and shouldn't be used as a security guarantee anyway. See #117 (comment) for more context.

Fixes #117.
This upgrades our dependencies to newer versions that are compatible with the new repo rules, and handles the fallout. Also add some comments to WORKSPACE.

rules_python now builds under Bazel 0.19.1 with `--incompatible_remove_native_git_repository` and `incompatible_remove_native_http_archive`.

Fixes #105.
This reformats the files and applies some automated fixes. This should
help get the repository forward-compatible with Bazel incompatible
changes.

Progress towards #134
Remaining issues are caused by subpar
Tested:
  bazel-0.21 test //... --all_incompatible_changes

Fixes #134
Currently only pure python wheels are supported.

This extension builds wheels directly, invoking a simple python
script that creates the zip archive in desired format instead of
using distutils/setuptools. This will make building
platform-dependent wheels easier in the future, as bazel
will have full control on how extension code is built.
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@pstradomski
Copy link
Contributor Author

Would love to see this make it into the repo. Any progress here?

Thanks

@pstradomski
Copy link
Contributor Author
pstradomski commented Jan 15, 2019

Going to try with a new pull request to avoid all the merge mess here:
#159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0