Skip to content

support finding packages installed into Debian dist-packages directories #1323

@Hyask

Description

@Hyask

Summary

Reproducer is quite simple:

root@ubuntu-noble:~/test# cat - >test.py <<EOD
import apt

print(apt.apt_pkg.version_compare("1.2.3", "1.2.4"))
print(apt.apt_pkg.version_compare("1.2.4", "1.2.3"))
EOD
root@ubuntu-noble:~/test# python3 test.py
-1
1
root@ubuntu-noble:~/test# ty check test.py
WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
Checking ------------------------------------------------------------ 1/1 fileserror[unresolved-import]: Cannot resolve imported module `apt`
 --> test.py:1:8
  |
1 | import apt
  |        ^^^
2 |
3 | print(apt.apt_pkg.version_compare("1.2.3", "1.2.4"))
  |
info: Searched in the following paths during module resolution:
info:   1. /root/test (first-party code)
info:   2. vendored://stdlib (stdlib typeshed stubs vendored by ty)
info: make sure your Python environment is properly configured: https://docs.astral.sh/ty/modules/#python-environment
info: rule `unresolved-import` is enabled by default

Found 1 diagnostic
root@ubuntu-noble:~/test#

Some packages (like apt) are usually best installed from the system, when writing system tools, so having a pyproject.toml file isn't really a viable option.
Just for the sake of it, I've tried adding a simple one with no dependencies specified, but as expected, it doesn't change the behavior.

Version

ty 0.0.1-alpha.21 (01fca55 2025-10-07)

Metadata

Metadata

Assignees

No one assigned

    Labels

    importsModule resolution, site-packages discovery, import-related diagnostics

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions