diff --git a/.azure/azp-template-wheels.yml b/.azure/azp-template-wheels.yml deleted file mode 100644 index 41be4376..00000000 --- a/.azure/azp-template-wheels.yml +++ /dev/null @@ -1,55 +0,0 @@ -# This azure pipeline template build wheels - -parameters: - name: '' - python: '' - -jobs: - -- job: 'Wheels_${{ parameters.name }}' - condition: eq(variables['Build.SourceBranchName'], 'dev') - timeoutInMinutes: 360 - pool: - vmImage: 'ubuntu-latest' - strategy: - maxParallel: 3 - matrix: - amd64: - buildArch: 'amd64' - i386: - buildArch: 'i386' - armhf: - buildArch: 'armhf' - armv7: - buildArch: 'armv7' - aarch64: - buildArch: 'aarch64' - steps: - - script: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - qemu-user-static \ - binfmt-support \ - curl - - sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc - sudo update-binfmts --enable qemu-arm - sudo update-binfmts --enable qemu-aarch64 - displayName: 'Initial cross build' - - script: | - mkdir -p .ssh - echo -e "-----BEGIN RSA PRIVATE KEY-----\n$(wheelsSSH)\n-----END RSA PRIVATE KEY-----" >> .ssh/id_rsa - ssh-keyscan -H $(wheelsHost) >> .ssh/known_hosts - chmod 600 .ssh/* - displayName: 'Install ssh key' - - script: sudo docker pull homeassistant/$(buildArch)-wheels:dev-${{ parameters.python }} - displayName: 'Install wheels builder' - - script: | - sudo docker run --rm -v $(pwd):/data:ro -v $(pwd)/.ssh:/root/.ssh:rw \ - homeassistant/$(buildArch)-wheels:dev-${{ parameters.python }} \ - --apk "build-base;libffi-dev;openssl-dev" \ - --index $(wheelsIndex) \ - --requirement requirements.txt \ - --upload rsync \ - --remote wheels@$(wheelsHost):/opt/wheels - displayName: 'Run wheels build' diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b8ee79e2..f9b67f00 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -19,7 +19,12 @@ variables: - name: versionBuilder value: '4.4' - group: docker - - group: wheels +resources: + repositories: + - repository: azure + type: github + name: 'home-assistant/ci-azure' + endpoint: 'home-assistant' jobs: @@ -64,38 +69,32 @@ jobs: displayName: 'Run Black' -- template: .azure/azp-template-wheels.yml +- template: templates/azp-job-wheels.yaml@azure parameters: - name: '37_Alpine39' - python: '3.7-alpine3.9' - - -- template: .azure/azp-template-wheels.yml + jobName: 'Wheels_Alpine39' + builderVersion: 'dev-3.7-alpine3.9' + builderApk: 'build-base;libffi-dev;openssl-dev' + wheelsRequirement: 'requirements_all.txt' + preBuild: + - script: | + cat requirements.txt requirements_build.txt > requirements_all.txt + displayName: 'Prepare requirements' + +- template: templates/azp-job-wheels.yaml@azure parameters: - name: '37_Alpine310' - python: '3.7-alpine3.10' - + jobName: 'Wheels_Alpine310' + builderVersion: 'dev-3.7-alpine3.10' + builderApk: 'build-base;libffi-dev;openssl-dev' + wheelsRequirement: 'requirements_all.txt' + preBuild: + - script: | + cat requirements.txt requirements_build.txt > requirements_all.txt + displayName: 'Prepare requirements' -- job: 'VersionValidate' - condition: or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), eq(variables['Build.SourceBranchName'], 'dev')) - pool: - vmImage: 'ubuntu-latest' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.7' - inputs: - versionSpec: '3.7' - - script: | - setup_version="$(python setup.py -V)" - branch_version="$(Build.SourceBranchName)" - if [ "${branch_version}" == "dev" ]; then - exit 0 - elif [ "${setup_version}" != "${branch_version}" ]; then - echo "Version of tag ${branch_version} don't match with ${setup_version}!" - exit 1 - fi - displayName: 'Check version of branch/tag' +- template: templates/azp-job-version.yaml@azure + parameters: + ignoreDev: true - job: 'Release' diff --git a/builder/__main__.py b/builder/__main__.py index aff91813..bf216787 100644 --- a/builder/__main__.py +++ b/builder/__main__.py @@ -16,6 +16,7 @@ build_wheels_package, build_wheels_requirement, extract_packages, + install_pips, write_requirement, ) from builder.upload import run_upload @@ -24,6 +25,7 @@ @click.command("builder") @click.option("--apk", default="build-base", help="APKs they are needed to build this.") +@click.option("--pip", default="Cython", help="PiPy modules needed to build this.") @click.option("--index", required=True, help="Index URL of remote wheels repository.") @click.option( "--requirement", @@ -55,6 +57,7 @@ ) def builder( apk: str, + pip: str, index: str, requirement: Optional[Path], requirement_diff: Optional[Path], @@ -75,6 +78,9 @@ def builder( wheels_dir = create_wheels_folder(output) wheels_index = create_wheels_index(index) + # Setup build helper + install_pips(wheels_index, pip) + if local: # Build wheels in a local folder/src build_wheels_local(wheels_index, wheels_dir) diff --git a/builder/pip.py b/builder/pip.py index 092c5134..9a59555f 100644 --- a/builder/pip.py +++ b/builder/pip.py @@ -96,3 +96,18 @@ def extract_packages( def write_requirement(requirement: Path, packages: List[str]) -> None: """Write packages list to a requirement file.""" requirement.write_text("\n".join(packages)) + + +def install_pips(index: str, pips: str) -> None: + """Install all pipy string formated as 'package1;package2'.""" + packages = " ".join(pips.split(";")) + + result = subprocess.run( + f"pip install --upgrade --no-cache-dir --prefer-binary --find-links {index} {packages}", + shell=True, + stdout=sys.stdout, + stderr=sys.stderr, + ) + + # Check result of program + result.check_returncode() diff --git a/requirements.txt b/requirements.txt index 4abfbc53..0eadd2a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ click==7.0 click-pathlib==2019.6.13.1 requests==2.22.0 -Cython==0.29.13 wheel==0.33.6 diff --git a/requirements_build.txt b/requirements_build.txt new file mode 100644 index 00000000..86a56194 --- /dev/null +++ b/requirements_build.txt @@ -0,0 +1,2 @@ +Cython==0.29.13 +numpy==1.17.1 diff --git a/setup.py b/setup.py index 42f838a5..af5ee20e 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -VERSION = "1.2" +VERSION = "1.3" setup( name="builder",