Skip to content

How do I execute a script at installation time to configure environment variables? #3164

Answered by abravalheri
zh601095001 asked this question in Q&A
Discussion options

You must be logged in to vote

The "executing arbitrary scripts at install time" use case is not supported by the combination of setuptools+pip.

You might have some luck if you package your project in a OS-specific way (e.g. deb, rpm, nix, etc...).

Otherwise you can try to:

  • create a command to be explicitly run by the users (e.g. mypackage ensureenv),
    (this approach is adopted by pipx)
  • ask the users to include a custom command in their .bashrc/.zshrc/...
    e.g. source "$(mypackage init --bashrc)" or eval "$(mypackage init --bashrc)",
    (this approach is adopted by pyenv)
  • ask your users to use a bash installation script
    (pyenv also offer this approach as an alternative)

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@abravalheri
Comment options

@zh601095001
Comment options

Answer selected by abravalheri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants