Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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

This file was deleted.

8 changes: 8 additions & 0 deletions packages/autorest.python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release

## 6.31.0

### Features

- [#3057](https://github.com/Azure/autorest.python/pull/3057) Always respect namespace from TCGC
- [#3060](https://github.com/Azure/autorest.python/pull/3060) Refine emitter options


## 6.30.0

### Bump dependencies
Expand Down
4 changes: 2 additions & 2 deletions packages/autorest.python/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@autorest/python",
"version": "6.30.0",
"version": "6.31.0",
"description": "The Python extension for generators in AutoRest.",
"scripts": {
"start": "node ./scripts/run-python3.js ./scripts/start.py",
Expand Down Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "~0.9.0-dev.1",
"@typespec/http-client-python": "~0.8.2",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand Down
8 changes: 8 additions & 0 deletions packages/typespec-python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release

## 0.41.0

### Features

- [#3057](https://github.com/Azure/autorest.python/pull/3057) Always respect namespace from TCGC
- [#3060](https://github.com/Azure/autorest.python/pull/3060) Refine emitter options


## 0.40.0

### Bump dependencies
Expand Down
4 changes: 2 additions & 2 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/typespec-python",
"version": "0.40.0",
"version": "0.41.0",
"author": "Microsoft Corporation",
"description": "TypeSpec emitter for Python SDKs",
"homepage": "https://github.com/Azure/autorest.python",
Expand Down Expand Up @@ -60,7 +60,7 @@
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"@typespec/http-client-python": "~0.9.0-dev.1",
"@typespec/http-client-python": "~0.8.2",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand Down
8 changes: 0 additions & 8 deletions packages/typespec-python/scripts/eng/regenerate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ const AZURE_EMITTER_OPTIONS: Record<string, Record<string, string> | Record<stri
"azure/client-generator-core/usage": {
namespace: "specs.azure.clientgenerator.core.usage",
},
"azure/core/lro/rpc": {
"package-name": "azurecore-lro-rpc",
"namespace": "azurecore.lro.rpc",
},
"client/structure/default": {
namespace: "client.structure.service",
},
Expand Down Expand Up @@ -183,10 +179,6 @@ const EMITTER_OPTIONS: Record<string, Record<string, string> | Record<string, st
"package-name": "typetest-union",
"namespace": "typetest.union",
},
"azure/core/lro/rpc": {
"package-name": "azurecore-lro-rpc",
"namespace": "azurecore.lro.rpc",
},
"client/structure/multi-client": {
"package-name": "client-structure-multiclient",
"namespace": "client.structure.multiclient",
Expand Down
4 changes: 2 additions & 2 deletions packages/typespec-python/src/emitter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EmitContext } from "@typespec/compiler";
import { PythonEmitterOptions } from "./lib.js";
import { PythonAzureEmitterOptions } from "./lib.js";
import { $onEmit as httpClientPythonOnEmit } from "@typespec/http-client-python";

export async function $onEmit(context: EmitContext<PythonEmitterOptions>) {
export async function $onEmit(context: EmitContext<PythonAzureEmitterOptions>) {
// set flavor to azure if not set for python azure emitter
if (context.options.flavor === undefined) {
context.options.flavor = "azure";
Expand Down
68 changes: 32 additions & 36 deletions packages/typespec-python/src/lib.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
import { SdkContext, SdkServiceOperation } from "@azure-tools/typespec-client-generator-core";
import { createTypeSpecLibrary, JSONSchemaType } from "@typespec/compiler";
import { PythonEmitterOptions, PythonEmitterOptionsSchema } from "@typespec/http-client-python";

export interface PythonEmitterOptions {
"package-version"?: string;
"package-name"?: string;
"output-dir"?: string;
"generate-packaging-files"?: boolean;
"packaging-files-dir"?: string;
"packaging-files-config"?: object;
"package-pprint-name"?: string;
"head-as-boolean"?: boolean;
export interface PythonAzureEmitterOptions extends PythonEmitterOptions {
"flavor"?: "azure";
"models-mode"?: string;
"tracing"?: boolean;
"company-name"?: string;
"generate-sample"?: boolean;
"generate-test"?: boolean;
"debug"?: boolean;
"flavor"?: "azure";
"examples-dir"?: string;
// If true, package namespace will respect the typespec namespace. Otherwise,
// package namespace is always aligned with package name.
"enable-typespec-namespace"?: boolean;
}

export interface PythonSdkContext<TServiceOperation extends SdkServiceOperation>
extends SdkContext<PythonEmitterOptions, TServiceOperation> {
extends SdkContext<PythonAzureEmitterOptions, TServiceOperation> {
__endpointPathParameters: Record<string, any>[];
}

const EmitterOptionsSchema: JSONSchemaType<PythonEmitterOptions> = {
const PythonAzureEmitterOptionsSchema: JSONSchemaType<PythonAzureEmitterOptions> = {
type: "object",
additionalProperties: true,
properties: {
"package-version": { type: "string", nullable: true },
"package-name": { type: "string", nullable: true },
"output-dir": { type: "string", nullable: true },
"generate-packaging-files": { type: "boolean", nullable: true },
"packaging-files-dir": { type: "string", nullable: true },
"packaging-files-config": { type: "object", nullable: true },
"package-pprint-name": { type: "string", nullable: true },
"head-as-boolean": { type: "boolean", nullable: true },
"models-mode": { type: "string", nullable: true },
"tracing": { type: "boolean", nullable: true },
"company-name": { type: "string", nullable: true },
"generate-test": { type: "boolean", nullable: true },
"debug": { type: "boolean", nullable: true },
"flavor": { type: "string", nullable: true },
"examples-dir": { type: "string", nullable: true, format: "absolute-path" },
"enable-typespec-namespace": { type: "boolean", nullable: true },
"flavor": {
type: "string",
nullable: true,
description: "The flavor of the SDK.",
},
"models-mode": {
type: "string",
nullable: true,
enum: ["dpg", "none"],
description:
"What kind of models to generate. If you pass in `none`, we won't generate models. `dpg` models are the default models we generate.",
},
"generate-sample": {
type: "boolean",
nullable: true,
description:
"Whether to generate sample files, for basic samples of your generated sdks. Defaults to `false`.",
},
"generate-test": {
type: "boolean",
nullable: true,
description:
"Whether to generate test files, for basic testing of your generated sdks. Defaults to `false`.",
},
...PythonEmitterOptionsSchema.properties,
},
required: [],
};
Expand All @@ -55,7 +51,7 @@ const libDef = {
name: "@azure-tools/typespec-python",
diagnostics: {},
emitter: {
options: EmitterOptionsSchema as JSONSchemaType<PythonEmitterOptions>,
options: PythonAzureEmitterOptionsSchema,
},
} as const;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include *.md
include LICENSE
include specs/azure/core/lro/rpc/py.typed
recursive-include tests *.py
recursive-include samples *.py *.md
include specs/__init__.py
include specs/azure/__init__.py
include specs/azure/core/__init__.py
include specs/azure/core/lro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Azurecore Lro Rpc client library for Python
# Specs Azure Core Lro Rpc client library for Python
<!-- write necessary description of service -->

## Getting started

### Install the package

```bash
python -m pip install azurecore-lro-rpc
python -m pip install specs-azure-core-lro-rpc
```

#### Prequisites

- Python 3.8 or later is required to use this package.
- You need an [Azure subscription][azure_sub] to use this package.
- An existing Azurecore Lro Rpc instance.
- An existing Specs Azure Core Lro Rpc instance.


## Contributing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"CrossLanguagePackageId": "_Specs_.Azure.Core.Lro.Rpc",
"CrossLanguageDefinitionId": {
"specs.azure.core.lro.rpc.models.GenerationOptions": "_Specs_.Azure.Core.Lro.Rpc.GenerationOptions",
"specs.azure.core.lro.rpc.models.GenerationResult": "_Specs_.Azure.Core.Lro.Rpc.GenerationResult",
"specs.azure.core.lro.rpc.RpcClient.begin_long_running_rpc": "_Specs_.Azure.Core.Lro.Rpc.longRunningRpc"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from azurecore.lro.rpc import RpcClient
from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer
import functools
from specs.azure.core.lro.rpc import RpcClient


class RpcClientTestBase(AzureRecordedTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from azurecore.lro.rpc.aio import RpcClient
from devtools_testutils import AzureRecordedTestCase
from specs.azure.core.lro.rpc.aio import RpcClient


class RpcClientTestBaseAsync(AzureRecordedTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from setuptools import setup, find_packages


PACKAGE_NAME = "azurecore-lro-rpc"
PACKAGE_PPRINT_NAME = "Azurecore Lro Rpc"
PACKAGE_NAME = "specs-azure-core-lro-rpc"
PACKAGE_PPRINT_NAME = "Specs Azure Core Lro Rpc"

# a-b-c => a/b/c
package_folder_path = PACKAGE_NAME.replace("-", "/")
Expand Down Expand Up @@ -54,13 +54,15 @@
exclude=[
"tests",
# Exclude packages that will be covered by PEP420 or nspkg
"azurecore",
"azurecore.lro",
"specs",
"specs.azure",
"specs.azure.core",
"specs.azure.core.lro",
]
),
include_package_data=True,
package_data={
"azurecore.lro.rpc": ["py.typed"],
"specs.azure.core.lro.rpc": ["py.typed"],
},
install_requires=[
"isodate>=0.6.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> No

self.endpoint = endpoint
self.api_version = api_version
kwargs.setdefault("sdk_moniker", "azurecore-lro-rpc/{}".format(VERSION))
kwargs.setdefault("sdk_moniker", "specs-azure-core-lro-rpc/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ def begin_long_running_rpc(
Generate data.

:param body: The body parameter. Required.
:type body: ~azurecore.lro.rpc.models.GenerationOptions
:type body: ~specs.azure.core.lro.rpc.models.GenerationOptions
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: An instance of LROPoller that returns GenerationResult. The GenerationResult is
compatible with MutableMapping
:rtype: ~azure.core.polling.LROPoller[~azurecore.lro.rpc.models.GenerationResult]
:rtype: ~azure.core.polling.LROPoller[~specs.azure.core.lro.rpc.models.GenerationResult]
:raises ~azure.core.exceptions.HttpResponseError:
"""

Expand All @@ -163,7 +163,7 @@ def begin_long_running_rpc(
:paramtype content_type: str
:return: An instance of LROPoller that returns GenerationResult. The GenerationResult is
compatible with MutableMapping
:rtype: ~azure.core.polling.LROPoller[~azurecore.lro.rpc.models.GenerationResult]
:rtype: ~azure.core.polling.LROPoller[~specs.azure.core.lro.rpc.models.GenerationResult]
:raises ~azure.core.exceptions.HttpResponseError:
"""

Expand All @@ -182,7 +182,7 @@ def begin_long_running_rpc(
:paramtype content_type: str
:return: An instance of LROPoller that returns GenerationResult. The GenerationResult is
compatible with MutableMapping
:rtype: ~azure.core.polling.LROPoller[~azurecore.lro.rpc.models.GenerationResult]
:rtype: ~azure.core.polling.LROPoller[~specs.azure.core.lro.rpc.models.GenerationResult]
:raises ~azure.core.exceptions.HttpResponseError:
"""

Expand All @@ -196,10 +196,10 @@ def begin_long_running_rpc(

:param body: The body parameter. Is one of the following types: GenerationOptions, JSON,
IO[bytes] Required.
:type body: ~azurecore.lro.rpc.models.GenerationOptions or JSON or IO[bytes]
:type body: ~specs.azure.core.lro.rpc.models.GenerationOptions or JSON or IO[bytes]
:return: An instance of LROPoller that returns GenerationResult. The GenerationResult is
compatible with MutableMapping
:rtype: ~azure.core.polling.LROPoller[~azurecore.lro.rpc.models.GenerationResult]
:rtype: ~azure.core.polling.LROPoller[~specs.azure.core.lro.rpc.models.GenerationResult]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> No

self.endpoint = endpoint
self.api_version = api_version
kwargs.setdefault("sdk_moniker", "azurecore-lro-rpc/{}".format(VERSION))
kwargs.setdefault("sdk_moniker", "specs-azure-core-lro-rpc/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

Expand Down
Loading
Loading