https://pantsbuild.org/ logo
f

flat-zoo-31952

09/29/2020, 6:25 PM
is there a way to make
./pants dependencies --type=3rdparty
output the value of
[python-repos].indexes.add
as well?
h

hundreds-father-404

09/29/2020, 6:32 PM
Hello! Not currently. Do you mean that you want for some deps to use a particular index, and others to use a different index? To get the value of
[python-repos].indexes
, you can use either
./pants help-advanced python-repos
, which will show you the current value. Or use
./pants help-all
, which will output JSON and you can use something like JQ to parse.
f

flat-zoo-31952

09/29/2020, 6:50 PM
i'm trying to script up creating a virtualenv from the deps so my IDE can understand what's going on šŸ™‚
i think for now i can just hard code the extra index into the script; the goal would to be to migrate those deps into the monorepo anyways, so i don't need to maintain this forever
šŸ‘ 1
h

hundreds-father-404

09/29/2020, 6:52 PM
i’m trying to script up creating a virtualenv from the deps so my IDE can understand what’s going on
Very helpful indeed. See https://www.pantsbuild.org/docs/python-third-party-dependencies#tip-set-up-a-virtual-environment-optional for a starter script
w

witty-crayon-22786

09/29/2020, 7:02 PM
this is the beginning of it with `help-all`:
Copy code
./pants help-all | jq '.scope_to_help_info["python-repos"].advanced | map(select(.config_key=="indexes")) | .[0].value_history'
… although the structure doesn’t seem to render the final value directly, so you’d still need some logic.
šŸ‘ 1
…the whole thing:
Copy code
./pants help-all | jq '.scope_to_help_info["python-repos"].advanced | map(select(.config_key=="indexes")) | .[0].value_history.ranked_values[-1].value'
😬 1
šŸ‘ 1
(maybe… cc @happy-kitchen-89482)
but more generally, we should probably expose venv export for IDE and jupyter purposes.
šŸ‘ 1
h

happy-kitchen-89482

09/29/2020, 8:00 PM
Yep
f

flat-zoo-31952

09/29/2020, 8:28 PM
nice jq, i would have had no idea how to write that šŸ˜„
but more generally, we should probably expose venv export for IDE and jupyter purposes
on this note, is there a good way to export "editable installs" to this venv? i'm trying a BUILD file in the source root and a
python_distribution()
target but there might be a better way
w

witty-crayon-22786

09/29/2020, 9:10 PM
nice jq, i would have had no idea how to write that
i learned yesterday! heh.
h

hundreds-father-404

09/29/2020, 9:17 PM
is there a good way to export ā€œeditable installsā€ to this venv?
You want to create a
.whl
for your code, and then have pip install it via an editable install? What’s the motivation? Generally, for an IDE with creating the venv, I’d think you only want your 3rdparty reqs in it, and then have the IDE treat your first-party code like it normally would, rather than loading it via an editable install
f

flat-zoo-31952

09/29/2020, 9:20 PM
hmm maybe i don't know how to confgure my IDE right then
h

hundreds-father-404

09/29/2020, 9:20 PM
Which IDE are you using?
f

flat-zoo-31952

09/29/2020, 9:21 PM
i'm using vscode, which seems to defer as much as possible to the code environment it's connected to
reading now on the options though
h

hundreds-father-404

09/29/2020, 9:22 PM
Okay cool, and it isn’t understanding your first-party imports, it sounds like? What are your source roots configured to for Pants? For PyCharm, I had to teach it that
src/python
is a source root so that it knows the import
pants.util.strutil
is really from
src/python/pants/util/strutil.py
i guess i've always leaned on virtualenvs + editable installs before to make this work, so i didn't think to look at the IDE settings
šŸ‘ 1
4 Views