Skip to content

Claim all existing packages on pypi #17580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/claim-pypi-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build Placeholder PyPI Packages

on:
pull_request:
branches:
- master

defaults:
run:
shell: bash


jobs:
python-artifacts:
name: Build wheel and source distribution
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install Build
run: pip install -U build[virtualenv]

- name: Build Packages
run: |
bash .github/workflows/scripts/build_placeholders.sh

# - name: Push Python artifacts to PyPI
# uses: pypa/gh-action-pypi-publish@v1.8.14
# with:
# skip-existing: true
# user: __token__
# password: ${{ secrets.INTEGRATIONS_PYPI_NAME_CLAIM }}
29 changes: 29 additions & 0 deletions .github/workflows/scripts/build_placeholders.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Requires python 3.11+ (for tomllib) and the `build` package.
# Run this script from the root of the repo.
# The TL;DR of this script is: for every subdirectory with a pyproject.toml file we build an empty Python wheel.

mkdir -p dist
mkdir -p pkg_placeholder
for file_or_subdir in *; do
if [[ -d "${file_or_subdir}" ]]; then
pyproject="${file_or_subdir}/pyproject.toml"
if [[ -f "${pyproject}" ]]; then
pypi_pkg_name=$(python -c "import tomllib, pathlib; contents = pathlib.Path('${pyproject}').read_text(); data = tomllib.loads(contents); print(data['project']['name'])")
# multiline strings are sensitive to indentation, so we must unindent the following command
cat <<EOF > pkg_placeholder/pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "${pypi_pkg_name}"
version = "0.0.1"
[tool.hatch.build.targets.wheel]
bypass-selection = true
EOF
python -m build --wheel pkg_placeholder
mv pkg_placeholder/dist/* dist/
fi
fi
done
Loading