Skip to content

Commit

Permalink
Roll out Python wheel build and publishing (#926)
Browse files Browse the repository at this point in the history
Fixes #897

As part of pulumi/home#2883 we are enabling:

- generating pyproject.toml instead of setup.py
- building wheels alongside source distributions
- making sure both wheels and source distributions are published on pypi

If all goes well this feature-* PR should result in a PyPI version that
can be checked to have both sdist and wheel distros published.
  • Loading branch information
t0yv0 authored Sep 8, 2023
1 parent d677fda commit 94134f1
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 48 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ jobs:
run: ./ci-scripts/ci/publish-tfgen-package ${{ github.workspace }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# See https://github.com/pulumi/scripts/pull/138/files
# Possible values: "all", "wheel".
PYPI_PUBLISH_ARTIFACTS: all
- if: failure() && github.event_name == 'push'
name: Notify Slack
uses: 8398a7/action-slack@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ jobs:
run: ./ci-scripts/ci/publish-tfgen-package ${{ github.workspace }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# See https://github.com/pulumi/scripts/pull/138/files
# Possible values: "all", "wheel".
PYPI_PUBLISH_ARTIFACTS: all
- if: failure() && github.event_name == 'push'
name: Notify Slack
uses: 8398a7/action-slack@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ jobs:
run: ./ci-scripts/ci/publish-tfgen-package ${{ github.workspace }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# See https://github.com/pulumi/scripts/pull/138/files
# Possible values: "all", "wheel".
PYPI_PUBLISH_ARTIFACTS: all
- if: failure() && github.event_name == 'push'
name: Notify Slack
uses: 8398a7/action-slack@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ sdk/java/.gradle
sdk/java/gradle
sdk/java/gradlew
sdk/java/gradlew.bat

sdk/python/venv
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,24 @@ build_nodejs::
sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json

generate_python::
# Delete files not tracked in Git
cd sdk/python/ && git clean -fxd

$(WORKING_DIR)/bin/$(CODEGEN) python ${VERSION}

build_python:: PYPI_VERSION := $(shell pulumictl get version --language python)
build_python::
# Delete files not tracked in Git
cd sdk/python/ && git clean -fxd
cd sdk/python/ && \
cp ../../README.md . && \
python3 setup.py clean --all 2>/dev/null && \
rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \
sed -i.bak -e 's/^VERSION = .*/VERSION = "$(PYPI_VERSION)"/g' -e 's/^PLUGIN_VERSION = .*/PLUGIN_VERSION = "$(VERSION)"/g' ./bin/setup.py && \
rm ./bin/setup.py.bak && \
cd ./bin && python3 setup.py build sdist
sed -i.bak -e 's/^ version = .*/ version = "$(PYPI_VERSION)"/g' ./bin/pyproject.toml && \
rm ./bin/pyproject.toml.bak && \
python3 -m venv venv && \
./venv/bin/python -m pip install build && \
cd ./bin && \
../venv/bin/python -m build .

generate_dotnet::
$(WORKING_DIR)/bin/$(CODEGEN) dotnet ${VERSION}
Expand Down
3 changes: 3 additions & 0 deletions provider/cmd/pulumi-resource-google-native/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,9 @@
"workloadmanager/v1": "workloadmanager/v1",
"workstations/v1beta": "workstations/v1beta"
},
"pyproject": {
"enabled": true
},
"readme": "The native Google Cloud Provider for Pulumi lets you provision Google Cloud resources in your cloud\nprograms. This provider uses the Google Cloud REST API directly and therefore provides full access to Google Cloud.\nThe provider is currently in public preview and is not recommended for production deployments yet. Breaking changes\nwill be introduced in minor version releases.",
"requires": {
"pulumi": "\u003e=3.0.0,\u003c4.0.0"
Expand Down
3 changes: 3 additions & 0 deletions provider/pkg/gen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ programs. This provider uses the Google Cloud REST API directly and therefore pr
The provider is currently in public preview and is not recommended for production deployments yet. Breaking changes
will be introduced in minor version releases.`,
"liftSingleValueMethodReturns": true,
"pyproject": map[string]bool{
"enabled": true,
},
})

pkg.Language["csharp"] = rawMessage(map[string]interface{}{
Expand Down
22 changes: 22 additions & 0 deletions sdk/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[project]
name = "pulumi_google_native"
description = "A native Pulumi package for creating and managing Google Cloud resources."
dependencies = ["parver>=0.2.1", "pulumi>=3.0.0,<4.0.0", "semver>=2.8.1"]
keywords = ["pulumi", "google cloud", "category/cloud", "kind/native"]
readme = "README.md"
requires-python = ">=3.7"
version = "0.0.0"
[project.license]
text = "Apache-2.0"
[project.urls]
Homepage = "https://pulumi.com"
Repository = "https://github.com/pulumi/pulumi-google-native"

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool]
[tool.setuptools]
[tool.setuptools.package-data]
pulumi_google_native = ["py.typed", "pulumi-plugin.json"]
44 changes: 0 additions & 44 deletions sdk/python/setup.py

This file was deleted.

0 comments on commit 94134f1

Please sign in to comment.