-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
4,687 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
TEMP_DIR=~/tmp | ||
PACKAGE_NAME=gojo | ||
mkdir -p $TEMP_DIR | ||
|
||
echo "[INFO] Building $PACKAGE_NAME package and running benchmarks." | ||
cp -R benchmarks/ $TEMP_DIR | ||
cp -a benchmarks/. $TEMP_DIR | ||
magic run mojo package src/$PACKAGE_NAME -o $TEMP_DIR/$PACKAGE_NAME.mojopkg | ||
|
||
echo "[INFO] Running benchmarks..." | ||
magic run mojo $TEMP_DIR/scanner.mojo | ||
magic run mojo $TEMP_DIR/string_builder.mojo | ||
magic run mojo $TEMP_DIR/buffer.mojo | ||
|
||
echo "[INFO] Cleaning up the benchmarks directory." | ||
rm -R $TEMP_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# The environment to build the package for. Usually "default", but might be "nightly" or others. | ||
ENVRIONMENT="${1-default}" | ||
if [[ "${ENVRIONMENT}" == "--help" ]]; then | ||
echo "Usage: ENVRIONMENT - Argument 1 corresponds with the environment you wish to build the package for." | ||
exit 0 | ||
fi | ||
|
||
magic run template -m "${ENVRIONMENT}" | ||
rattler-build build -r src -c https://conda.modular.com/max -c conda-forge --skip-existing=all | ||
rm src/recipe.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
#!/bin/bash | ||
|
||
CHANNEL=${1-'mojo-community'} | ||
echo "Publishing packages to: $CHANNEL" | ||
|
||
# ignore errors because we want to ignore duplicate packages | ||
for file in $CONDA_BLD_PATH/**/*.conda; do | ||
magic run rattler-build upload prefix -c "mojo-community" "$file" || true | ||
magic run rattler-build upload prefix -c "$CHANNEL" "$file" || true | ||
done | ||
|
||
rm $CONDA_BLD_PATH/**/*.conda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
FILE=${1} | ||
TEMP_DIR=~/tmp | ||
PACKAGE_NAME=gojo | ||
mkdir -p $TEMP_DIR | ||
|
||
echo "[INFO] Building $PACKAGE_NAME package and copying file." | ||
cp -R $FILE $TEMP_DIR | ||
magic run mojo package src/$PACKAGE_NAME -o $TEMP_DIR/$PACKAGE_NAME.mojopkg | ||
|
||
echo "[INFO] Running file..." | ||
readlink -f $TEMP_DIR/*.mojo | xargs -I {} magic run mojo {} | ||
|
||
echo "[INFO] Cleaning up the tmp directory." | ||
rm -R $TEMP_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import tomllib | ||
import argparse | ||
from typing import Any | ||
|
||
|
||
def build_dependency_list(dependencies: dict[str, str]) -> list[str]: | ||
deps: list[str] = [] | ||
for name, version in dependencies.items(): | ||
start = 0 | ||
operator = "==" | ||
if version[0] in {'<', '>'}: | ||
if version[1] != "=": | ||
operator = version[0] | ||
start = 1 | ||
else: | ||
operator = version[:2] | ||
start = 2 | ||
|
||
deps.append(f"- {name} {operator} {version[start:]}") | ||
|
||
return deps | ||
|
||
|
||
def main(): | ||
# Configure the parser to receive the mode argument. | ||
parser = argparse.ArgumentParser(description='Generate a recipe for the project.') | ||
parser.add_argument('-m', | ||
'--mode', | ||
default="default", | ||
help="The environment to generate the recipe for. Defaults to 'default' for the standard vers" | ||
) | ||
args = parser.parse_args() | ||
|
||
# Load the project configuration and recipe template. | ||
config: dict[str, Any] | ||
with open('mojoproject.toml', 'rb') as f: | ||
config = tomllib.load(f) | ||
|
||
recipe: str | ||
with open('src/template.yaml', 'r') as f: | ||
recipe = f.read() | ||
|
||
# Replace the placeholders in the recipe with the project configuration. | ||
recipe = recipe \ | ||
.replace("{{NAME}}", config["project"]["name"]) \ | ||
.replace("{{DESCRIPTION}}", config["project"]["description"]) \ | ||
.replace("{{LICENSE}}", config["project"]["license"]) \ | ||
.replace("{{LICENSE_FILE}}", config["project"]["license-file"]) \ | ||
.replace("{{HOMEPAGE}}", config["project"]["homepage"]) \ | ||
.replace("{{REPOSITORY}}", config["project"]["repository"]) \ | ||
.replace("{{VERSION}}", config["project"]["version"]) | ||
|
||
# Dependencies are the only notable field that changes between environments. | ||
dependencies: dict[str, str] | ||
match args.mode: | ||
case "default": | ||
dependencies = config["dependencies"] | ||
case _: | ||
dependencies = config["feature"][args.mode]["dependencies"] | ||
|
||
deps = build_dependency_list(dependencies) | ||
recipe = recipe.replace("{{DEPENDENCIES}}", "\n".join(deps)) | ||
|
||
# Write the final recipe. | ||
with open('src/recipe.yaml', 'w+') as f: | ||
recipe = f.write(recipe) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
TEMP_DIR=~/tmp | ||
PACKAGE_NAME=gojo | ||
mkdir -p $TEMP_DIR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json | ||
|
||
context: | ||
version: "13.4.2" | ||
|
||
package: | ||
name: {{NAME}} | ||
version: {{VERSION}} | ||
|
||
source: | ||
- path: . | ||
- path: ../{{LICENSE_FILE}} | ||
|
||
build: | ||
script: | ||
- mkdir -p ${PREFIX}/lib/mojo | ||
- magic run mojo package {{NAME}} -o ${PREFIX}/lib/mojo/{{NAME}}.mojopkg | ||
|
||
requirements: | ||
run: | ||
{{DEPENDENCIES}} | ||
|
||
about: | ||
homepage: {{HOMEPAGE}} | ||
license: {{LICENSE}} | ||
license_file: {{LICENSE_FILE}} | ||
summary: {{DESCRIPTION}} | ||
repository: {{REPOSITORY}} |
This file was deleted.
Oops, something went wrong.