Search code examples
pythonazure-pipelinesgithub-actions

Get Azure Pipelines to install test environment from pyproject.toml instead of requirements_dev.txt


As mentioned in the title, I'm hoping to get Azure Pipelines to be able to install its test environment from pyproject.toml instead of a separate requirements_dev.txt file, as it would help with reducing the number of dependencies lists that I'd have to maintain.

From looking in the .azure-pipelines folder, I was able to find the following script section in the ci.yml file that seems to be responsible for the installation of the test environment:

  - script: |
      set -eux
      pip install --disable-pip-version-check -r "$(Pipeline.Workspace)/src/requirements_dev.txt"
      pip install --no-deps --disable-pip-version-check -e "$(Pipeline.Workspace)/src"
    displayName: Install package

Would replacing /requirements_dev.txt with /pyproject.toml be sufficient to get Azure Pipelines to read from pyproject.toml, or will I have to perform other tweaks in addition to that?

Thanks in advance!


Solution

  • Would replacing /requirements_dev.txt with /pyproject.toml be sufficient to get Azure Pipelines to read from pyproject.toml, or will I have to perform other tweaks in addition to that?

    pip install -r command is not compatible with pyproject.toml files, it only works with requirements.txt files.

    Instead, you can use python -m pip install . (assumes that your pyproject.toml file is located in the root of your repository.) to install the dependency.

    My sample devops yaml based on github repo:

    pool:
      vmImage: ubuntu-latest
    
    
    steps:
    - script: python -m pip install .
      displayName: Install depenency
    
    - script: python -m unittest discover -v -s test
      displayName: Test
    

    enter image description here