Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: require python >=3.7 again (the python 3.9 dependency was unnecessary) #2372

Merged
merged 10 commits into from
Aug 2, 2023
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ classifiers =
zip_safe = False
include_package_data = False
packages = find:
python_requires = >=3.9
python_requires = >=3.7
install_requires =
appdirs
configargparse
Expand Down
8 changes: 6 additions & 2 deletions snakemake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
__license__ = "MIT"

import sys
from snakemake.common import MIN_PY_VERSION

if sys.version_info < (3, 9):
raise ValueError("Snakemake requires at least Python 3.9.")
if sys.version_info < MIN_PY_VERSION:
raise ValueError(
f"Snakemake requires at least Python {MIN_PY_VERSION}. Please ensure to execute it in a compatible Python environment.",
file=sys.stderr,
)

import os
import glob
Expand Down
3 changes: 2 additions & 1 deletion snakemake/executors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from functools import partial
from collections import namedtuple
import base64
from typing import List
import uuid
import re
import math
Expand Down Expand Up @@ -142,7 +143,7 @@ def get_resource_declarations(self, job: ExecutorJobInterface):

def run_jobs(
self,
jobs: list[ExecutorJobInterface],
jobs: List[ExecutorJobInterface],
callback=None,
submit_callback=None,
error_callback=None,
Expand Down
14 changes: 4 additions & 10 deletions snakemake/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@

import sys

# The typing API used here requires Python 3.9 or later and fails with unintuitive errors otherwise.
if sys.version_info < (3, 9):
raise ValueError(
"Snakemake executor interface definition requires at least Python 3.9."
)

from abc import ABC, abstractmethod
from typing import Optional
from typing import Optional, List, Dict


class ExecutorJobInterface(ABC):
Expand Down Expand Up @@ -278,7 +272,7 @@ def latency_wait(self) -> int:

@property
@abstractmethod
def rerun_triggers(self) -> Optional[list[str]]:
def rerun_triggers(self) -> Optional[List[str]]:
...

@property
Expand Down Expand Up @@ -328,12 +322,12 @@ def wrapper_prefix(self) -> Optional[str]:

@property
@abstractmethod
def overwrite_threads(self) -> dict[str, int]:
def overwrite_threads(self) -> Dict[str, int]:
...

@property
@abstractmethod
def overwrite_scatter(self) -> dict[str, int]:
def overwrite_scatter(self) -> Dict[str, int]:
...

@property
Expand Down
2 changes: 1 addition & 1 deletion test-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ channels:
- conda-forge
- bioconda
dependencies:
- python >=3.9
- python >=3.7
- yte
- packaging
- stopit
Expand Down
7 changes: 7 additions & 0 deletions tests/test_conda_python_3_7_script/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rule random_python_conda_script:
output:
"version.txt"
conda:
"test_python_env.yaml"
script:
"test_script.py"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.7.12
9 changes: 9 additions & 0 deletions tests/test_conda_python_3_7_script/test_python_env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
channels:
- conda-forge
- defaults
dependencies:
- python =3.7.12
# add a dependency that is not used by Snakemake itself,
# to simulate the case where the Python script needs 3.7 and
# that dependency
- pillow =9.2
5 changes: 5 additions & 0 deletions tests/test_conda_python_3_7_script/test_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import platform
import PIL

with open('version.txt', 'w') as f:
f.write(platform.python_version())
4 changes: 4 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,10 @@ def test_conda_python_script():
run(dpath("test_conda_python_script"), use_conda=True)


def test_conda_python_3_7_script():
run(dpath("test_conda_python_3_7_script"), use_conda=True)


def test_prebuilt_conda_script():
sp.run("conda env create -f tests/test_prebuilt_conda_script/env.yaml", shell=True)
run(dpath("test_prebuilt_conda_script"), use_conda=True)
Expand Down