Asked this before, but what about pytest and its e...
# development
n
Asked this before, but what about pytest and its extra_requirements, and mypy and type stubs, etc. As it stands, it seems
./pants export
won’t give you a complete venv - should there be instructions to add those to global requirements.txt?
h
So you want a venv that includes all the tools, not just the dependencies of your code?
h
Is this because you are importing the tools directly, like
import pytest
? Or some other reason?
n
Yes, in some cases, e.g.
with pytest.raises …
,
@pytest.fixture
, but also for type hinting in the IDE, and to be able to activate a venv in the terminal that has everything we need for the project.
I’ve switched to pycharm recently and found that if I point it to the venv generated by pants, it prompts me to install ’missing packages` for tools, which I have to do if the venv is regenerated, e.g. if we switch versions between branches.
h
What I'm trying to figure out is if https://github.com/pantsbuild/pants/issues/12449 would be sufficient. If the "missing packages" Pycharm complains about are solely due to imports? The effect of #12449 is that certain tools would be / could be included in your user requirements too, while still DRY For example, do you really want us to be installing black in the venv, even though you don't import it? Things become more complicated if so, as the Black tool lockfile needs to be compatible with your own user lockfile(s)
n
For black, I guess I could configure pycharm to run
./pants fmt
to format the files, which might be ok.
mypy might be a little different though as I would want the type stubs in the IDE
h
Oh hm, I love PyCharm but am not a power user. I wonder if it would be helpful to have a venv for each tool? That window you're showing suggests to me we could have something like
dist/virtualenvs/black
. Or do you need a single venv with all user requirements + tools?
h
I use PyCharm extensively and haven't noticed that issue, let me see
And BTW we are working on "proper" IntelliJ support, which should pretty quickly extend to PyCharm support
pytest
at least should be in the venv if it's a code dependency (i.e., if you
import
it)
type stubs not so much
Let me think about how we could make
export
support those