简体   繁体   中英

Building Python packages for a Raspberry Pi using Azure Pipelines

I have set up two pipelines for a Python package. One is for Windows, the other is for Linux. The one for Windows works as expected. However, if I copy the Linux executable to a Raspberry, it won't run. If I double click it, nothing happens and if I execute it using a terminal, I get permission denied. If I build the Python package locally on my Raspberry, everything works as expected.

So basically my question is, do I need to specifically target Linux ARM for my Python app to run on my Raspberry? If so, how can I achieve this? When creating a Pipeline, I can only choose between x86 and x64 architecture:

在此处输入图片说明

Repo can be found here .

This is the pipeline I use for building and publishing:

trigger:
- master

jobs:

- job: 'Raspberry'
  pool:
    name: arm32 # Already tried to use a self-hosted build agent, but didn't get it to work
  variables:
    python.version: '3.7'

  steps:
    - task: UsePythonVersion@0
      inputs:
        versionSpec: '$(python.version)'

    - script: |
        cd AzurePipelinesWithPython
        python -m pip install --upgrade pip
      displayName: 'Install dependencies'

    - script: pip install pyinstaller
      name: 'pyinstaller'

    - script: cd AzurePipelinesWithPython && pyinstaller --onefile --noconfirm --clean test.py
      name: 'build'

    - task: PublishBuildArtifacts@1
      inputs:
        pathtoPublish: './AzurePipelinesWithPython/dist/'
        artifactName: 'AzurePipelinesWithPython-raspi-$(python.version)'

Sorry for not being able to post a Azure DevOps repo, it belongs to our corporate subscription and isn't public.

So basically my question is, do I need to specifically target Linux ARM for my Python app to run on my Raspberry?

No, you don't need to specify it to target ARM for your app. Especially, I think it won't make big effects even if you remove that task. If you're using hosted agent , it contains different python versions by default. And if you use self-hosted agent, you just need to make sure the suitable version is installed in local machine.

However, if I copy the Linux executable to a Raspberry, it won't run. If I double click it, nothing happens and if I execute it using a terminal, I get permission denied.

For the strange behavior you met, I guess it didn't result from Azure Devops side. I searched and found several similar issues like yours, see one , two , three , four .

So I would think that it's more like a common issue in Linux environment, try using terminal to execute that program after using chmod u+x file_name to give the file the permission to run. Also, you can use file xx.exe to check if the exe is generated correctly for Linux if the issue persists. Hope all above gives a correct direction to resolve your issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM