pulumi/tests/testdata/codegen/regress-py-12980/python/setup.py

39 lines
1.0 KiB
Python
Raw Permalink Normal View History

Fix python cross module imports (#14832) # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> For python we were generating bad imports for 1) members of the same module, and 2) for members imported from another module. When importing from a different module, we want to always reference members using a fully qualified name (`mymod.childmod.member.Member`) to avoid any naming clashes in case multiple modules have members of the same name. For these we need to import their top level python module (`from ${relPath} import mymod`). When importing members from the same module, we want to use relative imports (`from .some_member import SomeMember`). Fixes https://github.com/pulumi/pulumi/issues/12980 ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] 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 Cloud, 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 Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-01-05 09:05:41 +00:00
# coding=utf-8
# *** WARNING: this file was generated by test. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import errno
from setuptools import setup, find_packages
from setuptools.command.install import install
from subprocess import check_call
Add SupportPack to schemas to write out in the new style (#15713) <!--- 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. --> This adds a new flag to the schema metadata to tell codegen to use the new proposed style of SDKs where we fill in versions and write go.mods etc. I've reworked pack to operate on packages assuming they're in this new style. That is pack no longer has the responsibility to fill in any version information. This updates python and node codegen to write out SDKs in this new style, and fixes their core libraries to still be buildable via pack. There are two approaches to fixing those, I've chosen option 1 below but could pretty easily rework for option 2. 1) Write the version information directly to the SDKs at the same time as we edit the .version file. To simplify this I've added a new 'set-version.py' script that takes a version string an writes it to all the relevant places (.version, package.json, etc). 2) Write "pack" in the language host to search up the directory tree for the ".version" file and then fill in the version information as we we're doing before with envvar tricks and copying and editing package.json. I think 1 is simpler long term, but does force some amount of cleanup in unrelated bits of the system right now (release makefiles need a small edit). 2 is much more localised but keeps this complexity that sdk/nodejs sdk/python aren't actually valid source modules. ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [ ] 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 Cloud, 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 Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-22 09:25:46 +00:00
VERSION = "0.0.0"
Fix python cross module imports (#14832) # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> For python we were generating bad imports for 1) members of the same module, and 2) for members imported from another module. When importing from a different module, we want to always reference members using a fully qualified name (`mymod.childmod.member.Member`) to avoid any naming clashes in case multiple modules have members of the same name. For these we need to import their top level python module (`from ${relPath} import mymod`). When importing members from the same module, we want to use relative imports (`from .some_member import SomeMember`). Fixes https://github.com/pulumi/pulumi/issues/12980 ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] 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 Cloud, 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 Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-01-05 09:05:41 +00:00
def readme():
try:
with open('README.md', encoding='utf-8') as f:
return f.read()
except FileNotFoundError:
return "myPkg Pulumi Package - Development Version"
setup(name='pulumi_myPkg',
python_requires='>=3.8',
Fix python cross module imports (#14832) # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> For python we were generating bad imports for 1) members of the same module, and 2) for members imported from another module. When importing from a different module, we want to always reference members using a fully qualified name (`mymod.childmod.member.Member`) to avoid any naming clashes in case multiple modules have members of the same name. For these we need to import their top level python module (`from ${relPath} import mymod`). When importing members from the same module, we want to use relative imports (`from .some_member import SomeMember`). Fixes https://github.com/pulumi/pulumi/issues/12980 ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] 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 Cloud, 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 Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-01-05 09:05:41 +00:00
version=VERSION,
description="Test imports across different module names",
long_description=readme(),
long_description_content_type='text/markdown',
packages=find_packages(),
package_data={
'pulumi_myPkg': [
'py.typed',
'pulumi-plugin.json',
]
},
install_requires=[
'parver>=0.2.1',
'pulumi>=3.0.0,<4.0.0',
Fix python cross module imports (#14832) # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> For python we were generating bad imports for 1) members of the same module, and 2) for members imported from another module. When importing from a different module, we want to always reference members using a fully qualified name (`mymod.childmod.member.Member`) to avoid any naming clashes in case multiple modules have members of the same name. For these we need to import their top level python module (`from ${relPath} import mymod`). When importing members from the same module, we want to use relative imports (`from .some_member import SomeMember`). Fixes https://github.com/pulumi/pulumi/issues/12980 ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] 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 Cloud, 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 Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-01-05 09:05:41 +00:00
'semver>=2.8.1'
],
zip_safe=False)