Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from go #234

Merged
merged 6 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test-cm4mlops-wheel-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- main
- dev
- mlperf-inference
paths:
- '.github/workflows/test-cm4mlops-wheel-macos.yml'
- 'setup.py'

jobs:
build:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-cm4mlops-wheel-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ on:
- main
- dev
- mlperf-inference
paths:
- '.github/workflows/test-cm4mlops-wheel-ubuntu.yml'
- 'setup.py'

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-20.04]
python-version: ['3.8', '3.11', '3.12']
python-version: ['3.7', '3.8', '3.11', '3.12']
exclude:
- os: ubuntu-latest
python-version: "3.8"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-cm4mlops-wheel-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- main
- dev
- mlperf-inference
paths:
- '.github/workflows/test-cm4mlops-wheel-windows.yml'
- 'setup.py'

jobs:
build:
Expand Down
32 changes: 27 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
import platform
import os

# Try to use importlib.metadata for Python 3.8+
try:
if sys.version_info >= (3, 8):
from importlib.metadata import version, PackageNotFoundError
else:
# Fallback to pkg_resources for Python < 3.8
import pkg_resources
PackageNotFoundError = pkg_resources.DistributionNotFound
except ImportError:
# If importlib.metadata is unavailable, fall back to pkg_resources
import pkg_resources
PackageNotFoundError = pkg_resources.DistributionNotFound



class CustomInstallCommand(install):
def run(self):
self.get_sys_platform()
Expand All @@ -19,6 +34,16 @@ def run(self):
# Call the custom function
return self.custom_function()

def is_package_installed(self, package_name):
try:
if sys.version_info >= (3, 8):
version(package_name) # Tries to get the version of the package
else:
pkg_resources.get_distribution(package_name) # Fallback for < 3.8
return True
except PackageNotFoundError:
return False

def install_system_packages(self):
# List of packages to install via system package manager
packages = []
Expand All @@ -37,11 +62,8 @@ def install_system_packages(self):

if name in sys.modules:
pass #nothing needed
elif (spec := importlib.util.find_spec(name)) is not None:
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
#print(f"{name} has been imported")
elif self.is_package_installed(name):
pass
else:
packages.append("python3-venv")

Expand Down
Loading