Skip to content

use of scripts in setup.py causes errors with virtualenvs #227

Description

@cs01

When running mssql-cli from within an activated virtualenv, everything is fine because the virtual env's python is the first match on the PATH. However, when invoking mssql-cli from myvenv/bin/mssql-cli while the virtual environment is not activated, we get

> myvenv/bin/mssql-cli
/usr/bin/python: Error while finding module specification for 'mssqlcli.main' (ModuleNotFoundError: No module named 'mssqlcli')

as noted in pypa/pipx#12.

This is because the script mssql-cli is custom made and hardcoded to invoke a new bash shell, ignoring any virtual environment.

There are a few solutions. The first is easiest and most common.

  1. Use the standard entry_points entry instead of scripts
    entry_points = {"console_scripts": [
        "mssql-cli.bat = mssqlcli.main:main",
        "mssql-cli = mssqlcli.main:main"
        ]},
  1. Leave as a script, but use python instead of bash; make the interpreter /usr/bin/env python instead of bash, similar to how awscli does it: https://github.com/aws/aws-cli/blob/develop/bin/aws
  2. In the script mssql-cli test if there is an activate script present, and if so, run source activate before running python -m mssqlcli.main "$@". This is hacky and I would not go this route.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions