spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.22k stars 1.59k forks source link

Poetry shell debug #20756

Open marianux opened 1 year ago

marianux commented 1 year ago

Description

What steps will reproduce the problem?

When I try to put a breakpoint inside a module being developed under the virtual env of "poetry shell" command, the debugger allows to step-in or step-over, recognizing the paths and functions within the module, but not allowing to catch breakpoints. The curious thing is that outside the virtual environment of "poetry shell", the debugger works fine as expected.

Versions

Dependencies

# Mandatory:
atomicwrites >=1.2.0          :  1.4.1 (OK)
chardet >=2.0.0               :  5.1.0 (OK)
cloudpickle >=0.5.0           :  2.2.1 (OK)
cookiecutter >=1.6.0          :  2.1.1 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.31.1;<9.0.0       :  7.34.0 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.2 (OK)
jellyfish >=0.7               :  0.9.0 (OK)
jsonschema >=3.2.0            :  4.17.3 (OK)
keyring >=17.0.0              :  23.13.1 (OK)
nbconvert >=4.0               :  7.2.9 (OK)
numpydoc >=0.6.0              :  1.5.0 (OK)
parso >=0.7.0;<0.9.0          :  0.8.3 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.9.4 (OK)
pygments >=2.0                :  2.14.0 (OK)
pylint >=2.5.0;<3.0           :  2.16.3 (OK)
pylint_venv >=2.1.1           :  3.0.1 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.7.1;<1.8.0          :  1.7.1 (OK)
pylsp_black >=1.2.0           :  1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0     :  3.0.3 (OK)
qstylizer >=0.2.2             :  0.2.2 (OK)
qtawesome >=1.2.1             :  1.2.2 (OK)
qtconsole >=5.4.0;<5.5.0      :  5.4.0 (OK)
qtpy >=2.1.0                  :  2.3.0 (OK)
rtree >=0.9.7                 :  1.0.1 (OK)
setuptools >=49.6.0           :  67.4.0 (OK)
sphinx >=0.6.6                :  5.3.0 (OK)
spyder_kernels >=2.4.2;<2.5.0 :  2.4.2 (OK)
textdistance >=4.2.0          :  4.5.0 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.3.1 (OK)
xdg >=0.26                    :  0.28 (OK)
zmq >=22.1.0                  :  25.0.0 (OK)

# Optional:
cython >=0.21                 :  None (NOK)
matplotlib >=3.0.0            :  3.7.0 (OK)
numpy >=1.7                   :  1.24.2 (OK)
pandas >=1.1.1                :  None (NOK)
scipy >=0.17.0                :  1.10.1 (OK)
sympy >=0.7.3                 :  1.11.1 (OK)

Environment

