All Projects → dillon-giacoppo → Rules_python_external

dillon-giacoppo / Rules_python_external

Licence: apache-2.0
Bazel rules to resolve and fetch artifacts transitively from the Python Package Index (PyPI)

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Rules python external

rules poetry
Bazel rules that use Poetry for Python package management
Stars: ✭ 40 (-33.33%)
Mutual labels:  bazel, pip
Rules python
Experimental Bazel Python Rules
Stars: ✭ 233 (+288.33%)
Mutual labels:  bazel, pip
Rules terraform
Bazel rules for using Hashicorp's Terraform in your Bazel builds.
Stars: ✭ 26 (-56.67%)
Mutual labels:  bazel
Rules grafana
Bazel rules for building Grafana dashboards
Stars: ✭ 46 (-23.33%)
Mutual labels:  bazel
Python Pixabay
Python 3 Pixabay's API wrapper.
Stars: ✭ 32 (-46.67%)
Mutual labels:  pip
Mongo schema
Python Package to provide a rough schema for the mongodb collection
Stars: ✭ 8 (-86.67%)
Mutual labels:  pip
Tofu
Project for an open-source python library for synthetic diagnostics and tomography for Fusion devices
Stars: ✭ 35 (-41.67%)
Mutual labels:  pip
Gazel
DEPRECATED: use gazelle
Stars: ✭ 22 (-63.33%)
Mutual labels:  bazel
Proposals
Index of all Bazel proposals and design documents
Stars: ✭ 50 (-16.67%)
Mutual labels:  bazel
Simple Sh Datascience
A collection of Bash scripts and Dockerfiles to install data science Tool, Lib and application
Stars: ✭ 32 (-46.67%)
Mutual labels:  pip
Art
🎨 ASCII art library for Python
Stars: ✭ 1,026 (+1610%)
Mutual labels:  pip
Video To Ascii
It is a simple python package to play videos in the terminal using characters as pixels
Stars: ✭ 960 (+1500%)
Mutual labels:  pip
Rules go
Go rules for Bazel
Stars: ✭ 852 (+1320%)
Mutual labels:  bazel
Bazel Mypy Integration
🐍🌿💚 Integrate MyPy type-checking into your Python Bazel builds
Stars: ✭ 40 (-33.33%)
Mutual labels:  bazel
Serverless Python Requirements
⚡️🐍📦 Serverless plugin to bundle Python packages
Stars: ✭ 838 (+1296.67%)
Mutual labels:  pip
Pip Gui
A GUI based Python Package installer
Stars: ✭ 46 (-23.33%)
Mutual labels:  pip
Django Rest Booking Api
A Restful api which allows you to book sports events or update existing odds.
Stars: ✭ 24 (-60%)
Mutual labels:  pip
Rules codeowners
Bazel rules for generating CODEOWNERS from a workspace.
Stars: ✭ 31 (-48.33%)
Mutual labels:  bazel
Platforms
Constraint values for specifying platforms and toolchains
Stars: ✭ 34 (-43.33%)
Mutual labels:  bazel
Pigar
☕️ A fantastic tool to generate requirements.txt for your Python project, and more than that. (IT IS NOT A PACKAGE MANAGEMENT TOOL)
Stars: ✭ 1,068 (+1680%)
Mutual labels:  pip

🚨 Deprecated

This repository has been merged into bazelbuild/[email protected] and is no longer maintained.

rules_python_external is now the canonical way to manage Python dependencies for rules_python. For instructions on how to use, see https://github.com/bazelbuild/rules_python#using-the-packaging-rules.


rules_python_external

Bazel rules to transitively fetch and install Python dependencies from a requirements.txt file.

Features

The rules address most of the top packaging issues in bazelbuild/rules_python. This means the rules support common packages such as tensorflow and google.cloud natively.

Usage

Prerequisites

The rules support Python >= 3.5 (the oldest maintained release).

Setup WORKSPACE

rules_python_external_version = "{COMMIT_SHA}"

http_archive(
    name = "rules_python_external",
    sha256 = "", # Fill in with correct sha256 of your COMMIT_SHA version
    strip_prefix = "rules_python_external-{version}".format(version = rules_python_external_version),
    url = "https://github.com/dillon-giacoppo/rules_python_external/archive/v{version}.zip".format(version = rules_python_external_version),
)

# Install the rule dependencies
load("@rules_python_external//:repositories.bzl", "rules_python_external_dependencies")
rules_python_external_dependencies()

load("@rules_python_external//:defs.bzl", "pip_install")
pip_install(
    name = "py_deps",
    requirements = "//:requirements.txt",
    # (Optional) You can provide a python interpreter (by path):
    python_interpreter = "/usr/bin/python3.8",
    # (Optional) Alternatively you can provide an in-build python interpreter, that is available as a Bazel target.
    # This overrides `python_interpreter`.
    # Note: You need to set up the interpreter target beforehand (not shown here). Please see the `example` folder for further details.
    #python_interpreter_target = "@python_interpreter//:python_bin",
)

Example BUILD file.

load("@py_deps//:requirements.bzl", "requirement")

py_binary(
    name = "main",
    srcs = ["main.py"],
    deps = [
        requirement("boto3"),
    ],
)

Note that above you do not need to add transitively required packages to deps = [ ... ]

Setup requirements.txt

While rules_python_external does not require a transitively-closed requirements.txt file, it is recommended. But if you want to just have top-level packages listed, that also will work.

Transitively-closed requirements specs are very tedious to produce and maintain manually. To automate the process we recommend pip-compile from jazzband/pip-tools.

For example, pip-compile takes a requirements.in like this:

boto3~=1.9.227
botocore~=1.12.247
click~=7.0

pip-compile 'compiles' it so you get a transitively-closed requirements.txt like this, which should be passed to pip_install below:

boto3==1.9.253
botocore==1.12.253
click==7.0
docutils==0.15.2          # via botocore
jmespath==0.9.4           # via boto3, botocore
python-dateutil==2.8.1    # via botocore
s3transfer==0.2.1         # via boto3
six==1.14.0               # via python-dateutil
urllib3==1.25.8           # via botocore

Demo

You can find a demo in the example/ directory.

Development

Testing

bazel test //...

Adopters

Here's a (non-exhaustive) list of companies that use rules_python_external in production. Don't see yours? You can add it in a PR!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].