Repository: Esri/pyprt-examples (language: python)

Issue:
Prepare release 1.8.0



Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 376a153..1b93a31 100644
--- a/README.md
+++ b/README.md
@@ -25,11 +25,9 @@ This repo contains examples of PyPRT usage. You can find installation instructio
 ## Requirements
 
 * Windows 10/11 64bit or Linux 64bit (RHEL 7/8/9 and compatible distributions)
-* Python 3.7 64bit or later. Please note, we currently provide PyPRT builds for Python 3.7 (only Windows), 3.8, 3.9 and 3.10(*). For other Python versions, please [build](https://github.com/Esri/pyprt) PyPRT yourself.
+* Python 3.8 64bit or later. Please note, we currently provide PyPRT builds for Python 3.8, 3.9, 3.10 and 3.11. For other Python versions, please [build](https://github.com/Esri/pyprt) PyPRT yourself.
 * Required Python packages: see `envs` directory
 
-(*) A note regarding Python 3.10: The arcgis package is [not yet available for Python 3.10](https://developers.arcgis.com/python/guide/system-requirements/), therefore the examples 8, 9 and 10 are not yet supported with Python 3.10.
-
 ## Running the examples
 
 PyPRT can be installed with `pip install pyprt` or `conda install -c esri pyprt`. To run the examples a few more packages are required, so please read on! :-)
@@ -57,7 +55,7 @@ PyPRT can be installed with `pip install pyprt` or `conda install -c esri pyprt`
 ### Alternative: using Anaconda
 
 1. Open the Anaconda prompt and change to the directory where you checked out this repository.
-1. Ensure you have a working Anaconda Python 3.8, 3.9 or 3.10 64bit installation (or additionally Python 3.7 on Windows). For other Python versions, please [build](https://github.com/Esri/pyprt) PyPRT yourself at the moment.
+1. Ensure you have a working Anaconda Python 64bit installation, e.g. for Python 3.8.
 1. Run `conda env create --prefix env --file envs/environment-py38.yml` to install PyPRT and all dependencies for the examples (replace `py38` with the used Python version).
    * In case `conda env create` takes very long or runs into errors, try to remove `arcgis` from `environment-pyXX.yml` and manually call `conda install --prefix env -c esri arcgis`. 
 1. Activate the Anaconda environment: `conda activate ./env`
diff --git a/envs/environment-py310.yml b/envs/environment-py310.yml
index be5e059..7093989 100644
--- a/envs/environment-py310.yml
+++ b/envs/environment-py310.yml
@@ -4,12 +4,19 @@ channels:
 dependencies:
   - python=3.10
   - esri::pyprt
+  - esri::arcgis
+  - numpy
+  - pandas
+  - pyqt
   - scipy
-  - conda-forge::vispy
+  - shapely
+  - notebook<7.0
+  - ipywidgets
+  - conda-forge::vtk>=9.2
   - conda-forge::pyvista
-  - conda-forge::ipyvtklink
   - conda-forge::trame
-  - notebook
-  - pandas
-  - pyqt
-  - numpy<1.24.0
+  - conda-forge::trame-vtk
+  - conda-forge::trame-vuetify
+  - conda-forge::vispy
+  - conda-forge::ipyvtklink
+  
\ No newline at end of file
diff --git a/envs/environment-py37.yml b/envs/environment-py311.yml
similarity index 52%
rename from envs/environment-py37.yml
rename to envs/environment-py311.yml
index fdb3217..0eb3565 100644
--- a/envs/environment-py37.yml
+++ b/envs/environment-py311.yml
@@ -1,16 +1,21 @@
-name: pyprt-examples-py37
+name: pyprt-examples-py311
 channels:
   - defaults
 dependencies:
-  - python=3.7
+  - python=3.11
   - esri::pyprt
   - esri::arcgis
+  - numpy
+  - pandas
+  - pyqt
   - scipy
   - shapely
-  - conda-forge::vispy
+  - notebook<7.0
+  - ipywidgets
+  - conda-forge::vtk>=9.2
   - conda-forge::pyvista
-  - conda-forge::ipyvtklink
   - conda-forge::trame
-  - notebook
-  - pyqt
-  - numpy<1.24.0
+  - conda-forge::trame-vtk
+  - conda-forge::trame-vuetify
+  - conda-forge::vispy
+  - conda-forge::ipyvtklink
diff --git a/envs/environment-py38.yml b/envs/environment-py38.yml
index 8987c69..a7477ba 100644
--- a/envs/environment-py38.yml
+++ b/envs/environment-py38.yml
@@ -5,12 +5,17 @@ dependencies:
   - python=3.8
   - esri::pyprt
   - esri::arcgis
+  - numpy<1.22
+  - pandas
+  - pyqt
   - scipy
   - shapely
-  - conda-forge::vispy
+  - notebook<7.0
+  - ipywidgets
+  - conda-forge::vtk>=9.2
   - conda-forge::pyvista
-  - conda-forge::ipyvtklink
   - conda-forge::trame
-  - notebook
-  - pyqt
-  - numpy<1.24.0
+  - conda-forge::trame-vtk
+  - conda-forge::trame-vuetify
+  - conda-forge::vispy
+  - conda-forge::ipyvtklink
diff --git a/envs/environment-py39.yml b/envs/environment-py39.yml
index 6503cb1..8b5bb6e 100644
--- a/envs/environment-py39.yml
+++ b/envs/environment-py39.yml
@@ -5,12 +5,17 @@ dependencies:
   - python=3.9
   - esri::pyprt
   - esri::arcgis
+  - numpy
+  - pandas
+  - pyqt
   - scipy
   - shapely
-  - conda-forge::vispy
+  - notebook<7.0
+  - ipywidgets
+  - conda-forge::vtk>=9.2
   - conda-forge::pyvista
-  - conda-forge::ipyvtklink
   - conda-forge::trame
-  - notebook
-  - pyqt
-  - numpy<1.24.0
+  - conda-forge::trame-vtk
+  - conda-forge::trame-vuetify
+  - conda-forge::vispy
+  - conda-forge::ipyvtklink
diff --git a/envs/linux/requirements-py310.txt b/envs/linux/requirements-py310.txt
index 1bb0670..047066a 100644
--- a/envs/linux/requirements-py310.txt
+++ b/envs/linux/requirements-py310.txt
@@ -1,11 +1,11 @@
-ipyvtklink
+arcgis
 notebook
-nbextensions
+numpy
 pandas
 PyPRT
 PyQt5
-pyvista
-trame
+pyvista[jupyter]
 scipy
+Shapely
 tornado
 vispy
diff --git a/envs/linux/requirements-py311.txt b/envs/linux/requirements-py311.txt
new file mode 100644
index 0000000..047066a
--- /dev/null
+++ b/envs/linux/requirements-py311.txt
@@ -0,0 +1,11 @@
+arcgis
+notebook
+numpy
+pandas
+PyPRT
+PyQt5
+pyvista[jupyter]
+scipy
+Shapely
+tornado
+vispy
diff --git a/envs/linux/requirements-py38.txt b/envs/linux/requirements-py38.txt
index cf47418..047066a 100644
--- a/envs/linux/requirements-py38.txt
+++ b/envs/linux/requirements-py38.txt
@@ -1,14 +1,11 @@
 arcgis
-urllib3<1.26.0
-ipyvtklink
 notebook
-nbextensions
+numpy
+pandas
 PyPRT
 PyQt5
-pyvista
-trame
+pyvista[jupyter]
 scipy
 Shapely
 tornado
 vispy
-numpy<1.24.0
\ No newline at end of file
diff --git a/envs/linux/requirements-py39.txt b/envs/linux/requirements-py39.txt
index cf47418..047066a 100644
--- a/envs/linux/requirements-py39.txt
+++ b/envs/linux/requirements-py39.txt
@@ -1,14 +1,11 @@
 arcgis
-urllib3<1.26.0
-ipyvtklink
 notebook
-nbextensions
+numpy
+pandas
 PyPRT
 PyQt5
-pyvista
-trame
+pyvista[jupyter]
 scipy
 Shapely
 tornado
 vispy
-numpy<1.24.0
\ No newline at end of file
diff --git a/envs/windows/requirements-py310.txt b/envs/windows/requirements-py310.txt
index 1bb0670..047066a 100644
--- a/envs/windows/requirements-py310.txt
+++ b/envs/windows/requirements-py310.txt
@@ -1,11 +1,11 @@
-ipyvtklink
+arcgis
 notebook
-nbextensions
+numpy
 pandas
 PyPRT
 PyQt5
-pyvista
-trame
+pyvista[jupyter]
 scipy
+Shapely
 tornado
 vispy
diff --git a/envs/windows/requirements-py311.txt b/envs/windows/requirements-py311.txt
new file mode 100644
index 0000000..047066a
--- /dev/null
+++ b/envs/windows/requirements-py311.txt
@@ -0,0 +1,11 @@
+arcgis
+notebook
+numpy
+pandas
+PyPRT
+PyQt5
+pyvista[jupyter]
+scipy
+Shapely
+tornado
+vispy
diff --git a/envs/windows/requirements-py37.txt b/envs/windows/requirements-py37.txt
deleted file mode 100644
index cf47418..0000000
--- a/envs/windows/requirements-py37.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-arcgis
-urllib3<1.26.0
-ipyvtklink
-notebook
-nbextensions
-PyPRT
-PyQt5
-pyvista
-trame
-scipy
-Shapely
-tornado
-vispy
-numpy<1.24.0
\ No newline at end of file
diff --git a/envs/windows/requirements-py38.txt b/envs/windows/requirements-py38.txt
index cf47418..047066a 100644
--- a/envs/windows/requirements-py38.txt
+++ b/envs/windows/requirements-py38.txt
@@ -1,14 +1,11 @@
 arcgis
-urllib3<1.26.0
-ipyvtklink
 notebook
-nbextensions
+numpy
+pandas
 PyPRT
 PyQt5
-pyvista
-trame
+pyvista[jupyter]
 scipy
 Shapely
 tornado
 vispy
-numpy<1.24.0
\ No newline at end of file
diff --git a/envs/windows/requirements-py39.txt b/envs/windows/requirements-py39.txt
index 9ecff8a..047066a 100644
--- a/envs/windows/requirements-py39.txt
+++ b/envs/windows/requirements-py39.txt
@@ -1,14 +1,11 @@
 arcgis
-urllib3<1.26.0
-ipyvtklink
 notebook
-nbextensions
+numpy
+pandas
 PyPRT
 PyQt5
-pyvista
-trame
+pyvista[jupyter]
 scipy
 Shapely
 tornado
 vispy
-numpy<1.24.0
diff --git a/ex10_update_scene_layer_package.py b/ex10_update_scene_layer_package.py
index bb0e0ae..00dfaf4 100644
--- a/ex10_update_scene_layer_package.py
+++ b/ex10_update_scene_layer_package.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2023 Esri R&D Center Zurich
+# Copyright (c) 2012-2024 Esri R&D Center Zurich
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
diff --git a/ex1_python_encoder.py b/ex1_python_encoder.py
index 4a7e6e7..cb52d81 100644
--- a/ex1_python_encoder.py
+++ b/ex1_python_encoder.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2023 Esri R&D Center Zurich
+# Copyright (c) 2012-2024 Esri R&D Center Zurich
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
diff --git a/ex2_obj_initial_shape.py b/ex2_obj_initial_shape.py
index 69ef65b..558240b 100644
--- a/ex2_obj_initial_shape.py
+++ b/ex2_obj_initial_shape.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2023 Esri R&D Center Zurich
+# Copyright (c) 2012-2024 Esri R&D Center Zurich
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
diff --git a/ex3_format_exporter.py b/ex3_format_exporter.py
index daa7e43..99a76fd 100644
--- a/ex3_format_exporter.py
+++ b/ex3_format_exporter.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2023 Esri R&D Center Zurich
+# Copyright (c) 2012-2024 Esri R&D Center Zurich
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
diff --git a/ex4_multi_generations.py b/ex4_multi_generations.py
index 6384462..f29fb59 100644
--- a/ex4_multi_generations.py
+++ b/ex4_multi_generations.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2023 Esri R&D Center Zurich
+# Copyright (c) 2012-2024 Esri R&D Center Zurich
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
diff --git a/ex5_dataset_collection.ipynb b/ex5_dataset_collection.ipynb
index d4bd2c7..2a1e4d8 100644
--- a/ex5_dataset_collection.ipynb
+++ b/ex5_dataset_collection.ipynb
@@ -4,7 +4,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Copyright (c) 2012-2023 Esri R&D Center Zurich\n",
+    "Copyright (c) 2012-2024 Esri R&D Center Zurich\n",
     "\n",
     "Licensed under the Apache License, Version 2.0 (the \"License\");\n",
     "you may not use this file except in compliance with the License.\n",
@@ -49,18 +49,6 @@
     "import pandas as pd"
    ]
   },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "CS_FOLDER = os.getcwd()\n",
-    "\n",
-    "def asset_file(filename):\n",
-    "    return os.path.join(CS_FOLDER, 'data', filename)"
-   ]
-  },
   {
    "cell_type": "markdown",
    "metadata": {},
@@ -81,6 +69,18 @@
     "    raise Exception(\"PRT is not initialized\")"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "CS_FOLDER = os.getcwd()\n",
+    "\n",
+    "def asset_file(filename):\n",
+    "    return os.path.join(CS_FOLDER, 'data', filename)"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -217,10 +217,22 @@
  "metadata": {
   "file_extension": ".py",
   "kernelspec": {
-   "display_name": "Python 3",
+   "display_name": "Python 3 (ipykernel)",
    "language": "python",
    "name": "python3"
   },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.18"
+  },
   "mimetype": "text/x-python",
   "name": "python",
   "npconvert_exporter": "python",
diff --git a/ex6_3d_visualization_vispy.py b/ex6_3d_visualization_vispy.py
index 80272d4..09a3b04 100644
--- a/ex6_3d_visualization_vispy.py
+++ b/ex6_3d_visualization_vispy.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2023 Esri R&D Center Zurich
+# Copyright (c) 2012-2024 Esri R&D Center Zurich
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
diff --git a/ex7_building_modeling_optimization.ipynb b/ex7_building_modeling_optimization.ipynb
index 76c5138..02c8ffd 100644
--- a/ex7_building_modeling_optimization.ipynb
+++ b/ex7_building_modeling_optimization.ipynb
@@ -4,7 +4,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Copyright (c) 2012-2023 Esri R&D Center Zurich\n",
+    "Copyright (c) 2012-2024 Esri R&D Center Zurich\n",
     "\n",
     "Licensed under the Apache License, Version 2.0 (the \"License\");\n",
     "you may not use this file except in compliance with the License.\n",
@@ -70,16 +70,6 @@
     "from vtkmodules.vtkIOImport import vtkGLTFImporter"
    ]
   },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "CWD = os.getcwd() # workaround: PyPRT initialization unexpectedly changes current working directory\n",
