Skip to content

Commit

Permalink
Merge branch 'python_package' of https://github.com/jeff-hykin/fornix
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-hykin committed Feb 13, 2024
2 parents 2e289b0 + 06dd41a commit 6303ca9
Show file tree
Hide file tree
Showing 19 changed files with 1,371 additions and 959 deletions.
3 changes: 2 additions & 1 deletion commands/project/publish
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ rm -rf ./dist
python setup.py sdist bdist_wheel
if [ -d "./dist" ]
then
stty sane 2>/dev/null
twine upload dist/*
fi

Expand All @@ -14,7 +15,7 @@ import toml
#
# get the data out of the toml file
#
toml_info = toml.load("./pyproject.toml")
toml_info = toml.load("../pyproject.toml")
package_info = {**toml_info["tool"]["poetry"], **toml_info["tool"]["extra"]}
print(package_info["version"])
')"
Expand Down
56 changes: 53 additions & 3 deletions commands/start
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,62 @@
#
# summary
#
# find fornix, make sure nix exists
# make sure nix exists
# find fornix
# with no arguments, this simply starts the shell
# with an argument, it refreshes the project connections, then runs `$commands_folder/project/$the_arguments`

# if nix doesnt exist
if [ -z "$(command -v "nix-shell")" ]
then
echo runinng installer_helper
#
# find the settings/extensions/nix/installer_helper
#
path_to_installer_helper=""
file_name="settings/extensions/nix/installer_helper"
folder_to_look_in="$PWD"
while :
do
# check if file exists
if [ -f "$folder_to_look_in/$file_name" ]
then
path_to_installer_helper="$folder_to_look_in/$file_name"
break
else
if [ "$folder_to_look_in" = "/" ]
then
break
else
folder_to_look_in="$(dirname "$folder_to_look_in")"
fi
fi
done
# couldn't find it
if [ -z "$path_to_installer_helper" ]
then
#
# what to do if file never found
#
echo "I'm a script running with a pwd of:$PWD"
echo "I'm looking for $file_name in a parent folder"
echo "I'm exiting now because I wasnt able to find it"
echo "thats all the information I have"
exit
#
# found it
#
else
# if wasnt able to install, then exit
export install_repo="false" # we only need nix
if ! . "$path_to_installer_helper"; then
# the installer will have the instructions/error messages
exit
fi
unset install_repo
fi
fi

#
# find the fornix_core
#
Expand Down Expand Up @@ -198,8 +250,6 @@ then
fi
fi

. "$FORNIX_FOLDER/settings/extensions/nix/commands/ensure_nix_installed"

# just start the shell with no arguments (arguments might be supported in the future)
"$FORNIX_COMMANDS_FOLDER/shell"
if [ "$FORNIX_DEBUG" = "true" ]; then
Expand Down
75 changes: 75 additions & 0 deletions commands/update_dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env sh
"\"",`$(echo --% ' |out-null)" >$null;function :{};function dv{<#${/*'>/dev/null )` 2>/dev/null;dv() { #>
echo "1.27.2"; : --% ' |out-null <#'; }; version="$(dv)"; deno="$HOME/.deno/$version/bin/deno"; if [ -x "$deno" ]; then exec "$deno" run -A "$0" "$@"; elif [ -f "$deno" ]; then chmod +x "$deno" && exec "$deno" run -A "$0" "$@"; fi; bin_dir="$HOME/.deno/$version/bin"; exe="$bin_dir/deno"; has () { command -v "$1" >/dev/null; } ; if ! has unzip; then if ! has apt-get; then has brew && brew install unzip; else if [ "$(whoami)" = "root" ]; then apt-get install unzip -y; elif has sudo; then echo "Can I install unzip for you? (its required for this command to work) ";read ANSWER;echo; if [ "$ANSWER" =~ ^[Yy] ]; then sudo apt-get install unzip -y; fi; elif has doas; then echo "Can I install unzip for you? (its required for this command to work) ";read ANSWER;echo; if [ "$ANSWER" =~ ^[Yy] ]; then doas apt-get install unzip -y; fi; fi; fi; fi; if ! has unzip; then echo ""; echo "So I couldn't find an 'unzip' command"; echo "And I tried to auto install it, but it seems that failed"; echo "(This script needs unzip and either curl or wget)"; echo "Please install the unzip command manually then re-run this script"; exit 1; fi; repo="denoland/deno"; if [ "$OS" = "Windows_NT" ]; then target="x86_64-pc-windows-msvc"; else :; case $(uname -sm) in "Darwin x86_64") target="x86_64-apple-darwin" ;; "Darwin arm64") target="aarch64-apple-darwin" ;; "Linux aarch64") repo="LukeChannings/deno-arm64" target="linux-arm64" ;; "Linux armhf") echo "deno sadly doesn't support 32-bit ARM. Please check your hardware and possibly install a 64-bit operating system." exit 1 ;; *) target="x86_64-unknown-linux-gnu" ;; esac; fi; deno_uri="https://github.com/$repo/releases/download/v$version/deno-$target.zip"; exe="$bin_dir/deno"; if [ ! -d "$bin_dir" ]; then mkdir -p "$bin_dir"; fi; if ! curl --fail --location --progress-bar --output "$exe.zip" "$deno_uri"; then if ! wget --output-document="$exe.zip" "$deno_uri"; then echo "Howdy! I looked for the 'curl' and for 'wget' commands but I didn't see either of them. Please install one of them, otherwise I have no way to install the missing deno version needed to run this code"; exit 1; fi; fi; unzip -d "$bin_dir" -o "$exe.zip"; chmod +x "$exe"; rm "$exe.zip"; exec "$deno" run -A "$0" "$@"; #>}; $DenoInstall = "${HOME}/.deno/$(dv)"; $BinDir = "$DenoInstall/bin"; $DenoExe = "$BinDir/deno.exe"; if (-not(Test-Path -Path "$DenoExe" -PathType Leaf)) { $DenoZip = "$BinDir/deno.zip"; $DenoUri = "https://github.com/denoland/deno/releases/download/v$(dv)/deno-x86_64-pc-windows-msvc.zip"; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; if (!(Test-Path $BinDir)) { New-Item $BinDir -ItemType Directory | Out-Null; }; Function Test-CommandExists { Param ($command); $oldPreference = $ErrorActionPreference; $ErrorActionPreference = "stop"; try {if(Get-Command "$command"){RETURN $true}} Catch {Write-Host "$command does not exist"; RETURN $false}; Finally {$ErrorActionPreference=$oldPreference}; }; if (Test-CommandExists curl) { curl -Lo $DenoZip $DenoUri; } else { curl.exe -Lo $DenoZip $DenoUri; }; if (Test-CommandExists curl) { tar xf $DenoZip -C $BinDir; } else { tar -Lo $DenoZip $DenoUri; }; Remove-Item $DenoZip; $User = [EnvironmentVariableTarget]::User; $Path = [Environment]::GetEnvironmentVariable('Path', $User); if (!(";$Path;".ToLower() -like "*;$BinDir;*".ToLower())) { [Environment]::SetEnvironmentVariable('Path', "$Path;$BinDir", $User); $Env:Path += ";$BinDir"; } }; & "$DenoExe" run -A "$PSCommandPath" @args; Exit $LastExitCode; <#
# */0}`;
// import { FileSystem, glob } from "https://deno.land/x/quickr@0.6.44/main/file_system.js"
import { FileSystem, glob } from "/Users/jeffhykin/repos/quickr/main/file_system.js"
import { returnAsString, run, Stderr, Stdout, Out } from "https://deno.land/x/quickr@0.6.44/main/run.js"
import { recursivelyAllKeysOf, get, set, remove, merge, compareProperty } from "https://deno.land/x/good@1.4.4.0/object.js"
import ProgressBar from "https://deno.land/x/progress@v1.3.8/mod.ts"
import { makeIterable, asyncIteratorToList, concurrentlyTransform } from "https://deno.land/x/good@1.1.1.2/iterable.js"

// go to project root
FileSystem.cwd = await FileSystem.walkUpUntil(".git/")

let depsFolder
let pathInfo = await FileSystem.info(FileSystem.thisFolder+"/__dependencies__")
if (pathInfo.isFolder) {
depsFolder = pathInfo.path
} else {
for await (const each of FileSystem.recursivelyIterateItemsIn('.', { searchOrder: 'breadthFirstSearch'})) {
if (each.path.startsWith(".git")) {
continue
}
if (each.isFolder && each.basename == "__dependencies__") {
depsFolder = each.path
break
}
}
}

const settingsJsonPath = `${FileSystem.parentPath(depsFolder)}/settings.json`
const dependencies = JSON.parse(await FileSystem.read(settingsJsonPath))?.pure_python_packages ?? {}

const statusOutput = await run`git status ${Out(returnAsString)}`
let changesWereStashed = false
if (statusOutput.match(/Changes to be committed:|Changes not staged for commit:|Untracked files:/)) {
await run`git add ${settingsJsonPath} ${Out(null)}`
await run`git commit -m ${"add settings path"} ${Out(null)}`
await run`git add -A`
if (await run`git stash`.success) {
changesWereStashed = true
}
}
try {

const globPath = `${depsFolder}/__sources__/*/.gitrepo`
for (const eachPath of await glob(globPath, { searchOrder: 'breadthFirstSearch'})) {
const folderToPull = FileSystem.parentPath(eachPath)
console.log(`pulling: ${eachPath}`)
const { success } = (await run`git subrepo pull --force ${folderToPull}`)
if (!success) {
break
}
}
for (const [importName, value] of Object.entries(dependencies)) {
const { path, git_url: gitUrl } = value
const repoPath = `${depsFolder}/__sources__/${importName}`
if (gitUrl) {
if (!(await FileSystem.info(repoPath)).exists) {
console.log(`cloning: ${gitUrl}`)
const {success} = await run`git subrepo clone ${gitUrl} ${repoPath}`
if (!success) {
break
}
}
}
}
} finally {
if (changesWereStashed) {
await run`git stash pop`
await run`git add -A`
}
}

// (this comment is part of deno-guillotine, dont remove) #>
7 changes: 6 additions & 1 deletion main/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import setuptools
import toml
from file_system_py import iterate_paths_in

#
# get the data out of the toml file
Expand All @@ -26,7 +27,11 @@
license=package_info["license"],
packages=[package_info["name"]],
# package_data={
# package_info["name"]: ['__dependencies__/**/*'],
# # include all files/folders in the module (recursively)
# package_info["name"]: [
# each[len(package_info["name"])+1:]
# for each in iterate_paths_in(package_info["name"], recursively=True)
# ],
# },
install_requires=[
# examples:
Expand Down
Loading

0 comments on commit 6303ca9

Please sign in to comment.