-
Notifications
You must be signed in to change notification settings - Fork 562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typing information installed to the wrong location #925
Comments
Rats, looks like |
I did some investigation to figure out the right way to do it, but it seems that package_data wants .py files not C extensions. Outside my setuptools knowledge, unfortunately. |
Actually, on further investigation, it looks like the I agree the comment in setup.py (line 94, near "data_files") is incorrect though, and should be updated at some point. So, just to be clear, @kadler, are you having a specific issue with the location of pyodbc.pyi? If so, what would that be? |
For a venv it is a bit odd, but it works I guess. The problem is more important if you're not installing in to a venv, though, since it gets installed in to the Python installation prefix ( |
I agree the current approach is not ideal, but I'm struggling to come up with something better. Unfortunately, Python packaging is still not great, even on version 3.9. Including random files in non-package distributions just isn't well supported at the moment. One potential approach might be to add specific package info to 'packages': ['pyodbc'],
'package_dir': {'pyodbc': 'src'},
'package_data': {'pyodbc': ['src/pyodbc.pyi']},
'include_package_data': True, This does appear to add the The fallback solution is not to package pyodbc.pyi in the distribution at all. Instead, add it to typeshed, but I was kinda hoping to keep it in-house for ease of maintenance. |
Just fyi, this is where pip has installed pyodbc.pyi in my docker container - in Thanks for having worked on this @keitherskine - it's valuable work. I hope this data point is useful.
|
FWIW, with how the stubs file is currently installed directly into I found this usage issue along the way to filing PR 979. |
For anyone looking for a workaround here (sorry, I can't help the library authors), adding the install location as an extra python path to the VSCode settings resolves the problem for me. For example, mine was installed in the root of my virtual environment (installed in ./.venv), and adding this to my settings.json file, then reloading the IDE resolves the import for me:
If you installed without a virtual environment I'm pretty certain that using the absolute path to the installation would work as well. I used @jpz 's command from above to locate mine. |
Not sure if it's linked, but here is a stackoverflow post that might be linked. |
From what I remember, setuptools can do this correctly using I've started a discussion over in the setuptools group to see if they have any suggestions: pypa/setuptools#3563 One simple hack to fix this would be to create a Python shim for the C extension, eg. src/pyodbc.py
Not sure how well that change would be received, however. |
Fixed with #1146 . |
Please first make sure you have looked at:
Environment
To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:
Issue
Python type stubs added in #864 are installed to the incorrect location:
pyodbc.pyi should be installed along pyodbc.so in site-packages, but is installed in the base of the venv/prefix.
The text was updated successfully, but these errors were encountered: