Repository: Lightning-Universe/lightning-flash

Issue:
Installing from master fails due to ModuleNotFoundError
## 🐛 Bug
See the title and below error msg.

I think this is caused by `setup.py` which depends on `flash` where it shouldn't because `setup.py` gets run when any required packages are not installed yet.

### To Reproduce
In, for example, Google Colab, you will get the following results:
```console
$ pip install git+https://github.com/PytorchLightning/lightning-flash.git@master
Collecting git+https://github.com/PytorchLightning/lightning-flash.git@master
  Cloning https://github.com/PytorchLightning/lightning-flash.git (to revision master) to /tmp/pip-req-build-ist5jx4a
  Running command git clone -q https://github.com/PytorchLightning/lightning-flash.git /tmp/pip-req-build-ist5jx4a
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

$ python setup.py egg_info
Traceback (most recent call last):
  File "setup.py", line 7, in <module>
    import flash
  File "/home/nitta/work/github.com/PyTorchLightning/lightning-flash/flash/__init__.py", line 22, in <module>
    from flash.core.data.callback import FlashCallback
  File "/home/nitta/work/github.com/PyTorchLightning/lightning-flash/flash/core/data/callback.py", line 4, in <module>
    from pytorch_lightning.callbacks import Callback
ModuleNotFoundError: No module named 'pytorch_lightning.callbacks'
```

### Expected behavior
```console
$ pip install git+https://github.com/PytorchLightning/lightning-flash.git@master
```
will successfully install flash from master branch.

### Additional context
Found while working on #335.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,29 +1,46 @@
 #!/usr/bin/env python
+# Copyright The PyTorch Lightning team.
+#
+# 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
+#
+#     http://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.
 import os
 from importlib.util import module_from_spec, spec_from_file_location
 
 from setuptools import find_packages, setup
 
-import flash
-import flash.__about__ as about
-
 # https://packaging.python.org/guides/single-sourcing-package-version/
 # http://blog.ionelmc.ro/2014/05/25/python-packaging/
-_PATH_ROOT = os.path.dirname(os.path.dirname(flash.__file__))
+_PATH_ROOT = os.path.dirname(__file__)
+_PATH_REQUIRE = os.path.join(_PATH_ROOT, "requirements")
 
 
 def _load_py_module(fname, pkg="flash"):
-    spec = spec_from_file_location(os.path.join(pkg, fname), os.path.join(_PATH_ROOT, pkg, fname))
+    spec = spec_from_file_location(
+        os.path.join(pkg, fname),
+        os.path.join(_PATH_ROOT, pkg, fname),
+    )
     py = module_from_spec(spec)
     spec.loader.exec_module(py)
     return py
 
 
+about = _load_py_module('__about__.py')
 setup_tools = _load_py_module('setup_tools.py')
 
-long_description = setup_tools._load_readme_description(_PATH_ROOT, homepage=about.__homepage__, ver=about.__version__)
-
-_PATH_REQUIRE = os.path.join(_PATH_ROOT, "requirements")
+long_description = setup_tools._load_readme_description(
+    _PATH_ROOT,
+    homepage=about.__homepage__,
+    ver=about.__version__,
+)
 
 extras = {
     "docs": setup_tools._load_requirements(path_dir=_PATH_REQUIRE, file_name="docs.txt"),


Test patch: