Skip to main content

Lets you import stuff ezier

Project description

importhelper

Imports

  • os
  • threading
  • traceback
  • subprocess
  • sys
  • gc

Requirements

  • pip

Installation

Hopefully...

pip install importhelper

... should work.

Use

Has a class named Mod(modules,src,package) which can almost directly translate to a pip package and the imports/installs to be made from said pip package. Custom urls for packages are not supported. (Only uses official packages from PyPI)

You can import the class by:

from importify import Mod

A Mod object's uses by example:

flaskMod = Mod(modules="jsonify,Flask as flsk",src="flask",package="Flask")
# If 'package' is not provided, it will take 'src's value
# 'src' and 'package' can only be strings
# 'modules' can either be a string with format "<Module> as <Name>,<Module2> as <Name2>,.."
# or can be a list like ["<Module> as <Name>","<Module2> as <Name2>"]
# or can be a dict like {"<Module>":"<Name>","<Module1>":"<Name2>"}
## Yes... I know Name:Module for dict makes more sense but izz too much effort to do that (Only 2 lines but still) =-=

# Imports "Flask" from the "flask" module as "flsk" (Literal execution is "from flask import Flask as flsk" and also "jsonify" from the "flask" module (Literal execution is "from flask import jsonify") if it is installed*
flaskMod.attemptImport()

# Installs package "Flask" if it is not installed*
flaskMod.install()

# Uninstalls package "Flask" if it is installed*
flaskMod.uninstall()

# Returns boolean value 'True' if the package is installed*
flaskMod.isInstalled()

requestsMod
  • The Mod class has a static variable called PIP_FREEZE(Basically saves the information of all currently installed packages). Thus, calling multiple Mod.install() or Mod.uninstall()'s is not recommended because PIP_FREEZE might be corrupted/have bad data. PIP_FREEZE is only refreshed when loading of the importify module and on install/uninstall of a Mod package.

Other features

  • You can manually refresh PIP_FREEZE by Mod.refreshPipFreezeInfo()
  • Mod.getPipFreeze() returns a list of ModVersion s that you can use to determine which packages are installed of which version. You can compare said ModVersion objects with each other. Just check the methods honestly.

Disabling print messages for import, install, uninstall

The Mod class has around 9 static "silencing" boolean variables which, upon enabling, will stop printing their respective msgz. Eg: Mod.SILENCE_UNINSTALL_ERRORS=True # Silence error messages when using Mod.uninstall() They are all False by default (No silencing)

Purpose

This project was built solely for the purpose of providing a way to automate package installations and imports when sending over .py files that require certain imports but they aren't installed i.e., import requests throws an error because you don't have it installed. It also helps when you have incompatibilities and need ways to workaround by uninstalling, installing and uninstalling certain packages in certain orders. (Bad and incompatible package creators.... You are the reason for this eyes intensely)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

importhelper-0.0.5.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

importhelper-0.0.5-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file importhelper-0.0.5.tar.gz.

File metadata

  • Download URL: importhelper-0.0.5.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.1

File hashes

Hashes for importhelper-0.0.5.tar.gz
Algorithm Hash digest
SHA256 199e86d82be59e92bd0b0177244aa536697afad7577934f13e4d0b73aa7aaaa1
MD5 5049e00e87a4fd284f0d6f4ea05e535c
BLAKE2b-256 4aaf4099d0dbec21d187cab85a36eb6641fbf7709ba1122e6f4e91aa572f22c2

See more details on using hashes here.

File details

Details for the file importhelper-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: importhelper-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.1

File hashes

Hashes for importhelper-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 87e4e23d13c6a797cb7226adbd04db81c46ab46030404496c884d2d7f994ac05
MD5 149b6054264c6edb95f61b85510210a3
BLAKE2b-256 ab9beda386b287d6cdb432211b7fe92bf6991e02ddce1a28baa4a8b43068b7a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page