Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tanin47/bazel-pex-pip
https://github.com/tanin47/bazel-pex-pip
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tanin47/bazel-pex-pip
- Owner: tanin47
- Created: 2017-04-13T03:17:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-14T04:37:37.000Z (over 7 years ago)
- Last Synced: 2024-08-05T03:01:48.543Z (3 months ago)
- Language: Python
- Size: 9.77 KB
- Stars: 11
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-bazel - Python pip
README
Example of Bazel with pex and pip
==================================This repo is a working example showing how to use [Bazel](https://bazel.build/)
with [pex](https://github.com/pantsbuild/pex) and
[pip](https://github.com/pypa/pip).This repo is meant to be educational. Therefore, please read the code.
The example shows:
* pulls dependencies using pip
* builds a single binary with pex
* reads a resource fileUsage
-------1. `bazel build main.pex`
2. `./bazel-bin/main.pex`The output:
```
Current file's path: /usr/local/google/home/tanin/.pex/code/e7c476458b50c0339f6e515b84111b4dd9dee723/test.py
appdirs' path: /usr/local/google/home/tanin/.pex/install/appdirs-1.4.3-py2.py3-none-any.whl.88ca3acdb0294d36138be8eb8d73eb234d0cc1d3/appdirs-1.4.3-py2.py3-none-any.whl/appdirs.pyc
Test.json's content: TEST
Finished.
```Notice that `appdirs` comes from within `.pex`.
Design Decision
-----------------### Why do we choose pex over [subpar](https://github.com/google/subpar)?
Subpar doesn't support extracting resource files from the archive. If we have a
more complex use case (e.g. executing a bash script), we can't use subpar.Pex, on another hand, can set `zip_safe=False` which extracts the archive before
executing the python code.Special Thanks
----------------* [The snippet](https://github.com/bazelbuild/bazel/issues/699#issuecomment-262091510) on pip integration from @trivigy
* [The pex integration](https://github.com/benley/bazel_rules_pex) from @benley