Skip to content

Commit

Permalink
change file names
Browse files Browse the repository at this point in the history
Signed-off-by: zhouzheng <[email protected]>
  • Loading branch information
zzvswxy committed Jan 30, 2022
1 parent f1e9b32 commit 4c29769
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 44 deletions.
4 changes: 2 additions & 2 deletions codegen_to_sdk_config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"init": {
"initScript": {
"path": ".scripts/automation_init.sh"
"path": ".scripts/sdk_init.sh"
}
},

"generateAndBuild": {
"generateAndBuildScript": {
"path": ".scripts/automation_generate_for_sdk_generator.sh",
"path": ".scripts/sdk_generate.sh",
"stderr": {
"storeAllLog": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export PATH=/usr/local/n/versions/node/14.15.0/bin:$PATH

TEMP_FILE="$TMPDIR/venv-sdk/auto_temp.json"
# generate code
python -m packaging_tools.auto_codegen_for_sdk_generator "$1" "$TEMP_FILE" 2>&1
python -m packaging_tools.sdk_generator "$1" "$TEMP_FILE" 2>&1
echo "[Generate] codegen done!!!"
if [ ! -f "$TEMP_FILE" ]; then
echo "[Autorest]$TEMP_FILE does not exist!!!Error happened during codegen"
exit 1
fi

# package
python -m packaging_tools.auto_package_for_sdk_generator "$TEMP_FILE" "$2" 2>&1
python -m packaging_tools.sdk_package "$TEMP_FILE" "$2" 2>&1
echo "[Generate] generate done!!!"
if [ ! -f "$2" ]; then
echo "[Autorest]$2 does not exist!!!Error happened during package"
Expand Down
17 changes: 17 additions & 0 deletions scripts/sdk_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# install python3.8
sudo apt-get install python3.8
sudo apt-get install python3.8-venv

# init env
rm -rf $TMPDIR/venv-sdk
python3.8 -m venv $TMPDIR/venv-sdk
VIRTUAL_ENV=$TMPDIR/venv-sdk
export VIRTUAL_ENV
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
python -m pip install -U pip
python scripts/dev_setup.py -p azure-core
echo "{}" >> $2
echo "[Generate] init success!!!"
2 changes: 1 addition & 1 deletion tools/azure-sdk-tools/packaging_tools/auto_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from .swaggertosdk.SwaggerToSdkCore import (CONFIG_FILE,)
from .generate_sdk import generate
from .auto_common_utils import get_package_names, init_new_service, update_servicemetadata
from .generate_utils import get_package_names, init_new_service, update_servicemetadata

_LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tools/azure-sdk-tools/packaging_tools/auto_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path

from azure_devtools.ci_tools.git_tools import get_diff_file_list
from .auto_common_utils import create_package, change_log_generate, extract_breaking_change
from .package_utils import create_package, change_log_generate, extract_breaking_change

_LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import glob
import json
import logging
import os
Expand All @@ -8,7 +7,6 @@
from pathlib import Path
from subprocess import check_call

from .change_log import main as change_log_main
from .swaggertosdk.autorest_tools import build_autorest_options

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -88,37 +86,3 @@ def update_servicemetadata(sdk_folder, data, config, folder_name, package_name,
if write_flag:
with open(manifest_file, "w") as f:
f.write("".join(includes))


def create_package(name, dest_folder=DEFAULT_DEST_FOLDER):
# a package will exist in either one, or the other folder. this is why we can resolve both at the same time.
absdirs = [
os.path.dirname(package)
for package in (glob.glob("{}/setup.py".format(name)) + glob.glob("sdk/*/{}/setup.py".format(name)))
]

absdirpath = os.path.abspath(absdirs[0])
check_call(["python", "setup.py", "bdist_wheel", "-d", dest_folder], cwd=absdirpath)
check_call(["python", "setup.py", "sdist", "--format", "zip", "-d", dest_folder], cwd=absdirpath)


def change_log_generate(package_name, last_version):
from pypi_tools.pypi import PyPIClient

client = PyPIClient()
try:
last_version[-1] = str(client.get_ordered_versions(package_name)[-1])
except:
return " - Initial Release"
else:
return change_log_main(f"{package_name}:pypi", f"{package_name}:latest")


def extract_breaking_change(changelog):
log = changelog.split("\n")
breaking_change = []
for i in range(0, len(log)):
if log[i].find("Breaking changes") > -1:
breaking_change = log[min(i + 2, len(log) - 1) :]
break
return sorted([x.replace(" - ", "") for x in breaking_change])
42 changes: 42 additions & 0 deletions tools/azure-sdk-tools/packaging_tools/package_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import glob
import os

from subprocess import check_call

from .change_log import main as change_log_main

DEFAULT_DEST_FOLDER = "./dist"


def create_package(name, dest_folder=DEFAULT_DEST_FOLDER):
# a package will exist in either one, or the other folder. this is why we can resolve both at the same time.
absdirs = [
os.path.dirname(package)
for package in (glob.glob("{}/setup.py".format(name)) + glob.glob("sdk/*/{}/setup.py".format(name)))
]

absdirpath = os.path.abspath(absdirs[0])
check_call(["python", "setup.py", "bdist_wheel", "-d", dest_folder], cwd=absdirpath)
check_call(["python", "setup.py", "sdist", "--format", "zip", "-d", dest_folder], cwd=absdirpath)


def change_log_generate(package_name, last_version):
from pypi_tools.pypi import PyPIClient

client = PyPIClient()
try:
last_version[-1] = str(client.get_ordered_versions(package_name)[-1])
except:
return " - Initial Release"
else:
return change_log_main(f"{package_name}:pypi", f"{package_name}:latest")


def extract_breaking_change(changelog):
log = changelog.split("\n")
breaking_change = []
for i in range(0, len(log)):
if log[i].find("Breaking changes") > -1:
breaking_change = log[min(i + 2, len(log) - 1) :]
break
return sorted([x.replace(" - ", "") for x in breaking_change])
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from .swaggertosdk.SwaggerToSdkCore import (CONFIG_FILE)
from .generate_sdk import generate
from .auto_common_utils import get_package_names, init_new_service, update_servicemetadata
from .generate_utils import get_package_names, init_new_service, update_servicemetadata

_LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path

from azure_devtools.ci_tools.git_tools import get_diff_file_list
from .auto_common_utils import create_package, change_log_generate, extract_breaking_change
from .package_utils import create_package, change_log_generate, extract_breaking_change

_LOGGER = logging.getLogger(__name__)

Expand Down

0 comments on commit 4c29769

Please sign in to comment.