Skip to content
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

write_pyi.py script using globally installed dependencies #1524

Closed
agriffin-grow opened this issue Aug 28, 2024 · 2 comments
Closed

write_pyi.py script using globally installed dependencies #1524

agriffin-grow opened this issue Aug 28, 2024 · 2 comments

Comments

@agriffin-grow
Copy link
Contributor

Describe the bug
There are two primary issues

  1. The order of imports in write_pyi requires alembic installed globally for some of the imports
  2. Running write_pyi also requires sqlalchemy, black, and zimports installed globally

Expected behavior
As a development script, this should be runnable from within the codebase without hard dependencies on the external system.

To Reproduce
Uninstall global alembic and sqlalchemy packages and run python tools/write_pyi.py

Error
without global alembic

$ python tools/write_pyi.py
Traceback (most recent call last):
  File "/Users/x/code/alembic/tools/write_pyi.py", line 15, in <module>
    from alembic.autogenerate.api import AutogenContext
ModuleNotFoundError: No module named 'alembic'

with alembic installed globally you get

$ python tools/write_pyi.py
Traceback (most recent call last):
  File "/Users/x/code/alembic/tools/write_pyi.py", line 16, in <module>
    from alembic.autogenerate.api import AutogenContext
  File "/Users/x/code/alembic/alembic/__init__.py", line 1, in <module>
    from . import context
  File "/Users/x/code/alembic/alembic/context.py", line 1, in <module>
    from .runtime.environment import EnvironmentContext
  File "/Users/x/code/alembic/alembic/runtime/environment.py", line 23, in <module>
    from .migration import _ProxyTransaction
  File "/Users/x/code/alembic/alembic/runtime/migration.py", line 35, in <module>
    from .. import ddl
  File "/Users/x/code/alembic/alembic/ddl/__init__.py", line 1, in <module>
    from . import mssql
  File "/Users/x/code/alembic/alembic/ddl/mssql.py", line 20, in <module>
    from .base import AddColumn
  File "/Users/x/code/alembic/alembic/ddl/base.py", line 19, in <module>
    from ..util.sqla_compat import _columns_for_constraint  # noqa
  File "/Users/x/code/alembic/alembic/util/__init__.py", line 24, in <module>
    from .pyfiles import coerce_resource_to_filename as coerce_resource_to_filename
  File "/Users/x/code/alembic/alembic/util/pyfiles.py", line 15, in <module>
    from mako import exceptions
ModuleNotFoundError: No module named 'mako'

Additional context

Fix incoming

Have a nice day!

@agriffin-grow agriffin-grow added the requires triage New issue that requires categorization label Aug 28, 2024
@CaselIT
Copy link
Member

CaselIT commented Sep 12, 2024

Hi,

it's an internal tool, so it's not really that polished. I'll take a look at the PR though

@CaselIT CaselIT added test suite and removed requires triage New issue that requires categorization labels Sep 12, 2024
@sqla-tester
Copy link
Collaborator

Aaron Griffin has proposed a fix for this issue in the main branch:

Improve write_pyi usage https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/5586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants