Comment out flavor.go (#60)

The code here isn't used at the moment.
This commit is contained in:
Pieter Noordhuis 2022-09-15 09:46:11 +02:00 committed by GitHub
parent f9b66b3536
commit 192a790155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 65 additions and 72 deletions

View File

@ -1,88 +1,81 @@
package project package project
import ( // type Flavor interface {
"context" // // Name returns a tuple of flavor key and readable name
"fmt" // Name() (string, string)
"os"
"os/exec"
)
type Flavor interface { // // Detected returns true on successful metadata checks
// Name returns a tuple of flavor key and readable name // Detected() bool
Name() (string, string)
// Detected returns true on successful metadata checks // // Build triggers packaging subprocesses
Detected() bool // Build(context.Context) error
// // TODO: Init() Questions
// // TODO: Deploy(context.Context) error
// }
// Build triggers packaging subprocesses // var _ Flavor = PythonWheel{}
Build(context.Context) error
// TODO: Init() Questions
// TODO: Deploy(context.Context) error
}
var _ Flavor = PythonWheel{} // type PythonWheel struct{}
type PythonWheel struct{} // func (pw PythonWheel) Name() (string, string) {
// return "wheel", "Python Wheel"
// }
func (pw PythonWheel) Name() (string, string) { // func (pw PythonWheel) Detected() bool {
return "wheel", "Python Wheel" // root, err := findProjectRoot()
} // if err != nil {
// return false
// }
// _, err = os.Stat(fmt.Sprintf("%s/setup.py", root))
// return err == nil
// }
func (pw PythonWheel) Detected() bool { // func (pw PythonWheel) Build(ctx context.Context) error {
root, err := findProjectRoot() // defer toTheRootAndBack()()
if err != nil { // // do subprocesses or https://github.com/go-python/cpy3
return false // // it all depends on complexity and binary size
} // // TODO: detect if there's an .venv here and call setup.py with ENV vars of it
_, err = os.Stat(fmt.Sprintf("%s/setup.py", root)) // // TODO: where.exe python (WIN) / which python (UNIX)
return err == nil // cmd := exec.CommandContext(ctx, "python", "setup.py", "bdist-wheel")
} // err := cmd.Run()
// if err != nil {
// return err
// }
// return nil
// }
func (pw PythonWheel) Build(ctx context.Context) error { // func toTheRootAndBack() func() {
defer toTheRootAndBack()() // wd, _ := os.Getwd()
// do subprocesses or https://github.com/go-python/cpy3 // root, _ := findProjectRoot()
// it all depends on complexity and binary size // os.Chdir(root)
// TODO: detect if there's an .venv here and call setup.py with ENV vars of it // return func() {
// TODO: where.exe python (WIN) / which python (UNIX) // os.Chdir(wd)
cmd := exec.CommandContext(ctx, "python", "setup.py", "bdist-wheel") // }
err := cmd.Run() // }
if err != nil {
return err
}
return nil
}
func toTheRootAndBack() func() { // var _ Flavor = PythonNotebooks{}
wd, _ := os.Getwd()
root, _ := findProjectRoot()
os.Chdir(root)
return func() {
os.Chdir(wd)
}
}
var _ Flavor = PythonNotebooks{} // type PythonNotebooks struct{}
type PythonNotebooks struct{} // func (n PythonNotebooks) Name() (string, string) {
// // or just "notebooks", as we might shuffle in scala?...
// return "python-notebooks", "Python Notebooks"
// }
func (n PythonNotebooks) Name() (string, string) { // func (n PythonNotebooks) Detected() bool {
// or just "notebooks", as we might shuffle in scala?... // // TODO: Steps:
return "python-notebooks", "Python Notebooks" // // - get all filenames
} // // - read first X bytes from random 10 files and check
// // if they're "Databricks Notebook Source"
// return false
// }
func (n PythonNotebooks) Detected() bool { // func (n PythonNotebooks) Build(ctx context.Context) error {
// TODO: Steps: // // TODO: perhaps some linting?..
// - get all filenames // return nil
// - read first X bytes from random 10 files and check // }
// if they're "Databricks Notebook Source"
return false
}
func (n PythonNotebooks) Build(ctx context.Context) error { // func (n PythonNotebooks) Deploy(ctx context.Context) error {
// TODO: perhaps some linting?.. // // TODO: recursively upload notebooks to a given workspace path
return nil // return nil
} // }
func (n PythonNotebooks) Deploy(ctx context.Context) error {
// TODO: recursively upload notebooks to a given workspace path
return nil
}