https://pantsbuild.org/ logo
#general
Title
# general
b

brave-policeman-49804

04/16/2019, 3:50 PM
Hey, guys. I have a python module, how do I mention in the BUILD file to install all the requirements from requirements.txt
g

gentle-wolf-58752

04/16/2019, 3:54 PM
I think this might help give some guidance there https://www.pantsbuild.org/3rdparty_py.html
b

brave-policeman-49804

04/16/2019, 4:05 PM
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

gentle-wolf-58752

04/16/2019, 4:34 PM
Are the requirements are in a
3rdparty
dir, or in the same dir as the module?
f

faint-holiday-82821

04/16/2019, 5:45 PM
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

happy-kitchen-89482

04/16/2019, 6:46 PM
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

faint-holiday-82821

04/16/2019, 7:10 PM
This is our 3rdparty/python/BUILD:
Copy code
# Change the requirements.txt file to update python requirements.
python_requirements()
b

brave-policeman-49804

04/17/2019, 11:00 AM
got it thanks.
2 Views