Repository: NVIDIA/TransformerEngine

Issue:
Development install fails due to missing `packaging` package.
Hi! #186 introduces `packaging` as a prerequisite for installing TE, but it is not documented in the [installation guide](https://docs.nvidia.com/deeplearning/transformer-engine/user-guide/installation.html).

I can see that it is declared in `setup.py`:
```py
class PyTorchBuilder(FrameworkBuilderBase):
    ...
    @staticmethod
    def install_requires():
        return ["flash-attn>=1.0.2", "packaging"]
```
but it seems that in development installation this would not work because we will not be able to `import packaging` in the first place.

Context: our nightly TE-JAX container build failed due to this error. See [full log](https://pipelines.actions.githubusercontent.com/serviceHosts/440a0623-83c9-43a7-a157-4a5684b1669e/_apis/pipelines/1/runs/596/signedlogcontent/9?urlExpires=2023-05-01T17%3A35%3A41.2720724Z&urlSigningMethod=HMACV1&urlSignature=mPO1iqrsnrC4n3alCQ9Xi2tj1B%2BsfqEHz%2FOLJvJjGmk%3D) here. I was able to fix the build by installing `packaging` alongside `pybind11` and `ninja`, but feel that it could be at least better documented.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@
 import re
 import copy
 import tempfile
-from packaging.version import Version
+from pkg_resources import packaging
 from setuptools import setup, find_packages, Extension
 from setuptools.command.build_ext import build_ext
 from shutil import copyfile
@@ -172,7 +172,7 @@ def cmake_flags(self):
 
     @staticmethod
     def install_requires():
-        return ["flash-attn>=1.0.2", "packaging"]
+        return ["flash-attn>=1.0.2"]
 
 
 class TensorFlowBuilder(FrameworkBuilderBase):
@@ -244,13 +244,13 @@ def get_cmake_bin():
     try:
         out = subprocess.check_output([cmake_bin, "--version"])
     except OSError:
-        cmake_installed_version = Version("0.0")
+        cmake_installed_version = packaging.version.Version("0.0")
     else:
-        cmake_installed_version = Version(
+        cmake_installed_version = packaging.version.Version(
             re.search(r"version\s*([\d.]+)", out.decode()).group(1)
         )
 
-    if cmake_installed_version < Version("3.18.0"):
+    if cmake_installed_version < packaging.version.Version("3.18.0"):
         print(
             "Could not find a recent CMake to build Transformer Engine. "
             "Attempting to install CMake 3.18 to a temporary location via pip.",
diff --git a/transformer_engine/pytorch/transformer.py b/transformer_engine/pytorch/transformer.py
--- a/transformer_engine/pytorch/transformer.py
+++ b/transformer_engine/pytorch/transformer.py
@@ -9,7 +9,7 @@
 from importlib.metadata import version
 from contextlib import nullcontext
 from typing import Any, Callable, Optional, Tuple, Union
-from packaging.version import Version
+from pkg_resources import packaging
 
 import torch
 
@@ -45,8 +45,8 @@
 )
 from transformer_engine.pytorch.export import is_in_onnx_export_mode
 
-_flash_attn_version = Version(version("flash-attn"))
-_flash_attn_version_required = Version("1.0.2")
+_flash_attn_version = packaging.version.Version(version("flash-attn"))
+_flash_attn_version_required = packaging.version.Version("1.0.2")
 warnings.filterwarnings("module", category=DeprecationWarning, module="transformer")
 
 


Test patch: