Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tutorpicasso/commands/enable_private_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import click
from packaging.version import Version
from tutor import config as tutor_config
from tutor.__about__ import __version__ as tutor_version
from tutor import utils as tutor_utils
from tutor import fmt as tutor_fmt
from tutor import utils as tutor_utils
from tutor.__about__ import __version__ as tutor_version


@click.command(name="enable-private-packages", help="Enable picasso private packages")
Expand Down
1 change: 0 additions & 1 deletion tutorpicasso/commands/run_extra_commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
import subprocess
from itertools import chain

from typing import Any, List, Pattern

import click
Expand Down
28 changes: 26 additions & 2 deletions tutorpicasso/plugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations

import os
import re
from glob import glob

import click
import importlib_resources
from packaging.version import Version
from packaging.version import InvalidVersion, Version
from tutor import hooks
from tutor.__about__ import __version__ as tutor_version

Expand All @@ -19,7 +20,30 @@

# Tutor introduces the MOUNTED_DIRECTORIES in the latest Palm version.
latest_palm_version = "16.1.8"
if Version(tutor_version) > Version(latest_palm_version):


def safe_version(v: str) -> Version:
"""Parse a version string, tolerating non-PEP-440 suffixes like '-main', '-dev', etc.

Converts '21.0.6-main' -> '21.0.6+main' (a valid PEP 440 local version),
and falls back to stripping the suffix entirely if that still fails.
"""
try:
return Version(v)
except InvalidVersion:
pass

# Replace the first '-<suffix>' with '+<suffix>' (PEP 440 local segment)
normalized = re.sub(r"-([A-Za-z][\w.]*)", r"+\1", v, count=1)
try:
return Version(normalized)
except InvalidVersion:
# Last resort: strip any trailing non-numeric segment
stripped = re.sub(r"[-+].*$", "", v)
return Version(stripped)


if safe_version(tutor_version) > safe_version(latest_palm_version):
hooks.Filters.MOUNTED_DIRECTORIES.add_items(
[
("openedx", r"eox-.*"),
Expand Down
Loading