-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
52bd0ee
Claim all existing packages on pypi
iliakur 815311d
better script and job name
iliakur ffb0b22
push wheels to pypi
iliakur 6660e07
Don't validate metadata and increase verbosity for better feedback
iliakur ab94109
Drop build isolation to speed up job
iliakur be9a15e
install hatchling separately
iliakur 9cb9ae4
Skip package that's blocked on pypi
iliakur ace4b04
fix bash syntax error
iliakur 0d52e98
upload cert manager, it's been unblocked
iliakur d8445d7
Job runs on schedule
iliakur 81cb542
add comment with motivation; allow workflow to be triggered manually
iliakur f2c1656
Update .github/workflows/claim-pypi-name.yaml
iliakur 1c65ee3
Update .github/workflows/claim-pypi-name.yaml
iliakur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This workflow claims package names on PyPI for our integrations by publishing empty packages. | ||
# The working packages can be found here: | ||
# https://dd-integrations-core-wheels-build-stable.datadoghq.com/targets/simple/index.html | ||
# This is a work-around until PyPI adds support for namespaces and we claim an entire namespace for Datadog. | ||
name: Build Placeholder PyPI Packages | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# At 3AM UTC | ||
# Running this every night strikes a good balance between claiming names fast without spamming PyPI with requests. | ||
- cron: "0 3 * * *" | ||
|
||
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 Deps | ||
run: pip install -U build[virtualenv] hatchling | ||
|
||
- 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 | ||
iliakur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with: | ||
# We don't mind invalid metadata, we only want to claim the package name. | ||
verify-metadata: false | ||
verbose: true | ||
# Only uploading the missing wheels makes this job idempotent and reduces its complexity. | ||
skip-existing: true | ||
user: __token__ | ||
password: ${{ secrets.INTEGRATIONS_PYPI_NAME_CLAIM }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/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 | ||
# We only want wheels. | ||
# We don't need build isolation because we'll trash the env anyway in CI. | ||
# Skipping isolation speeds up the job. | ||
python -m build --no-isolation --wheel pkg_placeholder | ||
mv pkg_placeholder/dist/* dist/ | ||
fi | ||
fi | ||
done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.