# Copyright 2020 The Flax Authors.
#
# 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.

"""setup.py for Flax."""

import os
from setuptools import find_packages
from setuptools import setup

version = "0.1.0"

here = os.path.abspath(os.path.dirname(__file__))
try:
  README = open(os.path.join(here, "README.md"), encoding='utf-8').read()
except IOError:
  README = ""

install_requires = [
    "numpy>=1.12",
    "jax>=0.1.59",
    "matplotlib",  # only needed for tensorboard export
    "dataclasses",  # will only install on py3.6
    "msgpack",
]

tests_require = [
    "jaxlib",
    "pytest",
    "pytest-cov",
    "pytest-xdist",
    "tensorflow",
    "tensorflow_datasets",
]

setup(
    name="flax",
    version=version,
    description="Flax: A neural network library for JAX designed for flexibility",
    long_description="\n\n".join([README]),
    long_description_content_type='text/markdown',
    classifiers=[
        "Development Status :: 3 - Alpha",
        "Intended Audience :: Developers",
        "Intended Audience :: Science/Research",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3.7",
        "Topic :: Scientific/Engineering :: Artificial Intelligence",
        ],
    keywords="",
    author="Flax team",
    author_email="flax-dev@google.com",
    url="https://github.com/google/flax",
    license="Apache",
    packages=find_packages(),
    include_package_data=False,
    zip_safe=False,
    install_requires=install_requires,
    extras_require={
        "testing": tests_require,
        },
    )

setup.py
# Copyright 2020 The Flax Authors.
#
# 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.

"""setup.py for Flax."""

import os
from setuptools import find_packages
from setuptools import setup

version = "0.1.0"

here = os.path.abspath(os.path.dirname(__file__))
try:
  README = open(os.path.join(here, "README.md"), encoding='utf-8').read()
except IOError:
  README = ""

install_requires = [
    "numpy>=1.12",
    "jax>=0.1.59",
    "matplotlib",  # only needed for tensorboard export
    "dataclasses;python_version<'3.7'", # will only install on py3.6
    "msgpack",
]

tests_require = [
    "jaxlib",
    "pytest",
    "pytest-cov",
    "pytest-xdist",
    "tensorflow",
    "tensorflow_datasets",
]

setup(
    name="flax",
    version=version,
    description="Flax: A neural network library for JAX designed for flexibility",
    long_description="\n\n".join([README]),
    long_description_content_type='text/markdown',
    classifiers=[
        "Development Status :: 3 - Alpha",
        "Intended Audience :: Developers",
        "Intended Audience :: Science/Research",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3.7",
        "Topic :: Scientific/Engineering :: Artificial Intelligence",
        ],
    keywords="",
    author="Flax team",
    author_email="flax-dev@google.com",
    url="https://github.com/google/flax",
    license="Apache",
    packages=find_packages(),
    include_package_data=False,
    zip_safe=False,
    install_requires=install_requires,
    extras_require={
        "testing": tests_require,
        },
    )

setup.py
diff --git a/setup.py b/setup.py
index 442ef0f76..25a9b112a 100644
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,7 @@
     "numpy>=1.12",
     "jax>=0.1.59",
     "matplotlib",  # only needed for tensorboard export
-    "dataclasses",  # will only install on py3.6
+    "dataclasses;python_version<'3.7'", # will only install on py3.6
     "msgpack",
 ]
 

`typing._ClassVar` cannot be accessed in the iPython shell – dataclasses package seems to mess up on Python 3.7
### Problem you have encountered:

I just installed flax and tried to import it from the iPython shell. But it raises an `AttributeError`.

```
In [1]: import flax

*snip*

~/.virtualenvs/flax2/lib/python3.7/site-packages/dataclasses.py in _is_classvar(a_type, typing)
    548     # This test uses a typing internal class, but it's the best way to
    549     # test if this is a ClassVar.
--> 550     return type(a_type) is typing._ClassVar
    551
    552

AttributeError: module 'typing' has no attribute '_ClassVar'
```
This does not happen in the normal interpreter, where everything goes fine. 

### What you expected to happen:

I expected the import to work the same in iPython and the normal python shell.

### Logs, error messages, etc:

Full traceback in this gist: https://gist.github.com/bayerj/96f096c7fb09a7c9b758dabdbca32671

### Steps to reproduce:

On Mac OS X with Python 3.7.6, not anaconda, virtuelenvwrapper installed.

```
❯❯❯ mkvirtualenv flax2
❯❯❯ pip install jaxlib
*snip*
❯❯❯ pip install flax
*snip*
❯❯❯ ipython

*snip*

In [1]: import flax
```

### Workaround

The problem seems to be in the `dataclasses` package–not python's own one–from PyPI. If I uninstall it...

```
❯❯❯ pip uninstall dataclasses
Found existing installation: dataclasses 0.6
Uninstalling dataclasses-0.6:
  Would remove:
    /Users/bayerj/.virtualenvs/debug2/lib/python3.7/site-packages/dataclasses-0.6.dist-info/*
    /Users/bayerj/.virtualenvs/debug2/lib/python3.7/site-packages/dataclasses.py
Proceed (y/n)? y
  Successfully uninstalled dataclasses-0.6
❯❯❯ ipython
/usr/local/lib/python3.7/site-packages/IPython/core/interactiveshell.py:931: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
  warn("Attempting to work in a virtualenv. If you encounter problems, please "
Python 3.7.6 (default, Dec 30 2019, 19:38:28)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.9.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import flax
```
... this goes fine.




