From 77914b327b5455580bd4c557566db09de72c2442 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Mon, 19 Apr 2021 13:29:27 -0700 Subject: [PATCH 1/8] add an environment.yml. consume in both build_conda_artifacts as well as in the meta.yml package definitions. --- doc/dev/conda-builds.md | 14 ++++++++++ eng/environment.yml | 5 ++++ .../templates/steps/build-conda-artifacts.yml | 22 ++++++++++++---- .../templates/steps/get-tagged-code.yml | 4 +-- scripts/devops_tasks/build_conda_artifacts.py | 26 ++++++++++++------- sdk/core/meta.yaml | 5 ++-- sdk/storage/ci.yml | 1 + sdk/storage/meta.yaml | 11 ++++---- 8 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 eng/environment.yml diff --git a/doc/dev/conda-builds.md b/doc/dev/conda-builds.md index aacebc5127ac..73702badd35d 100644 --- a/doc/dev/conda-builds.md +++ b/doc/dev/conda-builds.md @@ -16,6 +16,20 @@ A Conda Artifact defines: ## How to Build an Azure SDK Conda Package Locally +### Set up your conda environment + +You will notice that all the azure-sdk conda distributions have the **same** version number and requirement set. This is due to the fact that the azure-sdk team pushes our conda packages out in waves. To support this, all versions are set via a common environment variable `AZURESDK_CONDA_VERSION`. + +We keep this environment variable set properly across all our builds by using a common `environment.yml` when creating our build environment. This environment definition ensures that + +1. Our channel `https://azuresdkconda.blob.core.windows.net/channel1/` is added to the set to download packages +2. The environment variable `AZURESDK_CONDA_VERSION` will be set exactly once. + + +Reference the `environment.yml` in your local build by pass `-f ` when you create your conda environment. +``` +conda env create --yes --quiet --name ${{ artifact.name }} -f $(Build.SourcesDirectory)/eng/environment.yml +``` ### Create Your Build Directory Given how Conda packages are comprised of multiple source distributions _combined_, the buildable source does not exist directly within the azure-sdk-for-python repo. Currently, there is _some_ manual work that needs to be done. diff --git a/eng/environment.yml b/eng/environment.yml new file mode 100644 index 000000000000..fd24bcfb2ba1 --- /dev/null +++ b/eng/environment.yml @@ -0,0 +1,5 @@ +channels: + - https://azuresdkconda.blob.core.windows.net/channel1/ + +variables: + AZURESDK_CONDA_VERSION: '2021.05.01' diff --git a/eng/pipelines/templates/steps/build-conda-artifacts.yml b/eng/pipelines/templates/steps/build-conda-artifacts.yml index 024898a4ea66..d834fe761bfd 100644 --- a/eng/pipelines/templates/steps/build-conda-artifacts.yml +++ b/eng/pipelines/templates/steps/build-conda-artifacts.yml @@ -53,21 +53,33 @@ steps: displayName: 'Build Source Distribution for ${{ artifact.name }}' inputs: scriptPath: 'scripts/devops_tasks/build_conda_artifacts.py' - arguments: '-d "$(conda.output)" -b "$(conda.build)" -m "$(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }}/${{ artifact.meta_source }}" -r "${{ artifact.common_root }}" -n "${{ artifact.name }}" -s "${{ parameters.ServiceDirectory }}" -o "${{ upper(parameters.ServiceDirectory) }}_SOURCE_DISTRIBUTION"' + arguments: >- + -d "$(conda.output)" + -b "$(conda.build)" + -m "$(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }}/${{ artifact.meta_source }}" + -r "${{ artifact.common_root }}" + -n "${{ artifact.name }}" + -s "${{ parameters.ServiceDirectory }}" + -o "${{ upper(parameters.ServiceDirectory) }}_SOURCE_DISTRIBUTION" + -e "$(Build.SourcesDirectory)/eng/environment.yml" - bash: | echo "##vso[task.prependpath]$CONDA/bin" displayName: 'Prepend PATH with Conda and INIT' - bash: | - conda create --yes --quiet --name ${{ artifact.name }} - source activate ${{ artifact.name }} + conda env create --yes --quiet --name ${{ artifact.name }} -f $(Build.SourcesDirectory)/eng/environment.yml + conda activate ${{ artifact.name }} conda install --yes --quiet --name ${{ artifact.name }} conda-build displayName: 'Prepare Conda Environment for building ${{ artifact.name }}' + - pwsh: | + + displayName: 'Set Conda Version Variable' + - bash: | - source activate ${{ artifact.name }} - conda-build . --output-folder "$(Agent.BuildDirectory)/conda/output" -c https://azuresdkconda.blob.core.windows.net/channel1/ + conda activate ${{ artifact.name }} + conda-build . --output-folder "$(Agent.BuildDirectory)/conda/output" displayName: 'Activate Conda Environment and Build ${{ artifact.name }}' workingDirectory: $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }} diff --git a/eng/pipelines/templates/steps/get-tagged-code.yml b/eng/pipelines/templates/steps/get-tagged-code.yml index e8182f5a5319..34a0e0bf2033 100644 --- a/eng/pipelines/templates/steps/get-tagged-code.yml +++ b/eng/pipelines/templates/steps/get-tagged-code.yml @@ -15,9 +15,7 @@ parameters: steps: - pwsh: | $targetPath = "$(Agent.TempDirectory)/${{ parameters.Package }}" - if (!(Test-Path $targetPath)) { - mkdir $targetPath - } + mkdir -p $targetPath Write-Host "##vso[task.setvariable variable=Package.Clone]$targetPath" displayName: 'Prep for Sparse Checkout' diff --git a/scripts/devops_tasks/build_conda_artifacts.py b/scripts/devops_tasks/build_conda_artifacts.py index 8882c8ce0edf..1b513a1d0da6 100644 --- a/scripts/devops_tasks/build_conda_artifacts.py +++ b/scripts/devops_tasks/build_conda_artifacts.py @@ -30,7 +30,7 @@ from subprocess import check_call from distutils.dir_util import copy_tree -VERSION_REGEX = re.compile(r"\{\%\s*set\s*version\s*=\s*\"(.*)\"\s*\%\}") +VERSION_REGEX = re.compile(r"\s*AZURESDK_CONDA_VERSION\s*:\s*[\'](.*)[\']\s*") NAMESPACE_EXTENSION_TEMPLATE = """__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: str """ @@ -142,9 +142,8 @@ def create_sdist_skeleton(build_directory, artifact_name, common_root): dest = os.path.join(ns_dir, directory) shutil.copytree(src, dest) - -def get_version_from_meta(meta_yaml_location): - with open(os.path.abspath((meta_yaml_location)), "r") as f: +def get_version_from_config(environment_config): + with open(os.path.abspath((environment_config)), "r") as f: lines = f.readlines() for line in lines: result = VERSION_REGEX.match(line) @@ -152,7 +151,6 @@ def get_version_from_meta(meta_yaml_location): return result.group(1) return "0.0.0" - def get_manifest_includes(common_root): levels = common_root.split("/") breadcrumbs = [] @@ -165,7 +163,7 @@ def get_manifest_includes(common_root): return breadcrumbs -def create_setup_files(build_directory, common_root, artifact_name, service, meta_yaml): +def create_setup_files(build_directory, common_root, artifact_name, service, meta_yaml, environment_config): sdist_directory = os.path.join(build_directory, artifact_name) setup_location = os.path.join(sdist_directory, "setup.py") manifest_location = os.path.join(sdist_directory, "MANIFEST.in") @@ -173,7 +171,7 @@ def create_setup_files(build_directory, common_root, artifact_name, service, met setup_template = CONDA_PKG_SETUP_TEMPLATE.format( conda_package_name=artifact_name, - version=get_version_from_meta(meta_yaml), + version=get_version_from_config(environment_config), service=service, package_excludes="'azure', 'tests', '{}'".format(common_root.replace("/", ".")), ) @@ -193,7 +191,7 @@ def create_setup_files(build_directory, common_root, artifact_name, service, met def create_combined_sdist( - output_directory, build_directory, artifact_name, common_root, service, meta_yaml + output_directory, build_directory, artifact_name, common_root, service, meta_yaml, environment_config ): singular_dependency = ( len(get_pkgs_from_build_directory(build_directory, artifact_name)) == 0 @@ -202,7 +200,7 @@ def create_combined_sdist( if not singular_dependency: create_sdist_skeleton(build_directory, artifact_name, common_root) create_setup_files( - build_directory, common_root, artifact_name, service, meta_yaml + build_directory, common_root, artifact_name, service, meta_yaml, environment_config ) sdist_location = os.path.join(build_directory, artifact_name) @@ -283,6 +281,15 @@ def create_combined_sdist( required=False, ) + parser.add_argument( + "-e", + "--environment_config", + dest="environment_config", + help="The location of the environment.yml used to create the conda environments. This file has necessary common configuration information within.", + required=False, + ) + + args = parser.parse_args() output_source_location = create_combined_sdist( args.distribution_directory, @@ -291,6 +298,7 @@ def create_combined_sdist( args.common_root, args.service, args.meta_yml, + args.environment_config ) if args.output_var: diff --git a/sdk/core/meta.yaml b/sdk/core/meta.yaml index 57260f435fa7..3c3d045feb66 100644 --- a/sdk/core/meta.yaml +++ b/sdk/core/meta.yaml @@ -1,9 +1,8 @@ {% set name = "azure-core" %} -{% set version = "2021.05.01" %} package: name: "{{ name|lower }}" - version: "{{ version }}" + version: {{ environ.get('AZURESDK_CONDA_VERSION', '0.0.0') }} source: url: {{ environ.get('CORE_SOURCE_DISTRIBUTION', '') }} @@ -39,7 +38,7 @@ about: license: MIT license_family: MIT license_file: - summary: "Microsoft Azure Core Library for Python" + summary: {{ environ.get('AZURESDK_CONDA_SUMMARY', 'Microsoft Azure Core Library for Python') }} doc_url: dev_url: diff --git a/sdk/storage/ci.yml b/sdk/storage/ci.yml index a50fcfd3c3d5..155e66da510f 100644 --- a/sdk/storage/ci.yml +++ b/sdk/storage/ci.yml @@ -39,6 +39,7 @@ extends: MatrixConfigs: - Name: storage_ci_matrix Path: eng/pipelines/templates/stages/platform-matrix-cryptography-dependency.json + GenerateDocs: False Selection: sparse GenerateVMJobs: true Artifacts: diff --git a/sdk/storage/meta.yaml b/sdk/storage/meta.yaml index 676f37b987a9..ba9401ddaa62 100644 --- a/sdk/storage/meta.yaml +++ b/sdk/storage/meta.yaml @@ -1,9 +1,8 @@ {% set name = "azure-storage" %} -{% set version = "2021.05.01" %} package: name: "{{ name|lower }}" - version: "{{ version }}" + version: {{ environ.get('AZURESDK_CONDA_VERSION', '0.0.0') }} source: url: {{ environ.get('STORAGE_SOURCE_DISTRIBUTION', '') }} @@ -17,14 +16,14 @@ build: requirements: host: - - azure-core >=2021.05.01 + - azure-core >={{ environ.get('AZURESDK_CONDA_VERSION', '0.0.0') }} - cryptography >=2.1.4 - msrest >=2021.05.01 - pip - python - aiohttp run: - - azure-core >=2021.05.01 + - azure-core >={{ environ.get('AZURESDK_CONDA_VERSION', '0.0.0') }} - cryptography >=2.1.4 - msrest >=2021.05.01 - python @@ -42,8 +41,8 @@ about: home: "https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage" license: MIT license_family: MIT - license_file: - summary: "Microsoft Azure Storage Client Library for Python" + license_file: + summary: {{ environ.get('AZURESDK_CONDA_SUMMARY', 'Microsoft Azure Storage Client Library for Python') }} doc_url: dev_url: From 82ae04ebbea1777484c1ca7a1b906fa09a40e316 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Mon, 19 Apr 2021 13:30:47 -0700 Subject: [PATCH 2/8] small update to the manual --- doc/dev/conda-builds.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/dev/conda-builds.md b/doc/dev/conda-builds.md index 73702badd35d..2a61100eaae2 100644 --- a/doc/dev/conda-builds.md +++ b/doc/dev/conda-builds.md @@ -98,6 +98,7 @@ python `build_conda_artifacts.py` -r "azure/storage" -n "azure-storage" -s "storage" + -e "/eng/environment.yml" ``` ### Generate the Conda Package From 41aacb19d71aae064a8cf33cc5ef6809d4a02c2b Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Mon, 19 Apr 2021 14:20:39 -0700 Subject: [PATCH 3/8] update how env create is called --- eng/pipelines/templates/steps/build-conda-artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/build-conda-artifacts.yml b/eng/pipelines/templates/steps/build-conda-artifacts.yml index d834fe761bfd..f599eff96d36 100644 --- a/eng/pipelines/templates/steps/build-conda-artifacts.yml +++ b/eng/pipelines/templates/steps/build-conda-artifacts.yml @@ -68,7 +68,7 @@ steps: displayName: 'Prepend PATH with Conda and INIT' - bash: | - conda env create --yes --quiet --name ${{ artifact.name }} -f $(Build.SourcesDirectory)/eng/environment.yml + conda env create --name ${{ artifact.name }} --file $(Build.SourcesDirectory)/eng/environment.yml conda activate ${{ artifact.name }} conda install --yes --quiet --name ${{ artifact.name }} conda-build displayName: 'Prepare Conda Environment for building ${{ artifact.name }}' From e4dcc327a9aefc41d6dd55e008a76010fae3ea5a Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Mon, 19 Apr 2021 14:41:08 -0700 Subject: [PATCH 4/8] remove superfluous activation command. activate the environment with source --- eng/pipelines/templates/steps/build-conda-artifacts.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eng/pipelines/templates/steps/build-conda-artifacts.yml b/eng/pipelines/templates/steps/build-conda-artifacts.yml index f599eff96d36..16b911939ec0 100644 --- a/eng/pipelines/templates/steps/build-conda-artifacts.yml +++ b/eng/pipelines/templates/steps/build-conda-artifacts.yml @@ -69,7 +69,6 @@ steps: - bash: | conda env create --name ${{ artifact.name }} --file $(Build.SourcesDirectory)/eng/environment.yml - conda activate ${{ artifact.name }} conda install --yes --quiet --name ${{ artifact.name }} conda-build displayName: 'Prepare Conda Environment for building ${{ artifact.name }}' @@ -78,7 +77,7 @@ steps: displayName: 'Set Conda Version Variable' - bash: | - conda activate ${{ artifact.name }} + source activate ${{ artifact.name }} conda-build . --output-folder "$(Agent.BuildDirectory)/conda/output" displayName: 'Activate Conda Environment and Build ${{ artifact.name }}' workingDirectory: $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }} From f74bb5a9f6ad7e6ae3b4bc10b634dce29114081f Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Mon, 19 Apr 2021 16:11:48 -0700 Subject: [PATCH 5/8] creating a fresh environment with channels already established doesn't seem to be recognized. still need to pass custom channel to build command --- eng/environment.yml | 1 + eng/pipelines/templates/steps/build-conda-artifacts.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/environment.yml b/eng/environment.yml index fd24bcfb2ba1..d17d4adc8171 100644 --- a/eng/environment.yml +++ b/eng/environment.yml @@ -1,5 +1,6 @@ channels: - https://azuresdkconda.blob.core.windows.net/channel1/ + - defaults variables: AZURESDK_CONDA_VERSION: '2021.05.01' diff --git a/eng/pipelines/templates/steps/build-conda-artifacts.yml b/eng/pipelines/templates/steps/build-conda-artifacts.yml index 16b911939ec0..1b1dc3275581 100644 --- a/eng/pipelines/templates/steps/build-conda-artifacts.yml +++ b/eng/pipelines/templates/steps/build-conda-artifacts.yml @@ -78,7 +78,7 @@ steps: - bash: | source activate ${{ artifact.name }} - conda-build . --output-folder "$(Agent.BuildDirectory)/conda/output" + conda-build . --output-folder "$(Agent.BuildDirectory)/conda/output" -c https://azuresdkconda.blob.core.windows.net/channel1/ displayName: 'Activate Conda Environment and Build ${{ artifact.name }}' workingDirectory: $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }} From ddfe74a6fd50375f7b8ba97c17e029c45c21fdaa Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Mon, 19 Apr 2021 17:51:47 -0700 Subject: [PATCH 6/8] swap over to using globals.yml for the channel. add summary creation --- doc/dev/conda-builds.md | 1 + eng/environment.yml | 4 -- .../templates/steps/build-conda-artifacts.yml | 8 +-- eng/pipelines/templates/variables/globals.yml | 1 + scripts/devops_tasks/build_conda_artifacts.py | 53 +++++++++++++++---- sdk/core/meta.yaml | 4 +- sdk/storage/ci.yml | 1 - sdk/storage/meta.yaml | 4 +- 8 files changed, 50 insertions(+), 26 deletions(-) diff --git a/doc/dev/conda-builds.md b/doc/dev/conda-builds.md index 2a61100eaae2..feff7267d149 100644 --- a/doc/dev/conda-builds.md +++ b/doc/dev/conda-builds.md @@ -99,6 +99,7 @@ python `build_conda_artifacts.py` -n "azure-storage" -s "storage" -e "/eng/environment.yml" + -c "" ``` ### Generate the Conda Package diff --git a/eng/environment.yml b/eng/environment.yml index d17d4adc8171..960c090a9339 100644 --- a/eng/environment.yml +++ b/eng/environment.yml @@ -1,6 +1,2 @@ -channels: - - https://azuresdkconda.blob.core.windows.net/channel1/ - - defaults - variables: AZURESDK_CONDA_VERSION: '2021.05.01' diff --git a/eng/pipelines/templates/steps/build-conda-artifacts.yml b/eng/pipelines/templates/steps/build-conda-artifacts.yml index 1b1dc3275581..cb503c25dcb5 100644 --- a/eng/pipelines/templates/steps/build-conda-artifacts.yml +++ b/eng/pipelines/templates/steps/build-conda-artifacts.yml @@ -60,8 +60,8 @@ steps: -r "${{ artifact.common_root }}" -n "${{ artifact.name }}" -s "${{ parameters.ServiceDirectory }}" - -o "${{ upper(parameters.ServiceDirectory) }}_SOURCE_DISTRIBUTION" -e "$(Build.SourcesDirectory)/eng/environment.yml" + -c "$(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }}/ci.yml" - bash: | echo "##vso[task.prependpath]$CONDA/bin" @@ -72,13 +72,9 @@ steps: conda install --yes --quiet --name ${{ artifact.name }} conda-build displayName: 'Prepare Conda Environment for building ${{ artifact.name }}' - - pwsh: | - - displayName: 'Set Conda Version Variable' - - bash: | source activate ${{ artifact.name }} - conda-build . --output-folder "$(Agent.BuildDirectory)/conda/output" -c https://azuresdkconda.blob.core.windows.net/channel1/ + conda-build . --output-folder "$(Agent.BuildDirectory)/conda/output" -c $(AzureSDKCondaChannel) displayName: 'Activate Conda Environment and Build ${{ artifact.name }}' workingDirectory: $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }} diff --git a/eng/pipelines/templates/variables/globals.yml b/eng/pipelines/templates/variables/globals.yml index a9e52c921478..a949290954e9 100644 --- a/eng/pipelines/templates/variables/globals.yml +++ b/eng/pipelines/templates/variables/globals.yml @@ -1,3 +1,4 @@ variables: PythonVersion: '3.6' skipComponentGovernanceDetection: true + AzureSDKCondaChannel: https://azuresdkconda.blob.core.windows.net/channel1/ \ No newline at end of file diff --git a/scripts/devops_tasks/build_conda_artifacts.py b/scripts/devops_tasks/build_conda_artifacts.py index 1b513a1d0da6..9c1dd1df4da1 100644 --- a/scripts/devops_tasks/build_conda_artifacts.py +++ b/scripts/devops_tasks/build_conda_artifacts.py @@ -25,13 +25,18 @@ import os import shutil import re +import pdb from common_tasks import process_glob_string, run_check_call, str_to_bool, parse_setup from subprocess import check_call from distutils.dir_util import copy_tree +import yaml + VERSION_REGEX = re.compile(r"\s*AZURESDK_CONDA_VERSION\s*:\s*[\'](.*)[\']\s*") +SUMMARY_TEMPLATE = "- Generated from {}." + NAMESPACE_EXTENSION_TEMPLATE = """__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: str """ @@ -219,6 +224,23 @@ def create_combined_sdist( ) return output_location +def get_summary(ci_yml, artifact_name): + pkg_list = [] + with open(ci_yml, 'r') as f: + data = f.read() + + config = yaml.safe_load(data) + + conda_artifact = [conda_artifact for conda_artifact in config["extends"]["parameters"]["CondaArtifacts"] if conda_artifact["name"] == artifact_name] + + if conda_artifact: + dependencies = conda_artifact[0]["checkout"] + + for dep in dependencies: + pkg_list.append("{}=={}".format(dep["package"], dep["version"])) + + return SUMMARY_TEMPLATE.format(", ".join(pkg_list)) + if __name__ == "__main__": parser = argparse.ArgumentParser( @@ -273,22 +295,21 @@ def create_combined_sdist( required=True, ) - parser.add_argument( - "-o", - "--output_var", - dest="output_var", - help="The name of the environment variable that will be set in azure devops. The contents will be the final location of the output artifact. Local users will need to grab this value and set their env manually.", - required=False, - ) - parser.add_argument( "-e", "--environment_config", dest="environment_config", help="The location of the environment.yml used to create the conda environments. This file has necessary common configuration information within.", - required=False, + required=True, ) + parser.add_argument( + "-c", + "--ci_yml", + dest="ci_yml", + help="The location of the ci.yml that is used to define our conda artifacts. Used when to easily grab summary information.", + required=True, + ) args = parser.parse_args() output_source_location = create_combined_sdist( @@ -301,9 +322,19 @@ def create_combined_sdist( args.environment_config ) - if args.output_var: + summary = get_summary(args.ci_yml, args.artifact_name) + + if output_source_location: print( "##vso[task.setvariable variable={}]{}".format( - args.output_var, output_source_location + args.service.upper() + "_SOURCE_DISTRIBUTION", output_source_location ) ) + + if summary: + print( + "##vso[task.setvariable variable={}]{}".format( + args.service.upper() + "_SUMMARY", summary + ) + ) + diff --git a/sdk/core/meta.yaml b/sdk/core/meta.yaml index 3c3d045feb66..7d0ca118dd8a 100644 --- a/sdk/core/meta.yaml +++ b/sdk/core/meta.yaml @@ -38,10 +38,10 @@ about: license: MIT license_family: MIT license_file: - summary: {{ environ.get('AZURESDK_CONDA_SUMMARY', 'Microsoft Azure Core Library for Python') }} + summary: Microsoft Azure Core Library for Python{{ environ.get('CORE_SUMMARY', '') }} doc_url: dev_url: extra: recipe-maintainers: - - lmazuel,xiangyan99 + - lmazuel,xiangyan99,scbedd diff --git a/sdk/storage/ci.yml b/sdk/storage/ci.yml index 155e66da510f..a50fcfd3c3d5 100644 --- a/sdk/storage/ci.yml +++ b/sdk/storage/ci.yml @@ -39,7 +39,6 @@ extends: MatrixConfigs: - Name: storage_ci_matrix Path: eng/pipelines/templates/stages/platform-matrix-cryptography-dependency.json - GenerateDocs: False Selection: sparse GenerateVMJobs: true Artifacts: diff --git a/sdk/storage/meta.yaml b/sdk/storage/meta.yaml index ba9401ddaa62..4f311a6e090e 100644 --- a/sdk/storage/meta.yaml +++ b/sdk/storage/meta.yaml @@ -42,10 +42,10 @@ about: license: MIT license_family: MIT license_file: - summary: {{ environ.get('AZURESDK_CONDA_SUMMARY', 'Microsoft Azure Storage Client Library for Python') }} + summary: Microsoft Azure Storage Client Library for Python{{ environ.get('STORAGE_SUMMARY', '') }} doc_url: dev_url: extra: recipe-maintainers: - - your-github-id-here + - lmazuel,xiangyan99,scbedd From b48ddbee459158eff257b89aab8bec1120bf6ba8 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Tue, 20 Apr 2021 14:42:04 -0700 Subject: [PATCH 7/8] rename environment yaml. remove pdb from build_conda_artifacts --- eng/{environment.yml => conda_env.yml} | 0 .../templates/steps/build-conda-artifacts.yml | 4 +- scripts/devops_tasks/build_conda_artifacts.py | 47 +++++++++++++------ 3 files changed, 35 insertions(+), 16 deletions(-) rename eng/{environment.yml => conda_env.yml} (100%) diff --git a/eng/environment.yml b/eng/conda_env.yml similarity index 100% rename from eng/environment.yml rename to eng/conda_env.yml diff --git a/eng/pipelines/templates/steps/build-conda-artifacts.yml b/eng/pipelines/templates/steps/build-conda-artifacts.yml index cb503c25dcb5..bcaec17a22e3 100644 --- a/eng/pipelines/templates/steps/build-conda-artifacts.yml +++ b/eng/pipelines/templates/steps/build-conda-artifacts.yml @@ -60,7 +60,7 @@ steps: -r "${{ artifact.common_root }}" -n "${{ artifact.name }}" -s "${{ parameters.ServiceDirectory }}" - -e "$(Build.SourcesDirectory)/eng/environment.yml" + -e "$(Build.SourcesDirectory)/eng/conda_env.yml" -c "$(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }}/ci.yml" - bash: | @@ -68,7 +68,7 @@ steps: displayName: 'Prepend PATH with Conda and INIT' - bash: | - conda env create --name ${{ artifact.name }} --file $(Build.SourcesDirectory)/eng/environment.yml + conda env create --name ${{ artifact.name }} --file $(Build.SourcesDirectory)/eng/conda_env.yml conda install --yes --quiet --name ${{ artifact.name }} conda-build displayName: 'Prepare Conda Environment for building ${{ artifact.name }}' diff --git a/scripts/devops_tasks/build_conda_artifacts.py b/scripts/devops_tasks/build_conda_artifacts.py index 9c1dd1df4da1..ac071de6ebef 100644 --- a/scripts/devops_tasks/build_conda_artifacts.py +++ b/scripts/devops_tasks/build_conda_artifacts.py @@ -25,14 +25,12 @@ import os import shutil import re -import pdb +import yaml from common_tasks import process_glob_string, run_check_call, str_to_bool, parse_setup from subprocess import check_call from distutils.dir_util import copy_tree -import yaml - VERSION_REGEX = re.compile(r"\s*AZURESDK_CONDA_VERSION\s*:\s*[\'](.*)[\']\s*") SUMMARY_TEMPLATE = "- Generated from {}." @@ -147,6 +145,7 @@ def create_sdist_skeleton(build_directory, artifact_name, common_root): dest = os.path.join(ns_dir, directory) shutil.copytree(src, dest) + def get_version_from_config(environment_config): with open(os.path.abspath((environment_config)), "r") as f: lines = f.readlines() @@ -156,6 +155,7 @@ def get_version_from_config(environment_config): return result.group(1) return "0.0.0" + def get_manifest_includes(common_root): levels = common_root.split("/") breadcrumbs = [] @@ -168,7 +168,9 @@ def get_manifest_includes(common_root): return breadcrumbs -def create_setup_files(build_directory, common_root, artifact_name, service, meta_yaml, environment_config): +def create_setup_files( + build_directory, common_root, artifact_name, service, meta_yaml, environment_config +): sdist_directory = os.path.join(build_directory, artifact_name) setup_location = os.path.join(sdist_directory, "setup.py") manifest_location = os.path.join(sdist_directory, "MANIFEST.in") @@ -185,7 +187,9 @@ def create_setup_files(build_directory, common_root, artifact_name, service, met f.write(setup_template) manifest_template = MANIFEST_TEMPLATE.format( - namespace_includes="\n".join(["include " + ns for ns in get_manifest_includes(common_root)]) + namespace_includes="\n".join( + ["include " + ns for ns in get_manifest_includes(common_root)] + ) ) with open(manifest_location, "w") as f: @@ -196,7 +200,13 @@ def create_setup_files(build_directory, common_root, artifact_name, service, met def create_combined_sdist( - output_directory, build_directory, artifact_name, common_root, service, meta_yaml, environment_config + output_directory, + build_directory, + artifact_name, + common_root, + service, + meta_yaml, + environment_config, ): singular_dependency = ( len(get_pkgs_from_build_directory(build_directory, artifact_name)) == 0 @@ -205,7 +215,12 @@ def create_combined_sdist( if not singular_dependency: create_sdist_skeleton(build_directory, artifact_name, common_root) create_setup_files( - build_directory, common_root, artifact_name, service, meta_yaml, environment_config + build_directory, + common_root, + artifact_name, + service, + meta_yaml, + environment_config, ) sdist_location = os.path.join(build_directory, artifact_name) @@ -224,21 +239,26 @@ def create_combined_sdist( ) return output_location + def get_summary(ci_yml, artifact_name): pkg_list = [] - with open(ci_yml, 'r') as f: - data = f.read() - + with open(ci_yml, "r") as f: + data = f.read() + config = yaml.safe_load(data) - conda_artifact = [conda_artifact for conda_artifact in config["extends"]["parameters"]["CondaArtifacts"] if conda_artifact["name"] == artifact_name] + conda_artifact = [ + conda_artifact + for conda_artifact in config["extends"]["parameters"]["CondaArtifacts"] + if conda_artifact["name"] == artifact_name + ] if conda_artifact: dependencies = conda_artifact[0]["checkout"] for dep in dependencies: pkg_list.append("{}=={}".format(dep["package"], dep["version"])) - + return SUMMARY_TEMPLATE.format(", ".join(pkg_list)) @@ -319,7 +339,7 @@ def get_summary(ci_yml, artifact_name): args.common_root, args.service, args.meta_yml, - args.environment_config + args.environment_config, ) summary = get_summary(args.ci_yml, args.artifact_name) @@ -337,4 +357,3 @@ def get_summary(ci_yml, artifact_name): args.service.upper() + "_SUMMARY", summary ) ) - From 366ecb34b8abbd7298876983d55fee749d2e7a91 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Tue, 20 Apr 2021 15:34:47 -0700 Subject: [PATCH 8/8] catch all cases of environment.yml in the documentation --- doc/dev/conda-builds.md | 9 +++++---- scripts/devops_tasks/build_conda_artifacts.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/dev/conda-builds.md b/doc/dev/conda-builds.md index feff7267d149..152156bf67ad 100644 --- a/doc/dev/conda-builds.md +++ b/doc/dev/conda-builds.md @@ -20,15 +20,16 @@ A Conda Artifact defines: You will notice that all the azure-sdk conda distributions have the **same** version number and requirement set. This is due to the fact that the azure-sdk team pushes our conda packages out in waves. To support this, all versions are set via a common environment variable `AZURESDK_CONDA_VERSION`. -We keep this environment variable set properly across all our builds by using a common `environment.yml` when creating our build environment. This environment definition ensures that +We keep this environment variable set properly across all our builds by using a common `conda_env.yml` when creating our build environment. This environment definition ensures that: 1. Our channel `https://azuresdkconda.blob.core.windows.net/channel1/` is added to the set to download packages 2. The environment variable `AZURESDK_CONDA_VERSION` will be set exactly once. -Reference the `environment.yml` in your local build by pass `-f ` when you create your conda environment. +Reference the `conda_env.yml` in your local build by pass `-f ` when you create your conda environment. + ``` -conda env create --yes --quiet --name ${{ artifact.name }} -f $(Build.SourcesDirectory)/eng/environment.yml +conda env create --yes --quiet --name ${{ artifact.name }} -f $(Build.SourcesDirectory)/eng/conda_env.yml ``` ### Create Your Build Directory @@ -98,7 +99,7 @@ python `build_conda_artifacts.py` -r "azure/storage" -n "azure-storage" -s "storage" - -e "/eng/environment.yml" + -e "/eng/conda_env.yml" -c "" ``` diff --git a/scripts/devops_tasks/build_conda_artifacts.py b/scripts/devops_tasks/build_conda_artifacts.py index ac071de6ebef..090932f56192 100644 --- a/scripts/devops_tasks/build_conda_artifacts.py +++ b/scripts/devops_tasks/build_conda_artifacts.py @@ -319,7 +319,7 @@ def get_summary(ci_yml, artifact_name): "-e", "--environment_config", dest="environment_config", - help="The location of the environment.yml used to create the conda environments. This file has necessary common configuration information within.", + help="The location of the yml config file used to create the conda environments. This file has necessary common configuration information within.", required=True, )