From 4a0a918fd25e668ddc74803f703fc458ad31e7e4 Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Wed, 20 Oct 2021 09:23:13 -0700 Subject: [PATCH] feat(//py): Add the git revision to non release builds Signed-off-by: Naren Dasan Signed-off-by: Naren Dasan --- .github/workflows/docgen.yml | 1 + .gitignore | 6 ++++++ docker/Dockerfile.docs | 2 +- py/build_whl.sh | 8 ++++---- py/setup.py | 13 +++++++++++-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docgen.yml b/.github/workflows/docgen.yml index eca50fbcf5..b4a2b26f5a 100644 --- a/.github/workflows/docgen.yml +++ b/.github/workflows/docgen.yml @@ -36,6 +36,7 @@ jobs: - name: Generate New Docs run: | cd docsrc + python3 -c "import trtorch; print(trtorch.__version__)" make html - uses: stefanzweifel/git-auto-commit-action@v4 with: diff --git a/.gitignore b/.gitignore index c20384b979..cfc7a06484 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,12 @@ __pycache__ dist bdist py/trtorch/_version.py +py/trtorch/lib +py/trtorch/include +py/trtorch/bin +py/trtorch/BUILD +py/trtorch/LICENSE +py/trtorch/WORKSPACE py/wheelhouse py/.eggs notebooks/.ipynb_checkpoints/ diff --git a/docker/Dockerfile.docs b/docker/Dockerfile.docs index 7256e54c73..2077caaaad 100644 --- a/docker/Dockerfile.docs +++ b/docker/Dockerfile.docs @@ -3,7 +3,7 @@ FROM nvcr.io/nvidia/tensorrt:21.02-py3 RUN curl https://bazel.build/bazel-release.pub.gpg | apt-key add - RUN echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list -RUN apt-get update && apt-get install -y bazel-4.0.0 clang-format-9 +RUN apt-get update && apt-get install -y bazel-4.0.0 clang-format-9 libjpeg9 libjpeg9-dev RUN ln -s /usr/bin/bazel-4.0.0 /usr/bin/bazel RUN ln -s $(which clang-format-9) /usr/bin/clang-format diff --git a/py/build_whl.sh b/py/build_whl.sh index 6ec27a8c31..4b650c7c7e 100755 --- a/py/build_whl.sh +++ b/py/build_whl.sh @@ -8,25 +8,25 @@ export CXX=g++ build_py36() { /opt/python/cp36-cp36m/bin/python -m pip install -r requirements.txt - /opt/python/cp36-cp36m/bin/python setup.py bdist_wheel + /opt/python/cp36-cp36m/bin/python setup.py bdist_wheel --release #auditwheel repair --plat manylinux2014_x86_64 } build_py37() { /opt/python/cp37-cp37m/bin/python -m pip install -r requirements.txt - /opt/python/cp37-cp37m/bin/python setup.py bdist_wheel + /opt/python/cp37-cp37m/bin/python setup.py bdist_wheel --release #auditwheel repair --plat manylinux2014_x86_64 } build_py38() { /opt/python/cp38-cp38/bin/python -m pip install -r requirements.txt - /opt/python/cp38-cp38/bin/python setup.py bdist_wheel + /opt/python/cp38-cp38/bin/python setup.py bdist_wheel --release #auditwheel repair --plat manylinux2014_x86_64 } build_py39() { /opt/python/cp39-cp39/bin/python -m pip install -r requirements.txt - /opt/python/cp39-cp39/bin/python setup.py bdist_wheel + /opt/python/cp39-cp39/bin/python setup.py bdist_wheel --release #auditwheel repair --plat manylinux2014_x86_64 } diff --git a/py/setup.py b/py/setup.py index e4d846b892..2a8e0c647e 100644 --- a/py/setup.py +++ b/py/setup.py @@ -18,12 +18,21 @@ dir_path = os.path.dirname(os.path.realpath(__file__)) -__version__ = '0.5.0a0' - CXX11_ABI = False JETPACK_VERSION = None +__version__ = '0.5.0a0' + +def get_git_revision_short_hash() -> str: + return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() + +if "--release" not in sys.argv: + __version__ = __version__ + "+" + get_git_revision_short_hash() +else: + sys.argv.remove("--release") + + if "--use-cxx11-abi" in sys.argv: sys.argv.remove("--use-cxx11-abi") CXX11_ABI = True