-    "DATA = os.path.join(CWD, 'data')"
-   ]
-  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -128,6 +118,16 @@
     "### Given: building architecture (CGA Rule Package) and parcel to redevelop"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "CWD = os.getcwd()\n",
+    "DATA = os.path.join(CWD, 'data')"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -453,7 +453,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.7.13"
+   "version": "3.8.17"
   }
  },
  "nbformat": 4,
diff --git a/ex8_3d_gis_content_generation.ipynb b/ex8_3d_gis_content_generation.ipynb
index dd76629..af54760 100644
--- a/ex8_3d_gis_content_generation.ipynb
+++ b/ex8_3d_gis_content_generation.ipynb
@@ -4,7 +4,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Copyright (c) 2012-2023 Esri R&D Center Zurich\n",
+    "Copyright (c) 2012-2024 Esri R&D Center Zurich\n",
     "\n",
     "Licensed under the Apache License, Version 2.0 (the \"License\");\n",
     "you may not use this file except in compliance with the License.\n",
@@ -47,15 +47,6 @@
     "gis = GIS(username='my_username') # Enter your AGOL username."
    ]
   },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "CWD = os.getcwd() # workaround: PyPRT initialization unexpectedly changes current working directory"
-   ]
-  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -116,7 +107,9 @@
   {
    "cell_type": "code",
    "execution_count": null,
-   "metadata": {},
+   "metadata": {
+    "scrolled": true
+   },
    "outputs": [],
    "source": [
     "item_id = 'e9ff3ffc7445455d87c55551aafc6e54'\n",
@@ -127,9 +120,7 @@
   {
    "cell_type": "code",
    "execution_count": null,
-   "metadata": {
-    "scrolled": true
-   },
+   "metadata": {},
    "outputs": [],
    "source": [
     "map1 = gis.map()\n",
@@ -253,7 +244,7 @@
     "    'layerTextureMaxDimension': [2048], \n",
     "    'layerFeatureGranularity': ['0'], \n",
     "    'layerBackfaceCulling': [False], \n",
-    "    'outputPath': os.path.join(CWD, 'ex8_output')}\n",
+    "    'outputPath': os.path.join(os.getcwd(), 'ex8_output')}\n",
     "os.makedirs(enc_optionsSLPK['outputPath'], exist_ok=True)"
    ]
   },
@@ -355,7 +346,7 @@
    "notebookRuntimeVersion": "10.7.1"
   },
   "kernelspec": {
-   "display_name": "Python 3",
+   "display_name": "Python 3 (ipykernel)",
    "language": "python",
    "name": "python3"
   },
@@ -369,7 +360,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.8.13"
+   "version": "3.8.17"
   }
  },
  "nbformat": 4,
diff --git a/ex9_model_vis_web.py b/ex9_model_vis_web.py
index 3bdfaa1..1afa6ad 100644
--- a/ex9_model_vis_web.py
+++ b/ex9_model_vis_web.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2023 Esri R&D Center Zurich
+# Copyright (c) 2012-2024 Esri R&D Center Zurich
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.


Test patch:
diff --git a/test_conda_env.py b/test_conda_env.py
new file mode 100644
index 0000000..fa0d240
--- /dev/null
+++ b/test_conda_env.py
@@ -0,0 +1,72 @@
+# Copyright (c) 2012-2024 Esri R&D Center Zurich
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+#   https://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# A copy of the license is available in the repository's LICENSE file.
+
+import os
+import platform
+import argparse
+import shutil
+import tempfile
+
+
+def setup_conda_env_from_requirements(conda_cmd, conda_env, py_ver):
+    os.system(f"{conda_cmd} env remove -y -n {conda_env}")
+    os.system(f"{conda_cmd} env create -y -n {conda_env} --file envs/environment-py{py_ver}.yml")
+
+
+# one cannot directly install/update a .tar.bz2 conda package
+# first, we need to create a local channel directory and index it
+def add_custom_pyprt_package(conda_cmd, conda_env, custom_pyprt_package):
+    with tempfile.TemporaryDirectory(prefix="pyprt-conda-channel-") as local_channel:
+        cat_name = "win-64" if platform.system() == "Windows" else "linux-64"
+        dst = os.path.join(local_channel, cat_name)
+        os.makedirs(dst)
+        shutil.copy(src=custom_pyprt_package, dst=dst)
+        os.system(f"{conda_cmd} install -y conda-index")
+        os.system(f"{conda_cmd} index {local_channel}")
+        os.system(f"{conda_cmd} install -y -n {conda_env} -c {local_channel} pyprt")
+
+
+def run_examples(conda_cmd, conda_env):
+    py_cmd = f"{conda_cmd} run -n {conda_env} python"
+    os.system(f'{py_cmd} -c "import pyprt; print(pyprt.get_api_version())"')
+    os.system(f"{py_cmd} ex1_python_encoder.py")
+    os.system(f"{py_cmd} ex2_obj_initial_shape.py")
+    os.system(f"{py_cmd} ex3_format_exporter.py")
+    os.system(f"{py_cmd} ex4_multi_generations.py")
+
+
+def main():
+    conda_cmd_default = "%LOCALAPPDATA%\\miniconda3\\condabin\\conda" if platform.system() == "Windows" else "/opt/miniconda3/bin"
+
+    parser = argparse.ArgumentParser(description='PyPRT conda env tests for examples')
+    parser.add_argument("--py_ver", help="Python version to build for (38, ...)", type=str, required=True)
+    parser.add_argument(
+        '--pyprt_conda_package', help='custom pyprt build to use in conda env test', type=str, required=False)
+    parser.add_argument('--conda_env_name', help='name of conda env', type=str, required=False)
+    parser.add_argument("--conda_cmd", help="absolute path to conda executable", type=str,
+                        default=conda_cmd_default)
+    args = parser.parse_args()
+
+    if not args.conda_env_name:
+        args.conda_env_name = f"pyprt-examples-py{args.py_ver}"
+
+    setup_conda_env_from_requirements(args.conda_cmd, args.conda_env_name, args.py_ver)
+    if args.pyprt_conda_package:
+        add_custom_pyprt_package(args.conda_cmd, args.conda_env_name, args.pyprt_conda_package)
+    run_examples(args.conda_cmd, args.conda_env_name)
+
+
+if __name__ == '__main__':
+    main()
diff --git a/test_venv.py b/test_venv.py
index b65fd28..3ddd366 100644
--- a/test_venv.py
+++ b/test_venv.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2023 Esri R&D Center Zurich
+# Copyright (c) 2012-2024 Esri R&D Center Zurich
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -60,8 +60,13 @@ def main():
     parser.add_argument('--venv_path', help='use specific venv location and keep it around', type=str, required=False)
     args = parser.parse_args()
 
-    venv_dir = tempfile.TemporaryDirectory(
-        prefix=f'pyprt-venv-test-py{env_py}') if not args.venv_path else args.venv_path
+    venv_temp_dir = None
+    venv_dir = None
+    if args.venv_path:
+        venv_dir = args.venv_path
+    else:
+        venv_temp_dir = tempfile.TemporaryDirectory(prefix=f'pyprt-venv-test-py{env_py}')
+        venv_dir = venv_temp_dir.name
 
     setup_venv_from_requirements(venv_dir, env_py)
     if args.pyprt_wheel: