{"id":18952698,"url":"https://github.com/compwa/update-pip-constraints","last_synced_at":"2026-03-19T07:19:17.092Z","repository":{"id":65155211,"uuid":"426548923","full_name":"ComPWA/update-pip-constraints","owner":"ComPWA","description":"Create and update pip constraints files for each supported version of Python","archived":false,"fork":false,"pushed_at":"2024-03-13T09:04:43.000Z","size":52,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-01-01T02:41:42.137Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ComPWA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-10T08:50:29.000Z","updated_at":"2024-01-13T17:13:13.000Z","dependencies_parsed_at":"2024-01-13T19:12:12.399Z","dependency_job_id":"1d23e095-3f24-4e46-8718-cca6fa5c081b","html_url":"https://github.com/ComPWA/update-pip-constraints","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.16666666666666663","last_synced_commit":"13e61e0f0d94a7e4430b9464a03ca64295190ef1"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPWA%2Fupdate-pip-constraints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPWA%2Fupdate-pip-constraints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPWA%2Fupdate-pip-constraints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPWA%2Fupdate-pip-constraints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ComPWA","download_url":"https://codeload.github.com/ComPWA/update-pip-constraints/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239952598,"owners_count":19723922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T13:34:21.491Z","updated_at":"2026-03-19T07:19:17.040Z","avatar_url":"https://github.com/ComPWA.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Update pip constraint files\n\n[![BSD 3-Clause license](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n[![GitPod](https://img.shields.io/badge/gitpod-open-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ComPWA/update-pip-constraints)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ComPWA/update-pip-constraints/main.svg)](https://results.pre-commit.ci/latest/github/ComPWA/update-pip-constraints/main)\n[![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\nThis Python package is a wrapper around\n[`pip-tools`](https://github.com/jazzband/pip-tools). It helps updating a\ncollection of\n[PyPI constraints files](https://pip.pypa.io/en/stable/user_guide/#constraints-files)\nfor your repository. One constraint file is created for each Python version\nthat your package supports (see\n[here](https://github.com/jazzband/pip-tools#cross-environment-usage-of-requirementsinrequirementstxt-and-pip-compile)\nwhy this is important). The file structure is as follows:\n\n```text\n.constraints/\n├── py3.6.txt\n├── py3.7.txt\n└── ...\n```\n\nConstraint files allow you to pin your package requirements as follows:\n\n```shell\npython3 -m pip install -c .constraints/py3.7.txt -e .[dev]\n```\n\nThis is just an example where you install your package in\n[editable mode](https://packaging.python.org/guides/distributing-packages-using-setuptools/#working-in-development-mode)\n(`-e` flag) on Python 3.7, where we also installed\n[optional dependencies](https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies)\ndefined under an `extras_require` section called `[dev]`.\n\n## Why ship your repository with constraint files?\n\n- Constraint files\n  [reduce the resolution time](https://pip.pypa.io/en/latest/topics/dependency-resolution/#use-constraint-files-or-lockfiles)\n  of the PyPI dependency resolver.\n- Constraint files make the developer environment reproducible _for each\n  commit_ and _for each supported version of Python_.\n- Constraint files provide a way out of\n  [dependency hell](https://en.wikipedia.org/wiki/Dependency_hell).\n\n## Usage\n\n### Python package\n\nThis Package can be installed with [`pip`](https://pypi.org/project/pip) from\nGitHub:\n\n```shell\npython3 -m pip install git+https://github.com/ComPWA/update-pip-constraints@main\n```\n\nNow, if you run the command:\n\n```shell\nupdate-pip-constraints\n```\n\nan updated constraint file will be created for your version of Python under\n`.constraints/py3.x.txt`.\n\n### GitHub Action\n\nHere are two examples of how to use `update-pip-constraints` as a\n[GitHub Action](https://github.com/features/actions):\n\n\u003cdetails\u003e\n\u003csummary\u003e\nUpdate constraints files during a PR by pushing if there are dependency changes\n\u003c/summary\u003e\n\n```yaml\nname: Requirements (PR)\n\non:\n  pull_request:\n    branches: [main]\n\njobs:\n  pip-constraints:\n    name: Update pip constraints files\n    runs-on: ubuntu-22.04\n    strategy:\n      fail-fast: false\n      matrix:\n        python-version:\n          - \"3.7\"\n          - \"3.8\"\n          - \"3.9\"\n    steps:\n      - uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n      - name: Check if there are dependency changes\n        run: git diff origin/main --exit-code -- .constraints setup.cfg\n        continue-on-error: true\n      - name: Update pip constraints files\n        if: success()\n        uses: ComPWA/update-pip-constraints@main\n        with:\n          python-version: ${{ matrix.python-version }}\n\n  push:\n    name: Push changes\n    if: github.event.pull_request.head.repo.full_name == github.repository\n    runs-on: ubuntu-22.04\n    needs:\n      - pip-constraints\n    steps:\n      - uses: actions/checkout@v4\n        with:\n          token: ${{ secrets.PAT }}\n      - uses: actions/download-artifact@v2\n      - run: rm -rf .constraints/\n      - run: mv artifact .constraints\n      - name: Commit and push changes\n        run: |\n          git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }}\n          git config --global user.name \"GitHub\"\n          git config --global user.email \"noreply@github.com\"\n          git checkout -b ${GITHUB_HEAD_REF}\n          if [[ $(git status -s) ]]; then\n            git add -A\n            git commit -m \"ci: upgrade pinned requirements (automatic)\"\n            git config pull.rebase true\n            git pull origin ${GITHUB_HEAD_REF}\n            git push origin HEAD:${GITHUB_HEAD_REF}\n          fi\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\nCreate a PR with updated constraints files\n\u003c/summary\u003e\n\n```yaml\nname: Requirements (scheduled)\n\non:\n  schedule:\n    - cron: \"0 2 * * 1\"\n  workflow_dispatch:\n\njobs:\n  pip-constraints:\n    name: Update pip constraint files\n    runs-on: ubuntu-22.04\n    strategy:\n      fail-fast: false\n      matrix:\n        python-version:\n          - \"3.7\"\n          - \"3.8\"\n          - \"3.9\"\n    steps:\n      - uses: actions/checkout@v4\n      - uses: ComPWA/update-pip-constraints@v1\n        with:\n          python-version: ${{ matrix.python-version }}\n\n  push:\n    name: Create PR\n    runs-on: ubuntu-22.04\n    needs:\n      - pip-constraints\n    steps:\n      - uses: actions/checkout@v4\n        with:\n          token: ${{ secrets.PAT }}\n      - uses: actions/download-artifact@v4\n      - run: rm -rf .constraints/\n      - run: mv artifact .constraints\n      - uses: peter-evans/create-pull-request@v6\n        with:\n          commit-message: \"ci: update pip constraints files\"\n          committer: GitHub \u003cnoreply@github.com\u003e\n          author: GitHub \u003cnoreply@github.com\u003e\n          title: \"ci: update pip constraints files\"\n          branch-suffix: timestamp\n          delete-branch: true\n          token: ${{ secrets.PAT }}\n      - name: Print PR info\n        run: |\n          echo \"Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}\"\n          echo \"Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}\"\n```\n\n\u003c/details\u003e\n\nNote that you will have to set a\n[create a Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)\n(named `PAT` in the examples) in order to push the changes to the PR branch.\nThe automatic\n[`GITHUB_TOKEN`](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)\ncan be used as well, but that **will not start the workflows**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompwa%2Fupdate-pip-constraints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompwa%2Fupdate-pip-constraints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompwa%2Fupdate-pip-constraints/lists"}