Environment ``` Package Version Editable project location ----------------------------- --------- ------------------------------------------------ alabaster 0.7.13 anyio 3.6.2 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 arrow 1.2.3 astroid 2.14.2 asttokens 2.2.1 atomicwrites 1.4.1 attrs 22.2.0 autopep8 1.6.0 Babel 2.12.1 backcall 0.2.0 beautifulsoup4 4.11.2 binaryornot 0.4.4 black 23.1.0 bleach 6.0.0 certifi 2022.12.7 cffi 1.15.1 chardet 5.1.0 charset-normalizer 3.0.1 click 8.1.3 cloudpickle 2.2.1 comm 0.1.2 contourpy 1.0.7 cookiecutter 2.1.1 coverage 7.2.1 cryptography 39.0.2 cycler 0.11.0 debugpy 1.6.6 decorator 5.1.1 defusedxml 0.7.1 diff-match-patch 20200713 dill 0.3.6 docstring-to-markdown 0.11 docutils 0.18.1 entrypoints 0.4 exceptiongroup 1.1.0 executing 1.2.0 fastjsonschema 2.16.3 flake8 5.0.4 fonttools 4.38.0 fqdn 1.5.1 greenlet 2.0.2 idna 3.4 imagesize 1.4.1 importlib-metadata 6.0.0 inflection 0.5.1 iniconfig 2.0.0 intervaltree 3.1.0 ipykernel 6.21.2 ipython 7.34.0 ipython-genutils 0.2.0 ipywidgets 8.0.4 isoduration 20.11.0 isort 5.12.0 jaraco.classes 3.2.3 jedi 0.18.2 jeepney 0.8.0 jellyfish 0.9.0 Jinja2 3.1.2 jinja2-time 0.2.0 jsonpointer 2.3 jsonschema 4.17.3 jupyter 1.0.0 jupyter-cache 0.5.0 jupyter_client 7.4.9 jupyter-console 6.6.3 jupyter_core 5.2.0 jupyter-events 0.6.3 jupyter_server 2.3.0 jupyter_server_terminals 0.4.4 jupyterlab-pygments 0.2.2 jupyterlab-widgets 3.0.5 keyring 23.13.1 kiwisolver 1.4.4 lazy-object-proxy 1.9.0 Markdown 3.4.1 markdown-it-py 2.2.0 MarkupSafe 2.1.2 matplotlib 3.7.0 matplotlib-inline 0.1.6 mccabe 0.7.0 mdit-py-plugins 0.3.5 mdurl 0.1.2 mistune 2.0.5 more-itertools 9.1.0 mplcursors 0.5.2 mpmath 1.2.1 mypy-extensions 1.0.0 myst-nb 0.17.1 myst-parser 0.18.1 nbclassic 0.5.2 nbclient 0.5.13 nbconvert 7.2.9 nbformat 5.7.3 nest-asyncio 1.5.6 notebook 6.5.2 notebook_shim 0.2.2 numexpr 2.8.4 numpy 1.24.2 numpydoc 1.5.0 packaging 23.0 pandocfilters 1.5.0 parso 0.8.3 pathspec 0.11.0 pexpect 4.8.0 pickleshare 0.7.5 Pillow 9.4.0 pip 23.0.1 platformdirs 3.0.0 pluggy 1.0.0 pockets 0.9.1 prometheus-client 0.16.0 prompt-toolkit 3.0.38 psutil 5.9.4 ptyprocess 0.7.0 pure-eval 0.2.2 pycodestyle 2.9.1 pycparser 2.21 pydocstyle 6.2.3 pyfda 0.7.1 pyflakes 2.5.0 Pygments 2.14.0 pylint 2.16.3 pylint-venv 3.0.1 pyls-spyder 0.4.0 pyparsing 3.0.9 PyQt5 5.15.9 PyQt5-Qt5 5.15.2 PyQt5-sip 12.11.1 PyQtWebEngine 5.15.6 PyQtWebEngine-Qt5 5.15.2 pyrsistent 0.19.3 pytc2 0.0.1 /home/mariano/mariano/Docencia/TC2/scripts/pytc2 pytest 7.2.2 pytest-cov 4.0.0 python-dateutil 2.8.2 python-json-logger 2.0.7 python-lsp-black 1.2.1 python-lsp-jsonrpc 1.0.0 python-lsp-server 1.7.1 python-slugify 8.0.1 pytoolconfig 1.2.5 pyxdg 0.28 PyYAML 6.0 pyzmq 25.0.0 QDarkStyle 3.0.3 qstylizer 0.2.2 QtAwesome 1.2.2 qtconsole 5.4.0 QtPy 2.3.0 requests 2.28.2 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rope 1.7.0 Rtree 1.0.1 schemdraw 0.15 scipy 1.10.1 SecretStorage 3.3.3 Send2Trash 1.8.0 setuptools 67.4.0 simplegeneric 0.8.1 six 1.16.0 sniffio 1.3.0 snowballstemmer 2.2.0 sortedcontainers 2.4.0 soupsieve 2.4 Sphinx 5.3.0 sphinx-autoapi 2.0.1 sphinx-rtd-theme 1.2.0 sphinxcontrib-applehelp 1.0.4 sphinxcontrib-devhelp 1.0.2 sphinxcontrib-htmlhelp 2.0.1 sphinxcontrib-jquery 2.0.0 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-napoleon 0.7 sphinxcontrib-qthelp 1.0.3 sphinxcontrib-serializinghtml 1.1.5 spyder 5.4.2 spyder-kernels 2.4.2 SQLAlchemy 1.4.46 stack-data 0.6.2 sympy 1.11.1 tabulate 0.9.0 terminado 0.17.1 text-unidecode 1.3 textdistance 4.5.0 three-merge 0.1.1 tinycss2 1.2.1 toml 0.10.2 tomli 2.0.1 tomlkit 0.11.6 tornado 6.2 traitlets 5.9.0 typing_extensions 4.5.0 ujson 5.7.0 Unidecode 1.3.6 uri-template 1.2.0 urllib3 1.26.14 watchdog 2.3.1 wcwidth 0.2.6 webcolors 1.12 webencodings 0.5.1 websocket-client 1.5.1 whatthepatch 1.0.4 wheel 0.38.4 widgetsnbextension 4.0.5 wrapt 1.15.0 wurlitzer 3.0.3 yapf 0.32.0 zipp 3.15.0 ```
marianux commented 1 year ago

This is the module being developed under the virtual environment:

pytc2 0.0.1 /home/mariano/mariano/Docencia/TC2/scripts/pytc2

ccordoba12 commented 1 year ago

Hey @marianux, thanks for reporting. Could you describe a series of steps on how to create a virtualenv with poetry shell? (I've never used poetry before).

Also, please upload the code you're developing somewhere, or a simple example that generates your problem, so we can try to reproduce it on our side. Thanks!

marianux commented 1 year ago

Thanks Carlos, here are some steps, let me know if something fails, since this is under development right now

  git clone https://github.com/marianux/pytc2.git

  # go to src module folder
  cd pytc2

  #install poetry
  pip install poetry

  # should create the dev environment, install several dependencies
  poetry install

  # activates de development virtual environment
  poetry shell

  # check that you should have the exact environment that I reported
   pip list

  # launch spyder in this environment
  spyder &

with this example ....

########## start of example

  #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  """
  @author: mariano
  """

  import numpy as np
  import matplotlib.pyplot as plt
  import scipy.signal as sig

  from pytc2.sistemas_lineales import analyze_sys, pretty_print_lti, tf2sos_analog, pretty_print_SOS

  num = np.array([1, 0, 2.5, 0, 0.5625, 0])
  den = np.array([1, 0.390, 3.067 , 0.785, 3.056, 0.387, 0.989])

  pretty_print_lti(num, den)

  # find maximum in transfer function
  thisFilter = sig.TransferFunction(num, den)

  # analyze_sys( thisFilter, 'Ej 5.13' )

  _, mag, _ = thisFilter.bode(np.logspace(-1,1,1000))

  # bode in dB
  k0db = np.max(mag)

  # k0 deseada en el ejemplo en dB
  k0_deseada = 10 

  # factor de corrección de ganancia
  k_corr = 10**((k0_deseada - k0db)/20)

  num = k_corr * num

  print('\n\n')
  print('----------------------')
  print('Transferencia original')
  print('----------------------')
  pretty_print_lti(num, den)

  # particiono en SOS's para la implementación
  sos_pb = tf2sos_analog(num, den)

  # ajusto posibles problemas numericos (negativos y valores despreciables)
  # asumimos siempre transferencias normalizadas.
  sos_pb[sos_pb < 1e-6] = 0.0

  # parametrizada
  pretty_print_SOS(sos_pb)

  # parametrizada
  pretty_print_SOS(sos_pb, mode='omegayq')

  plt.close('all')

  # analyze_sys( sig.TransferFunction(num, den) )
  analyze_sys( sos_pb )

########## end of example

I try to put a breakpoint at line 44:

sos_pb = tf2sos_analog(num, den)

and debuger works great. I press CTRL+F11 and step into tf2sos_analog.

The problem is if I put a breakpoint inside that function, it never stops there.

BTW, the same, outside the poetry shell environment works as expected. No doubts that the poetry shell is disturbing some aspect of the debugger ... any clue?

THanks Carlos.