M
Modular7mo ago
Maxim

Poor persons package management in Mojo

This is a blog post which includes a bash script I use to check out modules from Github. https://medium.com/@mzaks/poor-persons-package-management-in-mojo-8671aa6e420a
Medium
Poor persons package management in Mojo
As you might have noticed, if you followed my last few posts, I am currently exploring the new programming language called Mojo.
1 Reply
Moosems / Three chickens
I did something similar a while back where I wrote a shell script that downloads mojopkg files from github repos. Note that it skips the first line of the file so that I could leave a comment in the requirements.txt.
# sh download_dependencies.sh
count=0
# Process the remaining lines
while IFS=', ' read -r owner repo release destination; do
if (( count == 0 )); then
((count++))
continue
fi
# Construct the URL
url="https://github.com/$owner/$repo/releases/download/$release/$repo.mojopkg"

# Update the destination
destination="$destination$repo.mojopkg"

# Download the file using curl
curl -L -o "$destination" "$url"
done < dependencies.txt
# sh download_dependencies.sh
count=0
# Process the remaining lines
while IFS=', ' read -r owner repo release destination; do
if (( count == 0 )); then
((count++))
continue
fi
# Construct the URL
url="https://github.com/$owner/$repo/releases/download/$release/$repo.mojopkg"

# Update the destination
destination="$destination$repo.mojopkg"

# Download the file using curl
curl -L -o "$destination" "$url"
done < dependencies.txt
requirements.txt:
Because Mojo has no package manager, I've implemented a hacky one myself. The order is owner, repository, tag, and path to install in the src tree. (E.G. "Moosems, Mojo-UI, latest-build, ./")
Because Mojo has no package manager, I've implemented a hacky one myself. The order is owner, repository, tag, and path to install in the src tree. (E.G. "Moosems, Mojo-UI, latest-build, ./")
Theres also a powershell script for the few windows users who may ever see it:
# This may or may not work, I've never worked with powershell
$count = 0
# Process the remaining lines
Get-Content -Path "dependencies.txt" | ForEach-Object {
if ($count -eq 0) {
$count++
continue
}

# Split the line into variables
$owner, $repo, $release, $destination = $_ -split ', '

# Construct the URL
$url = "https://github.com/$owner/$repo/releases/download/$release/$repo.mojopkg"

# Update the destination
$destination = "$destination$repo.mojopkg"

# Download the file using Invoke-WebRequest
Invoke-WebRequest -Uri $url -OutFile $destination
}
# This may or may not work, I've never worked with powershell
$count = 0
# Process the remaining lines
Get-Content -Path "dependencies.txt" | ForEach-Object {
if ($count -eq 0) {
$count++
continue
}

# Split the line into variables
$owner, $repo, $release, $destination = $_ -split ', '

# Construct the URL
$url = "https://github.com/$owner/$repo/releases/download/$release/$repo.mojopkg"

# Update the destination
$destination = "$destination$repo.mojopkg"

# Download the file using Invoke-WebRequest
Invoke-WebRequest -Uri $url -OutFile $destination
}
It also only deals with .mojopkg files instead of just downloading the repo
Want results from more Discord servers?
Add your server