Skip to content

Commit

Permalink
Add check for urls present in requires_dist (#1728)
Browse files Browse the repository at this point in the history
* Add check for git urls in requires_dist

* Update check for direct references and add error message.

* Put package distribution checks in separate script

* Temp. disable tests to check package is valid first

* Remove test job

* Reformat cpu-ci

* Put docs back in requries_dist to check validation fails

* Add missing colons for error message

* Remove docs from extras_require

Co-authored-by: Karl Higley <kmhigley@gmail.com>
  • Loading branch information
oliverholworthy and karlhigley authored Dec 15, 2022
1 parent f8df0d9 commit 985510e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/cpu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ jobs:
python -m pip install --upgrade pip setuptools==59.4.0 wheel tox pybind11
python -m pip uninstall protobuf -y
python -m pip install --no-binary=protobuf protobuf
- name: Generate package for pypi
run: |
python setup.py sdist bdist_wheel
- name: Check distribution is valid
run: |
./ci/check_dist.sh
- name: Run tests
run: |
ref_type=${{ github.ref_type }}
Expand All @@ -44,9 +50,6 @@ jobs:
branch=${raw/origin\/}
fi
tox -e test-cpu -- $branch
- name: Generate package for pypi
run: |
python setup.py sdist bdist_wheel
- name: Upload pypi artifacts to github
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -132,4 +135,4 @@ jobs:
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
anaconda -t $ANACONDA_TOKEN upload -u nvidia conda/*.tar.bz2
anaconda -t $ANACONDA_TOKEN upload -u nvidia conda/*.tar.bz2
18 changes: 18 additions & 0 deletions ci/check_dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__root="$(cd "$(dirname "${__dir}")" && pwd)"

pip install pkginfo twine

pkginfo -f requires_dist ${__root}/dist/*.whl | grep "@"

if [ $? -eq 0 ]; then
cat <<EOF
::error::Found direct reference(s) in package requires_dist. Please use only normal version specifiers.
See https://peps.python.org/pep-0440/#direct-references for more details.
EOF
exit 1
fi

twine check ${__root}/dist/*

0 comments on commit 985510e

Please sign in to comment.