i have pants pytests that call a service that I’ve...
# general
g
i have pants pytests that call a service that I’ve built with pants. I know how to use ipdb in pytest, but I want to use it within the service. pdb works, but when I try to add ipdb to the requirements I get “Could not find a version that satisfies the requirement ipdb” even though i’m in python 3.10 and ipdb should be available. Has pants done something special to prevent users from using ipdb? i know it has to go in via
extra_requirements
to pytest
👍 1
h
Hmm. And you're running with
./pants test --debug
?
g
i’m not in
pants test
at all-- just running an interactive python session that talks to this service built by pants. i don’t remember whether I had the same problem when running pants pytests that talked to the service, but i can’t imagine that would make a difference
h
Ah, so
./pants run ...
?
You mentioned "pytests" above, so I'm not sure what the framing is here
g
sorry for the confusion. i want to use the service from pytest but also from ipython. but the problem is with debugging the service, not with debugging the test. let me try running the service with
./pants run
actually i have tried that earlier for some other reasons, and every time I get this
i get the error when i try calling into the service
my ipython session gives
EOFError: connection closed by peer
command is
./pants run pushdown_service/service.py
. normally I do
./pants package pushdown_service/::
and then
dist/pushdown_service.service.pex
i was using an rpyc
ForkingServer
. @clever-hamburger-59716 suggested
ThreadedServer
and that let me debug! I’m not sure why
h
Huh...
Thanks for the tip @clever-hamburger-59716
g
@happy-kitchen-89482 one more question-- I can debug my service pex with ipdb
ipdb.set_trace()
but normally (outside of pants and this project entirely) i have
PYTHONBREAKPOINT=ipdb.set_trace
in my envrionment and
breakpoint()
automatically gives me ipdb instead of pdb. this isn’t working with my pex and I’m stumped. At the point where I run
ipdb.set_trace()
I print
os.environ["PYTHONBREAKPOINT"]
and it’s
ipdb.set_trace
. let me see if I can make a tiny repro repo
if i set the variable to something bogus like
afs
I don’t get an error, while normally I do
so i am back to the problem in the original post. my pex depends on ipdb, but when I add it to requiremens.txt, I get this error, even though ipdb is definitely on https://pypi.org/simple/ipdb/ with a version suitable for python 3.10
Copy code
stderr:
pid 75041 -> /Users/maheshvashishtha/.cache/pants/named_caches/pex_root/venvs/c9e55cc98846b062ba9676b3c1a5214512602544/07b01ddf09672a6b76d4e76683b2604821a7fda1/bin/python -sE /Users/maheshvashishtha/.cache/pants/named_caches/pex_root/venvs/c9e55cc98846b062ba9676b3c1a5214512602544/07b01ddf09672a6b76d4e76683b2604821a7fda1/pex --disable-pip-version-check --no-python-version-warning --exists-action a --no-input --isolated -q --cache-dir /Users/maheshvashishtha/.cache/pants/named_caches/pex_root/pip_cache --log /private/var/folders/ts/7lr9hnf958b68z7qr4dvtqvh0000gn/T/pants-sandbox-nBWpPv/.tmp/pex-pip-log.9lc3m4zm/pip.log download --dest /Users/maheshvashishtha/.cache/pants/named_caches/pex_root/downloads/resolver_download.w2d38tzk/cp39-cp39-manylinux2014_x86_64 --only-binary :all: fsspec[http] ipdb lz4==4.0.2 modin@ git+<https://github.com/devin-petersohn/modin.git@service/init-prod> rpyc==5.2.3 segment-analytics-python==2.2.1 snowflake-connector-python[pandas]==2.7.11 --platform manylinux2014_x86_64 --implementation cp --python-version 39 --abi cp39 --index-url <https://pypi.org/simple/> --retries 5 --timeout 15 exited with 1 and STDERR:
ERROR: Could not find a version that satisfies the requirement ipdb
ERROR: No matching distribution found for ipdb
ok i found a fix by comparing to a tiny repo that didn’t have the failure. but I don’t understand why it works.
Copy code
pex_binary(
    name="service",
    entry_point="service.py",
    platforms=[
        "current",
        "manylinux2014-x86_64-cp-39-cp39",
    ],
    dependencies=["//:soda#modin", "ponder/redacted:redacted"],
)
when I comment out the platforms, I can get ipdb. when I add them, I can’t find it. @happy-kitchen-89482 what could be the problem?
@clever-hamburger-59716 is this linux platform spec too specific? i doubt every package has a version like that
h
Those platforms will cause Pants to build a pex compatible with both platforms.
ipdb
is only available as an sdist on PyPI, so it can only be built for
manylinux2014-x86_64-cp-39-cp39
on that platform
👍 1
c
Thanks @happy-kitchen-89482 , we didn’t need manylinux2014, we removed that requirement.