Should setuptools always be present? Because it do...
# general
Should setuptools always be present? Because it doesn't seem to be. I'm getting some import errors for
which is in
a dep,
does not declare a dep on
(they think its std lib): What are my options for getting pants to include setuptools in this case?
Copy code
✘  ~/p/st2sandbox/st2.git   pants ●  ./pants test st2common/tests/unit/                                                                                                                                                                      1
03:18:02.08 [WARN] Completed: test - st2common/tests/unit/ failed (exit code 2).
============================= test session starts ==============================
platform linux -- Python 3.6.13, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /tmp/process-execution6KNsrk
plugins: cov-2.11.1, icdiff-0.5, benchmark-3.4.1
collected 0 items / 1 error

==================================== ERRORS ====================================
_______ ERROR collecting st2common/tests/unit/ _______
ImportError while importing test module '/tmp/process-execution6KNsrk/st2common/tests/unit/'.
Hint: make sure your test modules/packages have valid Python names.
/usr/lib64/python3.6/importlib/ in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
st2common/tests/unit/ in <module>
    from st2common.middleware.logging import LoggingMiddleware
st2common/st2common/middleware/ in <module>
    from st2common.router import Request, NotFoundException
st2common/st2common/ in <module>
    from flex.core import validate
/home/cognifloyd/.cache/pants/named_caches/pex_root/venvs/short/b40361f1/lib64/python3.6/site-packages/flex/ in <module>
    import pkg_resources
E   ModuleNotFoundError: No module named 'pkg_resources'
=========================== short test summary info ============================
ERROR st2common/tests/unit/
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.32s ===============================

𐄂 st2common/tests/unit/ failed.
So, do I have to add setuptools to
python_library(dependencies = ...)
even though it is a transitive dep?
Create an inlined python_requirement_library, rather than putting it in requirements.txt. Add to its dependencies field the path to setuptools target, eg 3rdparty/python:setuptools
rather than putting it in requirements.txt
It's necessary to remove from requirements.txt so that you don't have two targets referring to the same requirement, which would disable dependency inference for flex because it would be ambiguous which you want to use The script will still do the right thing
Ah. Ok. I'll probably leave a comment in the requirements file. Is it better to put that flex python_requirement_library in the top level BUILD or in the file next to where it is used?
I'd probably say the BUILD where your requirements.txt is that. That way it's more discoverable if other modules start using it in the future