action-pipenv icon indicating copy to clipboard operation
action-pipenv copied to clipboard

Supporting Python Image Versions Beyond Latest?

Open markpbaggett opened this issue 5 years ago • 9 comments

Hello,

It looks like 2 days ago the base python3 image was changed to be associated with python3.9 on docker hub. I'm curious if whether it is possible to pass an argument from a Github action yaml to this action rather than forcing Pipfiles that use this action to specify python3.9.

Thanks in advance for any thoughts you have!

markpbaggett avatar Oct 08 '20 14:10 markpbaggett

Hi, Mark! That's a great idea! I'll try to think about some solution! Thanks for your contribution to my project.

VaultVulp avatar Oct 08 '20 18:10 VaultVulp

Hi I've hit this issue too. I want to build using pipenv and a matrix of python 3.7 and python 3.8. Thanks for this project.

gilesknap avatar Nov 18 '20 07:11 gilesknap

Same here. I'll appreciate support for non-latest

amir-smrt avatar Jan 11 '21 11:01 amir-smrt

I spent a bit of time looking for a solution, but without any luck - to provide different versions of python in one action we have to setup interpreter after the initialization of docker container, but this will drastically increase actual execution time of this action. So, right now, I do not have any ideas. I'll look a bit more into this issue later, but if you have any ideas - feel free to share them here.

VaultVulp avatar Apr 02 '21 10:04 VaultVulp

I also ran into this issue today. This time, the python docker image for version 3 changed from 3.10 to 3.11 - which is of course a problem if the Pipfile specifies the version to still be 3.10.

I might be mistaken but the dockerfile already accepts a specific image (and therefore python) version https://github.com/VaultVulp/action-pipenv/blob/3a655e21a5d246a5c6351787aa9ce206c87bd3ad/Dockerfile#L1

I am not familiar with github actions but wouldn't it be possible to pass this also as an option using with: ? E.g. like

      - name: Install dependecies
        uses: VaultVulp/[email protected]
        with:
          command: sync --dev
+         python_version: 3.10

burnedikt avatar Nov 25 '22 13:11 burnedikt

I am not familiar with github actions but wouldn't it be possible to pass this also as an option using with: ? E.g. like

      - name: Install dependecies
        uses: VaultVulp/[email protected]
        with:
          command: sync --dev
+         python_version: 3.10

To answer my own question: it appears there's currently no way to pass that input (python version) to the docker build process as a build arg according to github action's docs. Sad!


I guess the other way around would then be to install pyenv within the docker container which would then automatically take care of installing the python version specified in a Pipfile.

burnedikt avatar Nov 25 '22 13:11 burnedikt

As far as I know, it's impossible to use Dockerfile arguments in Github Actions.

Action's execution is separated in two steps:

  1. Build stage: this is a docker build call that builds Image. At this stage we are could use Dockerifle-arguments, but Actions do not allow us to set arguments at this stage.
  2. Execution stage: this is a docker run call that passes with-arguments into the Image we built earlier.

So right now, as far as, I know the only possible solution is to built and support multiple versions of the same Action, ex: VaultVulp/[email protected], VaultVulp/[email protected], etc.

VaultVulp avatar Nov 25 '22 13:11 VaultVulp

pyenv is a possible solution, but it will significantly incease action's execution time, for it will build and install python interpreter on each run.

VaultVulp avatar Nov 25 '22 13:11 VaultVulp

I see the struggle. In my case that meant to use a more manual approach for pipenv again, which is sad but I guess there's no way around it right now, given the lack of flexibility of github actions in conjunction with docker (obviously, you could rewrite the github action to not use docker and instead install stuff directly on the build machine, but that seems like a bigger change for this project 😉).


For reference and others that face the same issue, this is what I ended up with. Definitely more verbose but works.

- - name: Install dependecies
-   uses: VaultVulp/[email protected]
+ - name: Setup python version
+   uses: actions/setup-python@v2
    with:
-     command: sync --dev # Install all dependencies, including development ones
+     python-version: "3.10"
+ - name: Install pipenv
+   run: pip install --user pipenv
+ - name: Install all dependencies, including development ones
+   run: pipenv sync --dev
  - name: Run tests
-   uses: VaultVulp/[email protected]
-   with:
-     command: run pytest
+   run: pipenv run pytest

burnedikt avatar Nov 25 '22 13:11 burnedikt