Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
11431: Bumps grpcio to version 1.50 r=kpitzen a=kpitzen

Currently, pinning to a version of grpcio <1.50 can cause build errors on newer versions of python+pip - the existing setup.py install method of building libararies is being deprecated and wheels are not being backported for older versions of grpcio.  Since this change is a no-op as far as our python proto clients are concerned, it feels safe to bump to a version that will be supported going forward

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

Fixes #11276 

Though this change doesn't result in guaranteed Python 3.11 support, it should allow users of Python 3.11 to at least install Pulumi successfully without Deprecation warnings etc.  grpcio 1.4X does not ship 3.11-compatible wheels, so users are starting to see errors when installing Pulumi - bumping to this version also does not change our existing proto clients in Python, so feels like a relatively safe change.

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


11437: Mark external modules as forign r=justinvp a=iwahbe

Fixes #8070

Progress on #11427

11440: Cleanup import generation r=iwahbe a=iwahbe

Cleanup the `getPulumiImport` function.

In doing so, remove an edge causing extraneous `/index` in #11427. 


For reviewers, looking at the diff for this PR is painful. It's much easier to review the old and new code separately.

Part of #11427.

11441: Changelog and go.mod updates for v3.47.2 r=pulumi-bot a=pulumi-bot

bors merge

Co-authored-by: Kyle Pitzen <kyle.pitzen@gmail.com>
Co-authored-by: Ian Wahbe <ian@wahbe.com>
Co-authored-by: github-actions <github-actions@github.com>
  • Loading branch information
4 people committed Nov 23, 2022
5 parents c19597a + bac8315 + 724fae5 + bff689c + 1c521a4 commit 36c72e2
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 63 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,19 @@
# Changelog

## 3.47.2 (2022-11-22)


### Features

- [cli] Add prompt to `up` to use experimental update plans.
[#11353](https://github.com/pulumi/pulumi/pull/11353)


### Bug Fixes

- [sdk/python] Don't error on type mismatches when using input values for outputs
[#11422](https://github.com/pulumi/pulumi/pull/11422)

## 3.47.1 (2022-11-18)


Expand Down

This file was deleted.

This file was deleted.

@@ -0,0 +1,4 @@
changes:
- type: chore
scope: sdk/python
description: Bumps grpcio to 1.50
11 changes: 7 additions & 4 deletions pkg/codegen/go/gen.go
Expand Up @@ -40,6 +40,11 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)

// A signifier that the module is external, and will never match.
//
// This token is always an invalid module since ':' is not allowed within modules.
const ExternalModuleSig = ":always-external:"

type typeDetails struct {
// Note: if any of {ptr,array,map}Input are set, input and the corresponding output field must also be set. The
// mark* functions ensure that these invariants hold.
Expand Down Expand Up @@ -242,10 +247,7 @@ func (pkg *pkgContext) resolveEnumType(t *schema.EnumType) string {
}

extPkgCtx, _ := pkg.contextForExternalReference(t)
enumType := extPkgCtx.tokenToEnum(t.Token)
if !strings.Contains(enumType, ".") {
enumType = fmt.Sprintf("%s.%s", extPkgCtx.pkg.Name, enumType)
}
enumType := extPkgCtx.typeString(t)
return enumType
}

Expand Down Expand Up @@ -730,6 +732,7 @@ func (pkg *pkgContext) contextForExternalReference(t schema.Type) (*pkgContext,
extPkgCtx.pkgImportAliases = pkgImportAliases
extPkgCtx.externalPackages = pkg.externalPackages
mod := tokenToPackage(extPkg, goInfo.ModuleToPackage, token)
extPkgCtx.mod = ExternalModuleSig

return extPkgCtx, *maps[mod].detailsForType(t)
}
Expand Down
62 changes: 25 additions & 37 deletions pkg/codegen/go/gen_program.go
Expand Up @@ -363,7 +363,7 @@ func (g *generator) collectImports(
program *pcl.Program,
stdImports,
pulumiImports,
preambleHelperMethods codegen.StringSet) (codegen.StringSet, codegen.StringSet, codegen.StringSet) {
preambleHelperMethods codegen.StringSet) {
// Accumulate import statements for the various providers
for _, n := range program.Nodes {
if r, isResource := n.(*pcl.Resource); isResource {
Expand Down Expand Up @@ -432,8 +432,6 @@ func (g *generator) collectImports(
})
contract.Assert(len(diags) == 0)
}

return stdImports, pulumiImports, preambleHelperMethods
}

func (g *generator) collectConvertImports(
Expand Down Expand Up @@ -492,48 +490,38 @@ func (g *generator) getGoPackageInfo(pkg string) (GoPackageInfo, bool) {
return info, ok
}

func (g *generator) getPulumiImport(pkg, vPath, mod, name string) string {
info, _ := g.getGoPackageInfo(pkg)
if m, ok := info.ModuleToPackage[mod]; ok {
mod = m
}
func (g *generator) getPulumiImport(pkg, versionPath, mod, name string) string {
// We do this before we let the user set overrides. That way the user can still have a
// module named IndexToken.
info, _ := g.getGoPackageInfo(pkg) // We're allowing `info` to be zero-initialized

imp := fmt.Sprintf("github.com/pulumi/pulumi-%s/sdk%s/go/%s/%s", pkg, vPath, pkg, mod)
// namespaceless invokes "aws:index:..."
if mod == "" {
imp = fmt.Sprintf("github.com/pulumi/pulumi-%s/sdk%s/go/%s", pkg, vPath, pkg)
}
importPath := func(mod string) string {
importBasePath := info.ImportBasePath
if importBasePath == "" {
importBasePath = fmt.Sprintf("github.com/pulumi/pulumi-%s/sdk%s/go/%s", pkg, versionPath, pkg)
}

// All providers don't follow the sdk/go/<package> scheme. Allow ImportBasePath as
// a means to override this assumption.
if info.ImportBasePath != "" {
if mod != "" {
imp = fmt.Sprintf("%s/%s", info.ImportBasePath, mod)
} else {
imp = info.ImportBasePath
if mod != "" && mod != IndexToken {
return fmt.Sprintf("%s/%s", importBasePath, mod)
}
return importBasePath
}

if alias, ok := info.PackageImportAliases[imp]; ok {
return fmt.Sprintf("%s %q", alias, imp)
if m, ok := info.ModuleToPackage[mod]; ok {
mod = m
}

modSplit := strings.Split(mod, "/")
// account for mods like "eks/ClusterVpcConfig" index...
if len(modSplit) > 1 {
if modSplit[0] == "" || modSplit[0] == IndexToken {
imp = fmt.Sprintf("github.com/pulumi/pulumi-%s/sdk%s/go/%s", pkg, vPath, pkg)
if info.ImportBasePath != "" {
imp = info.ImportBasePath
}
} else {
imp = fmt.Sprintf("github.com/pulumi/pulumi-%s/sdk%s/go/%s/%s", pkg, vPath, pkg, modSplit[0])
if info.ImportBasePath != "" {
imp = fmt.Sprintf("%s/%s", info.ImportBasePath, modSplit[0])
}
}
path := importPath(mod)
if alias, ok := info.PackageImportAliases[path]; ok {
return fmt.Sprintf("%s %q", alias, path)
}
return fmt.Sprintf("%q", imp)

// Trim off anything after the first '/'.
// This handles transforming modules like s3/bucket to s3 (as found in
// aws:s3/bucket:Bucket).
mod = strings.SplitN(mod, "/", 2)[0]

return fmt.Sprintf("%#v", importPath(mod))
}

// genPostamble closes the method
Expand Down
6 changes: 4 additions & 2 deletions pkg/codegen/go/gen_program_expressions.go
Expand Up @@ -168,8 +168,10 @@ func (g *generator) genSafeEnum(w io.Writer, to *model.EnumType) func(member *sc
}
memberTag, err := makeSafeEnumName(memberTag, enumName)
contract.AssertNoErrorf(err, "Enum is invalid")
namespace := tokenToModule(to.Token)
g.Fgenf(w, "%s.%s", namespace, memberTag)
pkg, mod, _, _ := pcl.DecomposeToken(to.Token, to.SyntaxNode().Range())
mod = g.getModOrAlias(pkg, mod, mod)

g.Fgenf(w, "%s.%s", mod, memberTag)
}
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/codegen/testing/test/program_driver.go
Expand Up @@ -113,8 +113,6 @@ var PulumiPulumiProgramTests = []ProgramTest{
{
Directory: "aws-webserver",
Description: "AWS Webserver",
SkipCompile: codegen.NewStringSet("go"),
// Blocked on go: TODO[pulumi/pulumi#8070]
},
{
Directory: "simple-range",
Expand Down
Expand Up @@ -25,9 +25,9 @@ func main() {
if err != nil {
return err
}
ami, err := aws.GetAmi(ctx, &GetAmiArgs{
Filters: []GetAmiFilter{
GetAmiFilter{
ami, err := aws.GetAmi(ctx, &aws.GetAmiArgs{
Filters: []aws.GetAmiFilter{
aws.GetAmiFilter{
Name: "name",
Values: []string{
"amzn-ami-hvm-*-x86_64-ebs",
Expand Down
2 changes: 1 addition & 1 deletion pkg/go.mod
Expand Up @@ -36,7 +36,7 @@ require (
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d
github.com/opentracing/opentracing-go v1.2.0
github.com/pgavlin/goldmark v1.1.33-0.20200616210433-b5eb04559386
github.com/pulumi/pulumi/sdk/v3 v3.47.1
github.com/pulumi/pulumi/sdk/v3 v3.47.2
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0
github.com/sergi/go-diff v1.2.0
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
Expand Down
2 changes: 1 addition & 1 deletion proto/.checksum.txt
@@ -1,4 +1,4 @@
283055245 2069 proto/build-container/Dockerfile
3850377987 2069 proto/build-container/Dockerfile
3003861496 625 proto/build-container/scripts/install-go.sh
853251015 873 proto/build-container/scripts/install-node.sh
2003827277 549 proto/build-container/scripts/install-packages.sh
Expand Down
4 changes: 2 additions & 2 deletions proto/build-container/Dockerfile
Expand Up @@ -54,6 +54,6 @@ RUN PROTOC_VERSION=3.20.1 \
PROTOC_GEN_GO_VERSION=1.5.2 \
NODEJS_GRPC_VERSION=1.24.2 \
NODEJS_GRPC_TOOLS_VERSION=1.8.1 \
PYTHON_GRPCIO_VERSION=1.49.1 \
PYTHON_GRPCIO_TOOLS_VERSION=1.49.1 \
PYTHON_GRPCIO_VERSION=1.50.0 \
PYTHON_GRPCIO_TOOLS_VERSION=1.50.0 \
/build-scripts/install-protobuf-tools.sh
2 changes: 1 addition & 1 deletion sdk/python/lib/setup.py
Expand Up @@ -45,7 +45,7 @@ def readme():
# Keep this list in sync with Pipfile
install_requires=[
'protobuf~=4.21',
'grpcio==1.47',
'grpcio==1.50',
'dill~=0.3',
'six~=1.12',
'semver~=2.8',
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/requirements.txt
@@ -1,7 +1,7 @@
# Packages needed by the library.
# Keep this list in sync with setup.py.
protobuf~=4.21
grpcio==1.47
grpcio==1.50
dill~=0.3
six~=1.12
semver~=2.8
Expand Down
2 changes: 1 addition & 1 deletion tests/go.mod
Expand Up @@ -12,7 +12,7 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/golang/protobuf v1.5.2
github.com/pulumi/pulumi/pkg/v3 v3.34.1
github.com/pulumi/pulumi/sdk/v3 v3.47.1
github.com/pulumi/pulumi/sdk/v3 v3.47.2
github.com/stretchr/testify v1.8.0
google.golang.org/grpc v1.49.0
sourcegraph.com/sourcegraph/appdash v0.0.0-20211028080628-e2786a622600
Expand Down

0 comments on commit 36c72e2

Please sign in to comment.