Skip to content

Commit

Permalink
Fix package detect in setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsuresh committed Oct 18, 2024
1 parent df8bd61 commit bf538f9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ def run(self):
return self.custom_function()

def is_package_installed(self, package_name):
if package_name == "venv":
try:
import venv
return True
except ImportError:
return False
try:
if sys.version_info >= (3, 8):
version(package_name) # Tries to get the version of the package
spec = importlib.util.find_spec(package_name))
module = importlib.util.module_from_spec(spec)
sys.modules[package_name] = module
spec.loader.exec_module(module)
else:
pkg_resources.get_distribution(package_name) # Fallback for < 3.8
return True
Expand Down

0 comments on commit bf538f9

Please sign in to comment.