Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
yuaanlin committed Nov 21, 2023
2 parents 22bb47d + c6a2ab6 commit 593554c
Show file tree
Hide file tree
Showing 12 changed files with 559 additions and 180 deletions.
136 changes: 116 additions & 20 deletions internal/python/__snapshots__/plan_test.snap
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@

[TestDetermineInstallCmd_Snapshot/pipenv-with-wsgi - 1]
RUN pip install pipenv
COPY Pipfile* Pipfile.lock* .
RUN pipenv install gunicorn
COPY Pipfile* .
RUN pipenv install
---

[TestDetermineInstallCmd_Snapshot/poetry-with-wsgi - 1]
RUN pip install poetry
COPY pyproject.toml* poetry.lock* .
RUN poetry add gunicorn
COPY poetry.lock* pyproject.toml* .
RUN poetry install
---

[TestDetermineInstallCmd_Snapshot/poetry-none - 1]
RUN pip install poetry
COPY poetry.lock* pyproject.toml* .
COPY pyproject.toml* poetry.lock* .
RUN poetry install
---

[TestDetermineInstallCmd_Snapshot/pipenv-none - 1]
RUN pip install pipenv
COPY Pipfile* .
COPY Pipfile* Pipfile.lock* .
RUN pipenv install
---

[TestDetermineInstallCmd_Snapshot/pip-with-wsgi - 1]
RUN pip install gunicorn
COPY requirements.txt* .
RUN pip install gunicorn
RUN pip install -r requirements.txt
---

Expand All @@ -37,22 +37,22 @@ RUN pip install -r requirements.txt
---

[TestDetermineInstallCmd_Snapshot/pip-with-fastapi - 1]
RUN pip install uvicorn
COPY requirements.txt* .
RUN pip install uvicorn
RUN pip install -r requirements.txt
---

[TestDetermineInstallCmd_Snapshot/poetry-with-fastapi - 1]
RUN pip install poetry
COPY pyproject.toml* poetry.lock* .
RUN poetry add uvicorn
COPY poetry.lock* pyproject.toml* .
RUN poetry install
---

[TestDetermineInstallCmd_Snapshot/pipenv-with-fastapi - 1]
RUN pip install pipenv
COPY Pipfile* Pipfile.lock* .
RUN pipenv install uvicorn
COPY Pipfile* .
RUN pipenv install
---

Expand Down Expand Up @@ -134,27 +134,27 @@ poetry run gunicorn --bind :8080 wsgi.py

[TestDetermineInstallCmd_Snapshot/poetry-with-static-nginx-django - 1]
RUN pip install poetry
COPY pyproject.toml* poetry.lock* .
RUN poetry add gunicorn
COPY poetry.lock* pyproject.toml* .
RUN poetry install
---

[TestDetermineInstallCmd_Snapshot/poetry-with-static-nginx - 1]
RUN pip install poetry
COPY pyproject.toml* poetry.lock* .
RUN poetry add gunicorn
COPY poetry.lock* pyproject.toml* .
RUN poetry install
---

[TestDetermineInstallCmd_Snapshot/pip-with-static-nginx - 1]
RUN pip install gunicorn
COPY requirements.txt* .
RUN pip install gunicorn
RUN pip install -r requirements.txt
---

[TestDetermineInstallCmd_Snapshot/pip-with-static-django - 1]
RUN pip install gunicorn
COPY requirements.txt* .
RUN pip install gunicorn
RUN pip install -r requirements.txt
---

Expand All @@ -164,8 +164,8 @@ RUN pip install gunicorn

[TestDetermineInstallCmd_Snapshot/poetry-with-static-django - 1]
RUN pip install poetry
COPY pyproject.toml* poetry.lock* .
RUN poetry add gunicorn
COPY poetry.lock* pyproject.toml* .
RUN poetry install
---

Expand All @@ -179,51 +179,147 @@ RUN pip install gunicorn

[TestDetermineInstallCmd_Snapshot/pipenv-with-static-nginx-django - 1]
RUN pip install pipenv
COPY Pipfile* Pipfile.lock* .
RUN pipenv install gunicorn
COPY Pipfile* .
RUN pipenv install
---

[TestDetermineInstallCmd_Snapshot/pipenv-with-static-nginx - 1]
RUN pip install pipenv
COPY Pipfile* Pipfile.lock* .
RUN pipenv install gunicorn
COPY Pipfile* .
RUN pipenv install
---

[TestDetermineInstallCmd_Snapshot/pip-with-static-nginx-django - 1]
RUN pip install gunicorn
COPY requirements.txt* .
RUN pip install gunicorn
RUN pip install -r requirements.txt
---

[TestDetermineInstallCmd_Snapshot/pipenv-with-static-django - 1]
RUN pip install pipenv
COPY Pipfile* Pipfile.lock* .
RUN pipenv install gunicorn
COPY Pipfile* .
RUN pipenv install
---

[TestDetermineInstallCmd_Snapshot/pipenv-with-streamlit-entry - 1]
RUN pip install pipenv
COPY Pipfile* Pipfile.lock* .
RUN pipenv install streamlit
COPY Pipfile* .
RUN pipenv install
---

[TestDetermineInstallCmd_Snapshot/pip-with-streamlit-entry - 1]
RUN pip install streamlit
COPY requirements.txt* .
RUN pip install streamlit
RUN pip install -r requirements.txt
---

[TestDetermineInstallCmd_Snapshot/poetry-with-streamlit-entry - 1]
RUN pip install poetry
COPY pyproject.toml* poetry.lock* .
RUN poetry add streamlit
COPY poetry.lock* pyproject.toml* .
RUN poetry install
---

[TestDetermineInstallCmd_Snapshot/unknown-with-streamlit-entry - 1]
RUN pip install streamlit
---

[TestDetermineInstallCmd_Snapshot/poetry-with-fastapi - 1]
RUN pip install poetry
COPY pyproject.toml* poetry.lock* .
RUN poetry add uvicorn
RUN poetry install
---

[TestDetermineInstallCmd_Snapshot/unknown-with-fastapi - 1]
RUN pip install uvicorn
---

[TestDetermineInstallCmd_Snapshot/pip-with-static-nginx - 1]
COPY requirements.txt* .
RUN pip install gunicorn
RUN pip install -r requirements.txt
---

[TestDetermineInstallCmd_Snapshot/pdm-with-streamlit-entry - 1]
RUN pip install pdm
COPY pyproject.toml* pdm.lock* .
RUN pdm add streamlit
RUN pdm install
---

[TestDetermineInstallCmd_Snapshot/pdm-none - 1]
RUN pip install pdm
COPY pyproject.toml* pdm.lock* .
RUN pdm install
---

[TestDetermineInstallCmd_Snapshot/unknown-with-static-nginx-django - 1]
RUN pip install gunicorn
---

[TestDetermineInstallCmd_Snapshot/pdm-with-static-nginx-django - 1]
RUN pip install pdm
COPY pyproject.toml* pdm.lock* .
RUN pdm add gunicorn
RUN pdm install
---

[TestDetermineInstallCmd_Snapshot/pdm-with-static-django - 1]
RUN pip install pdm
COPY pyproject.toml* pdm.lock* .
RUN pdm add gunicorn
RUN pdm install
---

[TestDetermineInstallCmd_Snapshot/pdm-with-wsgi - 1]
RUN pip install pdm
COPY pyproject.toml* pdm.lock* .
RUN pdm add gunicorn
RUN pdm install
---

[TestDetermineInstallCmd_Snapshot/pdm-with-static-nginx - 1]
RUN pip install pdm
COPY pyproject.toml* pdm.lock* .
RUN pdm add gunicorn
RUN pdm install
---

[TestDetermineInstallCmd_Snapshot/pdm-with-fastapi - 1]
RUN pip install pdm
COPY pyproject.toml* pdm.lock* .
RUN pdm add uvicorn
RUN pdm install
---

[TestDetermineInstallCmd_Snapshot/pipenv-with-fastapi - 1]
RUN pip install pipenv
COPY Pipfile* Pipfile.lock* .
RUN pipenv install uvicorn
RUN pipenv install
---

[TestDetermineInstallCmd_Snapshot/poetry-none - 1]
RUN pip install poetry
COPY pyproject.toml* poetry.lock* .
RUN poetry install
---

[TestDetermineInstallCmd_Snapshot/pdm-with-streamlit-entry - 1]
RUN pip install pdm
COPY pyproject.toml* pdm.lock* .
RUN pdm add streamlit
RUN pdm install
---

[TestDetermineInstallCmd_Snapshot/poetry-with-static-django - 1]
RUN pip install poetry
COPY pyproject.toml* poetry.lock* .
RUN poetry add gunicorn
RUN poetry install
---
91 changes: 91 additions & 0 deletions internal/python/pkgmanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package python

import (
"strings"

"github.com/zeabur/zbpack/pkg/types"
)

func getPmInitCmd(pm types.PythonPackageManager) string {
switch pm {
case types.PythonPackageManagerPipenv:
return "pip install pipenv"
case types.PythonPackageManagerPoetry:
return "pip install poetry"
case types.PythonPackageManagerPdm:
return "pip install pdm"
}

return ""
}

func getPmAddCmd(pm types.PythonPackageManager, deps ...string) string {
if len(deps) == 0 {
return ""
}

switch pm {
case types.PythonPackageManagerPipenv:
return "pipenv install " + strings.Join(deps, " ")
case types.PythonPackageManagerPoetry:
return "poetry add " + strings.Join(deps, " ")
case types.PythonPackageManagerPdm:
return "pdm add " + strings.Join(deps, " ")
}

return "pip install " + strings.Join(deps, " ")
}

func getPmInstallCmd(pm types.PythonPackageManager) string {
switch pm {
case types.PythonPackageManagerPip:
return "pip install -r requirements.txt"
case types.PythonPackageManagerPipenv:
return "pipenv install"
case types.PythonPackageManagerPoetry:
return "poetry install"
case types.PythonPackageManagerPdm:
return "pdm install"
}

return ""
}

func getPmStartCmdPrefix(pm types.PythonPackageManager) string {
switch pm {
case types.PythonPackageManagerPipenv:
return "pipenv run"
case types.PythonPackageManagerPoetry:
return "poetry run"
case types.PythonPackageManagerPdm:
return "pdm run"
}

return ""
}

func getPmDeclarationFile(pm types.PythonPackageManager) string {
switch pm {
case types.PythonPackageManagerPip:
return "requirements.txt"
case types.PythonPackageManagerPipenv:
return "Pipfile"
case types.PythonPackageManagerPoetry, types.PythonPackageManagerPdm:
return "pyproject.toml"
}

return ""
}

func getPmLockFile(pm types.PythonPackageManager) []string {
switch pm {
case types.PythonPackageManagerPipenv:
return []string{"Pipfile.lock"}
case types.PythonPackageManagerPoetry:
return []string{"poetry.lock"}
case types.PythonPackageManagerPdm:
return []string{"pdm.lock"}
}

return nil
}
Loading

0 comments on commit 593554c

Please sign in to comment.