Skip to content

Installing dependencies from script #929

Open

Description

I noticed that a lot of the scripts require the user to install a module or more (obviously!).

Instead of having the user install each module required for each script, why not install these modules FROM the script itself?

I have an example of this over at my ArkEngine repository. The code is here:

import sys
import subprocess as sp

def dependencies(pip = str):
        try:
            sp.call(f'{pip} install pygame', shell = True)
            sp.call(f'{pip} install cryptography', shell = True)
        except:
            print('custom error message')
            sys.exit()

In the code snippet above, the required modules for my project are pygame and cryptography. So in each script, you can add the lines dependencies('pip3') (for macOS users) and/or dependences('pip') (for Windows users). Make sure to modify the dependencies() function to include all the modules you need.

There are many variations, you could also have the code check if the user has the dependencies (modules) installed. If they don't, install it for them. macOS requires pip3, it'll say pip is not a valid command, the same way it does for python.

I think installing the dependent modules from the scripts would improve the UX by removing another step for them.

Activity

  1. ghost added
    queryFor asking any kind of question
    on Nov 6, 2022
  2. MalikMlitat commented on Nov 12, 2022

    @MalikMlitat

    hmm, usually you shouldn't change the system without owner's agreement or else you uninstall the modules which you installed after execution

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

Metadata

Metadata

Assignees

Labels

queryFor asking any kind of question

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions