I’m trying to set up GitHub actions and keep getti...
# development
n
I’m trying to set up GitHub actions and keep getting this despite trying to set up Python 3.11 for our GHA (github action), any tips?
Copy code
Bootstrapping Pants 2.17.0 using cpython 3.9.16
1
Here is our GitHub action
Copy code
---
name: Pants

on:
   pull_request:
      branches:
         - main

jobs:
   build:
      name: Run Pants on Codebase
      runs-on: ubuntu-latest

      steps:
         - uses: actions/checkout@v4

         - uses: actions/setup-python@v4

         - uses: pantsbuild/actions/init-pants@main
           # This action bootstraps pants and manages 2-3 GHA caches.
           # See: <http://github.com/pantsbuild/actions/tree/main/init-pants/|github.com/pantsbuild/actions/tree/main/init-pants/>
           with:
              gha-cache-key: v0
              named-caches-hash: ${{ hashFiles('python-default.lock') }}
         - name: Lint
           run: |
              pants lint ::
         - name: Check BUILD files
           run: |
              pants tailor --check update-build-files --check ::
         - name: Test
           run: |
              pants test ::
         - name: Package
           run: |
              # We also smoke test that our release process will work
              pants package ::
         - name: Upload pants log
           uses: actions/upload-artifact@v3
           with:
              name: pants-log
              path: .pants.d/pants.log
           if: always() # We want the log even on failures.
and error:
Copy code
Run pants lint ::
  
23:44:07.24 [ERROR] 1 Exception encountered:
Engine traceback:
  in `lint` goal
ProcessExecutionFailure: Process 'Find interpreter for constraints: CPython<4,>=3.7' failed with exit code 102.
stdout:
stderr:
Could not find a compatible interpreter.
No interpreters could be found on the system.
Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
Error: Process completed with exit code 1.
I needed to add
<PATH>
to directory for GHA to search:
Copy code
[python-bootstrap]
search_path = [
  "<PATH>",
  "<PYENV>",
]
h
Pants itself always uses a self-provided 3.9 to run itself. This is an internal implementation detail, unrelated to the interpreter used to run your code
So you can ignore it
We should probably just remove that log line, it causes more confusion than its worth
What are the interpreter_constraints in your pants.toml?
That
ProcessExecutionFailure: Process 'Find interpreter for constraints: CPython<4,>=3.7' failed with exit code 102.
is suspicious, those wide, open-ended ICs are usually not a good idea.
c
We should probably just remove that log line, it causes more confusion than its worth
agree, it made sense to log the Python version when pants needed a pre-installed Python on the system, but with
scie-pants
it’s become superfluous.
n
sorry I'm late here the interpreter_constraints is
Copy code
interpreter_constraints = ["==3.11.*"]
and I got it working yesterday by adding
<PATH>
to the github action
here's my whole yaml if it helps:
Copy code
---
name: Pants

on:
   pull_request:
      branches:
         - main

jobs:
   build:
      name: Run Pants on Codebase
      runs-on: ubuntu-latest

      steps:
         - uses: actions/checkout@v4

         - uses: actions/setup-python@v4

         - uses: pantsbuild/actions/init-pants@main
           # This action bootstraps pants and manages 2-3 GHA caches.
           # See: <http://github.com/pantsbuild/actions/tree/main/init-pants/|github.com/pantsbuild/actions/tree/main/init-pants/>
           with:
              gha-cache-key: v0
              named-caches-hash: ${{ hashFiles('python-default.lock') }}
         - name: Check BUILD files
           run: |
              pants tailor --check update-build-files --check ::
         - name: Lint
           run: |
              pants lint ::
         - name: Test
           run: |
              pants test ::
         - name: Package
           run: |
              # We also smoke test that our release process will work
              pants package ::
         - name: Upload pants log
           uses: actions/upload-artifact@v3
           with:
              name: pants-log
              path: .pants.d/pants.log
           if: always() # We want the log even on failures.
we have a file
.python-version
which is
3.11.5
which is what the GitHub
setup-python
action uses
h
Ah, that
Find interpreter for constraints: CPython<4,>=3.7
is probably because those are default constraints for tools, in this case whichever linters you have turned on