From 2fb60676a91e42d64a7f7e3e18943c5f900bcd8e Mon Sep 17 00:00:00 2001 From: odidev Date: Tue, 31 Aug 2021 13:38:15 +0530 Subject: [PATCH] Add Linux AArch64 wheel build support --- .circleci/config.yml | 45 ++++++++++++++++++++++++ ci/docker/manylinux/Dockerfile.aarch64 | 27 +++++++++++++++ ci/travis/build-manylinux.sh | 8 ++++- ssh2/_version.py | 48 +++----------------------- 4 files changed, 83 insertions(+), 45 deletions(-) create mode 100644 ci/docker/manylinux/Dockerfile.aarch64 diff --git a/.circleci/config.yml b/.circleci/config.yml index bad5157a..676dc895 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -111,6 +111,44 @@ jobs: command: | twine upload --skip-existing -u $PYPI_USER -p $PYPI_PASSWORD dist/* wheelhouse/* + manylinux2014-aarch64: + machine: + image: ubuntu-2004:202101-01 + resource_class: arm.medium + steps: + - checkout + - python/load-cache: + key: manylinuxdepsv6-{{ .Branch }}.{{ arch }} + dependency-file: requirements_dev.txt + - run: + name: Git LFS + command: | + curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash + sudo apt-get install git-lfs + git lfs install + git lfs pull + - run: + name: Deps + command: | + sudo apt-get install python3-pip + pip3 install -U pip + pip3 install twine + which twine + - python/save-cache: + key: manylinuxdepsv6-{{ .Branch }}.{{ arch }} + dependency-file: requirements_dev.txt + - run: + name: Build Wheels + command: | + if [[ -z "${CIRCLE_PULL_REQUEST}" ]]; then + docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" ; + fi + ./ci/travis/build-manylinux.sh + - run: + name: Upload Wheels + command: | + twine upload --skip-existing -u $PYPI_USER -p $PYPI_PASSWORD dist/* wheelhouse/* + workflows: version: 2.1 main: @@ -132,6 +170,13 @@ workflows: only: /.*/ branches: ignore: /.*/ + - manylinux2014-aarch64: + context: Docker + #filters: + # tags: + # only: /.*/ + # branches: + # ignore: /.*/ - osx: matrix: parameters: diff --git a/ci/docker/manylinux/Dockerfile.aarch64 b/ci/docker/manylinux/Dockerfile.aarch64 new file mode 100644 index 00000000..9111ae8a --- /dev/null +++ b/ci/docker/manylinux/Dockerfile.aarch64 @@ -0,0 +1,27 @@ +FROM quay.io/pypa/manylinux2014_aarch64 + +ENV OPENSSL openssl-1.1.1g +ENV SYSTEM_LIBSSH2 1 +ENV LIBSSH2_VERSION 1.9.0 + +RUN yum install zlib-devel -y + +ADD libssh2-${LIBSSH2_VERSION}.tar.gz libssh2-${LIBSSH2_VERSION}.tar.gz +ADD https://www.openssl.org/source/${OPENSSL}.tar.gz ${OPENSSL}.tar.gz + +RUN tar -xzf ${OPENSSL}.tar.gz +# Openssl +RUN cd ${OPENSSL} && \ + ./config --prefix=/usr --openssldir=/usr/openssl threads shared && \ + make -j4 && make install + +# Libssh2 +RUN mkdir -p build_libssh2 && cd build_libssh2 && \ + cmake ../libssh2-${LIBSSH2_VERSION}.tar.gz/libssh2-libssh2-${LIBSSH2_VERSION} \ + -DBUILD_SHARED_LIBS=ON -DENABLE_ZLIB_COMPRESSION=ON \ + -DENABLE_CRYPT_NONE=ON -DENABLE_MAC_NONE=ON -DCMAKE_INSTALL_PREFIX=/usr && \ + cmake --build . --config Release --target install + +RUN rm -rf ${OPENSSL}* build_libssh2 libssh2.tar.gz + +VOLUME /var/cache diff --git a/ci/travis/build-manylinux.sh b/ci/travis/build-manylinux.sh index 9ec17450..2ecea948 100755 --- a/ci/travis/build-manylinux.sh +++ b/ci/travis/build-manylinux.sh @@ -1,12 +1,18 @@ #!/bin/bash -xe docker_tag="parallelssh/ssh2-manylinux" +docker_file="ci/docker/manylinux/Dockerfile" rm -rf build ssh2/libssh2.* python ci/appveyor/fix_version.py . +if [[ `uname -m` == "aarch64" ]]; then + docker_tag=${docker_tag}-aarch64 + docker_file=${docker_file}.aarch64 +fi + docker pull $docker_tag || echo -docker build --cache-from $docker_tag ci/docker/manylinux -t $docker_tag +docker build --cache-from $docker_tag ci/docker/manylinux -t $docker_tag -f ${docker_file} if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then docker push $docker_tag; fi docker run -e TRAVIS_TAG="$TRAVIS_TAG" --rm -v `pwd`:/io $docker_tag /io/ci/travis/build-wheels.sh ls wheelhouse/ diff --git a/ssh2/_version.py b/ssh2/_version.py index 1c3945e4..b956c75f 100644 --- a/ssh2/_version.py +++ b/ssh2/_version.py @@ -473,48 +473,8 @@ def render(pieces, style): "dirty": pieces["dirty"], "error": None, "date": pieces.get("date")} - +import json +version_json = ''' +"0.99.0"''' # END VERSION_JSON def get_versions(): - """Get version information or return default if unable to do so.""" - # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have - # __file__, we can work backwards from there to the root. Some - # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which - # case we can only use expanded keywords. - - cfg = get_config() - verbose = cfg.verbose - - try: - return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, - verbose) - except NotThisMethod: - pass - - try: - root = os.path.realpath(__file__) - # versionfile_source is the relative path from the top of the source - # tree (where the .git directory might live) to this file. Invert - # this to find the root from __file__. - for i in cfg.versionfile_source.split('/'): - root = os.path.dirname(root) - except NameError: - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to find root of source tree", - "date": None} - - try: - pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) - return render(pieces, cfg.style) - except NotThisMethod: - pass - - try: - if cfg.parentdir_prefix: - return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) - except NotThisMethod: - pass - - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to compute version", "date": None} + return json.loads(version_json)