Hey, guys. I have a python module, how do I mentio...
# general
b
Hey, guys. I have a python module, how do I mention in the BUILD file to install all the requirements from requirements.txt
g
I think this might help give some guidance there https://www.pantsbuild.org/3rdparty_py.html
b
already tried it but it is not working while I try to run the module.
I wrote
python_requirements(requirements_relpath="requirements.txt")
in the build file
so when I do
./pants run module:task
it will run this task too right?
g
Are the requirements are in a
3rdparty
dir, or in the same dir as the module?
f
Your libraries/bins should end up looking like this:
Copy code
python_library(
  name='starsky_utils',
  dependencies=[
        '3rdparty/python:pypika',
        '3rdparty/python:pytz',
        '3rdparty/python:arrow',
        '3rdparty/python:bravado',
        '3rdparty/python:pandas',
        '3rdparty/python:boto3',
        '3rdparty/python:psycopg2-binary',
        '3rdparty/python:click',
        '3rdparty/python:es-connector',
  ],

  sources=globs('**/*.py'),
)
h
The idiomatic way is to have
3rdparty/python/BUILD
contain just the stanza
python_requirements()
, which is shorthand for "create targets for every requirement listed in the
requirements.txt
in this directory."
Then you declare dependencies on the specific requirements you need as @faint-holiday-82821 showed above
f
This is our 3rdparty/python/BUILD:
Copy code
# Change the requirements.txt file to update python requirements.
python_requirements()
b
got it thanks.