dropbox / dbx_build_tools

Dropbox's Bazel rules and tools
Other
209 stars 37 forks source link

how to add third party dependencies #5

Closed zyxue closed 4 years ago

zyxue commented 4 years ago

e.g. if I'd like to add flask in the example from README.md, what should I do, please?

armooo commented 4 years ago

Sorry this is not better documented.

You would want to create a new //pip/flask/BUILD.in file. Most of the contents need to be extracted from the upstream setup.py. So it would look something like this:

dbx_py_pypi_piplib(
    name = "flask",
    pip_version="1.1.1",
    deps = [
        "//pip/werkzeug",
        "//pip/jinja2",
        "//pip/itsdangerous",
        "//pip/click",
    ],
)

And then you would need to repeat this process for all of the deps of flask. Once this is done you can run bzl gen //pip/... to create the BUILD files. And bazel test //pip/... to test that each library can be imported.

zyxue commented 4 years ago

thank you! Is it true that dbx_py_pypi_piplib needs to be done for each module (of a particular version) only once and then used for all repositories in bazel?

armooo commented 4 years ago

It is expected that you are working in a monorepo with a single //pip tree. Within that tree each pip module would be created and only a single version would exist. This is along the lines of google's //third_party which is documented in part of the The One Version Rule.

armooo commented 4 years ago

I am going to close this issue but let reachout if you have any other questions.