mirror of
https://github.com/hanzoai/pack.git
synced 2026-09-30 23:43:13 +00:00
pipfile support
This commit is contained in:
@@ -50,6 +50,8 @@ func (p *PythonProvider) Plan(ctx *generate.GenerateContext) error {
|
||||
p.PlanPoetry(ctx)
|
||||
} else if p.hasPyproject(ctx) && p.hasPdm(ctx) {
|
||||
p.PlanPDM(ctx)
|
||||
} else if p.hasPipfile(ctx) {
|
||||
p.PlanPipenv(ctx)
|
||||
}
|
||||
|
||||
// Install dependencies
|
||||
@@ -129,6 +131,53 @@ func (p *PythonProvider) PlanUv(ctx *generate.GenerateContext) {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PythonProvider) PlanPipenv(ctx *generate.GenerateContext) {
|
||||
install := ctx.NewCommandStep("install")
|
||||
install.AddInput(plan.NewStepInput(p.GetBuilderDeps(ctx).Name()))
|
||||
|
||||
install.AddEnvVars(p.GetPythonEnvVars(ctx))
|
||||
install.AddEnvVars(map[string]string{
|
||||
"PIPENV_CHECK_UPDATE": "false",
|
||||
"PIPENV_VENV_IN_PROJECT": "1",
|
||||
"PIPENV_IGNORE_VIRTUALENVS": "1",
|
||||
})
|
||||
install.Secrets = []string{}
|
||||
install.UseSecretsWithPrefixes([]string{"PYTHON", "PIP"})
|
||||
|
||||
if ctx.App.HasMatch("Pipfile.lock") {
|
||||
install.AddCommands([]plan.Command{
|
||||
plan.NewExecCommand("pipx install pipenv"),
|
||||
plan.NewPathCommand(LOCAL_BIN_PATH),
|
||||
plan.NewCopyCommand("Pipfile"),
|
||||
plan.NewCopyCommand("Pipfile.lock"),
|
||||
plan.NewExecCommand("pipenv install --deploy --ignore-pipfile"),
|
||||
plan.NewPathCommand(VENV_PATH + "/bin"),
|
||||
})
|
||||
} else {
|
||||
install.AddCommands([]plan.Command{
|
||||
plan.NewCopyCommand("Pipfile"),
|
||||
plan.NewExecCommand("pipenv install --skip-lock"),
|
||||
})
|
||||
}
|
||||
|
||||
build := ctx.NewCommandStep("build")
|
||||
build.AddInput(plan.NewStepInput(install.Name()))
|
||||
|
||||
ctx.Deploy.StartCmd = p.GetStartCommand(ctx)
|
||||
maps.Copy(ctx.Deploy.Variables, p.GetPythonEnvVars(ctx))
|
||||
|
||||
ctx.Deploy.Inputs = []plan.Input{
|
||||
plan.NewStepInput(p.GetImageWithRuntimeDeps(ctx).Name()),
|
||||
plan.NewStepInput(ctx.GetMiseStepBuilder().Name(), plan.InputOptions{
|
||||
Include: ctx.GetMiseStepBuilder().GetOutputPaths(),
|
||||
}),
|
||||
plan.NewStepInput(build.Name(), plan.InputOptions{
|
||||
Include: []string{"."},
|
||||
}),
|
||||
plan.NewLocalInput("."),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PythonProvider) PlanPDM(ctx *generate.GenerateContext) {
|
||||
install := ctx.NewCommandStep("install")
|
||||
install.AddInput(plan.NewStepInput(p.GetBuilderDeps(ctx).Name()))
|
||||
@@ -263,7 +312,7 @@ func (p *PythonProvider) GetBuilderDeps(ctx *generate.GenerateContext) *generate
|
||||
plan.NewStepInput(ctx.GetMiseStepBuilder().Name()),
|
||||
}
|
||||
|
||||
aptStep.Packages = []string{"python3-dev"}
|
||||
aptStep.Packages = []string{"python3-dev", "libpq-dev"}
|
||||
|
||||
return aptStep
|
||||
}
|
||||
@@ -368,7 +417,7 @@ func (p *PythonProvider) InstallMisePackages(ctx *generate.GenerateContext, mise
|
||||
miseStep.Version(python, pipfileVersion, "Pipfile")
|
||||
}
|
||||
|
||||
if p.hasPoetry(ctx) || p.hasUv(ctx) || p.hasPdm(ctx) {
|
||||
if p.hasPoetry(ctx) || p.hasUv(ctx) || p.hasPdm(ctx) || p.hasPipfile(ctx) {
|
||||
miseStep.Default("pipx", "latest")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
cowsay = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.13"
|
||||
python_full_version = "3.13.2"
|
||||
Generated
+30
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "f855c7f410b3ae66d683bbb0c5940c1f456eabd69a517647f5b4a63804baa5e3"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_full_version": "3.13.2",
|
||||
"python_version": "3.13"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"cowsay": {
|
||||
"hashes": [
|
||||
"sha256:274b1e6fc1b966d53976333eb90ac94cb07a450a700b455af9fbdf882244b30a"
|
||||
],
|
||||
"index": "pypi",
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==6.1"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import cowsay
|
||||
|
||||
cowsay.cow("Hello, world!")
|
||||
Reference in New Issue
Block a user