Skip to content

prepend_sys_path does not work with absolute paths on windows #1330

Closed
@mwerezak

Description

@mwerezak

Describe the bug

If you put an absolute path in prepend_sys_path in your alembic.ini on windows (which will happen if you use %(here)s), the path will get split on the ':' character that separates the drive letter.

Expected behavior

Absolute paths to not get broken.

To Reproduce
Use an absolute path in prepend_sys_path like C:/something or %(here)s/something

Then print out sys.path, e.g. for path in sys.path: print(path) you get:

C
\something
C
\path\to\here\something
# Insert code here

Error
ModuleNotFoundError: No module named ...
because env.py can't import my modules.

Versions.

  • OS: Windows 10
  • Python: 3.11.5
  • Alembic: 1.12.0
  • SQLAlchemy: 1.4.49
  • Database: Postgres
  • DBAPI: psycopg2

Additional context

prepend_sys_path = config.get_main_option("prepend_sys_path")
if prepend_sys_path:
sys.path[:0] = list(
_split_on_space_comma_colon.split(prepend_sys_path)
)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions