import os
import io
import re
from setuptools import setup, find_packages


def read(*names, **kwargs):
    with io.open(os.path.join(os.path.dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")) as fp:
        return fp.read()


def find_version(*file_paths):
    version_file = read(*file_paths)
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError("Unable to find version string.")


readme = read("README.md")

VERSION = find_version("ignite", "__init__.py")

requirements = [
    "torch",
]

setup(
    # Metadata
    name="pytorch-ignite",
    version=VERSION,
    author="PyTorch Core Team",
    author_email="soumith@pytorch.org",
    url="https://github.com/pytorch/ignite",
    description="A lightweight library to help with training neural networks in PyTorch.",
    long_description_content_type="text/markdown",
    long_description=readme,
    license="BSD",
    # Package info
    packages=find_packages(exclude=("tests", "tests.*",)),
    zip_safe=True,
    install_requires=requirements,
)

setup.py
import os
import io
import re
from setuptools import setup, find_packages


def read(*names, **kwargs):
    with io.open(os.path.join(os.path.dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")) as fp:
        return fp.read()


def find_version(*file_paths):
    version_file = read(*file_paths)
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError("Unable to find version string.")


readme = read("README.md")

VERSION = find_version("ignite", "__init__.py")

requirements = [
    "torch>=1.0,<2",
]

setup(
    # Metadata
    name="pytorch-ignite",
    version=VERSION,
    author="PyTorch Core Team",
    author_email="soumith@pytorch.org",
    url="https://github.com/pytorch/ignite",
    description="A lightweight library to help with training neural networks in PyTorch.",
    long_description_content_type="text/markdown",
    long_description=readme,
    license="BSD",
    # Package info
    packages=find_packages(exclude=("tests", "tests.*",)),
    zip_safe=True,
    install_requires=requirements,
)

setup.py
diff --git a/.github/workflows/pytorch-version-tests.yml b/.github/workflows/pytorch-version-tests.yml
new file mode 100644
index 000000000000..383342bf272a
--- /dev/null
+++ b/.github/workflows/pytorch-version-tests.yml
@@ -0,0 +1,51 @@
+on: 
+  schedule:
+    # Run at 00:00 UTC on Sunday
+    - cron:  '0 0 * * 0'
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    strategy:
+      max-parallel: 10
+      fail-fast: false
+      matrix:
+        python-version: [3.5, 3.6, 3.7, 3.8]
+        pytorch-version: [1.4.0, 1.3.1, 1.2.0, 1.1.0, 1.0.1]
+        exclude:
+          - pytorch-version: 1.3.1
+            python-version: 3.8
+          - pytorch-version: 1.2.0
+            python-version: 3.8
+          - pytorch-version: 1.1.0
+            python-version: 3.8
+          - pytorch-version: 1.0.1
+            python-version: 3.8
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Setup Conda
+      run: |
+        wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
+        bash miniconda.sh -b -p $HOME/miniconda
+        export PATH="$HOME/miniconda/bin:$PATH"
+        conda config --set always_yes yes --set changeps1 no
+        conda update -q conda
+        # Useful for debugging any issues with conda
+        conda info -a
+        conda create -q -n test-environment pytorch=${{ matrix.pytorch-version }} cpuonly python=${{ matrix.python-version }} -c pytorch
+        
+    - name: Install dependencies
+      run: |
+        export PATH="$HOME/miniconda/bin:$PATH"
+        source activate test-environment
+        # Keep fix in case of problem with torchvision nightly releases
+        conda install torchvision cpuonly python=${{ matrix.python-version }} -c pytorch
+        pip install -r requirements-dev.txt
+        python setup.py install
+
+    - name: Run Tests
+      run: |
+        export PATH="$HOME/miniconda/bin:$PATH"
+        source activate test-environment
+        py.test tests -vvv
diff --git a/.github/workflows/tpu-tests.yaml b/.github/workflows/tpu-tests.yml
similarity index 100%
rename from .github/workflows/tpu-tests.yaml
rename to .github/workflows/tpu-tests.yml
diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml
index 1af97970725b..4e3f793786e4 100644
--- a/conda.recipe/meta.yaml
+++ b/conda.recipe/meta.yaml
@@ -16,11 +16,11 @@ requirements:
   build:
     - python
     - setuptools
-    - pytorch
+    - pytorch 1.*.*
 
   run:
     - python
-    - pytorch
+    - pytorch 1.*.*
 
 test:
   imports:
diff --git a/setup.py b/setup.py
index ce7f00845d5d..667c5b279bdf 100644
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ def find_version(*file_paths):
 VERSION = find_version("ignite", "__init__.py")
 
 requirements = [
-    "torch",
+    "torch>=1.0,<2",
 ]
 
 setup(

PyTorch dependency is lacking version constraint
## 🐛 Bug description

<!-- A clear and concise description of what the bug is. -->
PyTorch is a dependency of Ignite and, thus, is specified in `setup.py`

https://github.com/pytorch/ignite/blob/4b311cc82fe45b3082661125cd7ee54007283fb0/setup.py#L24-L26

and `conda.recipe/meta.yaml`:

https://github.com/pytorch/ignite/blob/4b311cc82fe45b3082661125cd7ee54007283fb0/conda.recipe/meta.yaml#L15-L23

The PyTorch dependency is lacking a version constraint which may work fine right now, but there is no guarantee that Ignite will be compatible with any future major PyTorch release (e.g. PyTorch v2.x).

I suggest to constrain the PyTorch version that Ignite is compatible with, e.g. `>=1.0,<2` or `<2` if any `0.x` and `1.x` version works. If PyTorch has a new major release, even previous Ignite versions can become compatible with the new major PyTorch release (especially if no changes to the code are necessary) by making new bug fix releases with relaxed version constraints to include the new PyTorch version.

In my opinion, it is highly preferable to be conservative about dependency version constraints through a [compatible release constraint](https://www.python.org/dev/peps/pep-0440/#compatible-release) in case the dependency conforms with semantic versioning. It is impossible to guarantee compatibility with a future major release of a dependency as its API can change arbitrarily.
