Code Monkey home page Code Monkey logo

pythonpackageinstaller's Introduction

PythonPackageInstaller

forthebadge made-with-python GitHub license GitHub release Github all releases GitHub contributors GitHub stars Workflow Status
This script allows for easy installation of a batch of package dependencies given a file or modifying the script. This tool uses pip, which is included locally for ease of inclusion for the tool, and installs from PyPi. PyPi is the database that pip uses to install the packages.

HOW TO USE

  1. When including in a project, provide the pipinstaller folder on the top level of the project. Inlcude all files in the repository pipinstaller folder in the project folder. This ensures that the functions can reach each other. Additionally, make sure to have a resources folder for the pip script and the list of target packages. This can be done easily by simply copying both folders from the repository to the project.

  2. Packages can be specified in four ways:

    • Modifying the list named "targetPackages" in install_Functions.py under pipinstaller

    • Modifying the targetPackages.txt in resources

      • Some packages are not named the same as a module as it is on PyPi. When adding the pair of values to targetPackages or the list, make sure to add it in the form: "moduleName","PyPiName" To find the PyPi name, search for the package online and choose which version of the module you would like the installer to get.
      • It is possible for the installer to get extra command line arguments for the pip install call. The only argument that is present by default is --user. To specify an extra argument, add the argument to the end of the PyPiName wherever it is used. Make sure there is a space between the package name and the arguments.
    • Creating a requirements.txt file in the root of your project, and passing it's path to install when installing

    • Modifying the requirements.txt file in the pipinstaller/resources path

      • Learn more about requirements.txt here
      • To use requirements.txt, specify the package name, then the version retraints. For an example, canvasplus>=1.4.0<2.0.0. This installs the package canvasplus, version greater than or equal to 1.4.0, but smaller than 2.0.0.
      • Semver versioning goes major.minor.patch. Version retraints should be within the same "major" version, as a change in this version is not backwards compatible.
    • Note that the list in the script takes priority over the files. If it is not empty, it will take the packages from there rather than the file.

  3. Import install_packages.py and run the install() procedure. This will run the process to ask the user to install each package.

    • If you have a requirements.txt file that is not in the pipinstaller/resources directory, specify the directory like so
install(pathToRequirements="path_to_requirements")

If the pipinstaller folder is in the same folder as the starter file, this can be done by doing:

import pipinstaller

For simplicity sake, this is also an option

import pipinstaller as pipi

Another option is to just import the install function. To do this, do:

from pipinstaller import install

To see an example, look at the test.py file.

  1. Please take note that to have the packages be available on the same run as when the packages are installed, it is necessary for all import of the packages that are being installed to occur after running the install() procedure. What this means is that no imports apart from the installation can be done prior to calling the procedure.

For example:

from pipinstaller import install  

install()

#...Your Program

or

import pipinstaller as pipi

pipi.install()

#...Your Program

Thank you for using this python package installer.

pythonpackageinstaller's People

Contributors

kertox662 avatar luke-zhang-04 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

luke-zhang-04

pythonpackageinstaller's Issues

String escaping

Line 43 of install_functions.py has

cmd = "py -3 pipinstaller\resources\get-pip.py --user" if sys.platform == 'win32' else "python3 pipinstaller/resources/get-pip.py --user" 

where the \r could cause an escaped string on the windows platform.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.