Skip to content

Commit

Permalink
Auto-detect python version and require at least Python 3.9 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
openvmp authored Jan 13, 2024
1 parent ed8fbf9 commit 0d9e17e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion partcad-cli/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.3.2"
description = "Command-line interface to PartCAD"
readme = "README.md"
keywords = ["cadquery", "build123d", "cad", "design", "openscad", "step", "stl"]
requires-python = ">=3.7"
requires-python = ">=3.9"
license = {file = "LICENSE.txt"}
authors = [
{name = "Roman Kuzmenko", email = "openvmp@proton.me" }
Expand Down
2 changes: 1 addition & 1 deletion partcad/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.3.2"
description = "Package manager for CAD models and a modelling framework"
readme = "README.md"
keywords = ["cadquery", "build123d", "cad", "design", "openscad", "step", "stl"]
requires-python = ">=3.7"
requires-python = ">=3.9"
license = {file = "LICENSE.txt"}
authors = [
{name = "Roman Kuzmenko", email = "openvmp@proton.me" }
Expand Down
9 changes: 6 additions & 3 deletions partcad/src/partcad/project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ def __init__(self, import_config_name, config_path=DEFAULT_CONFIG_FILENAME):

# option: "pythonVersion"
# description: the version of python to use in sandboxed environments if any
# values: string
# default: "3.10"
# values: string (e.g. "3.10")
# default: <The major and minor version of the current interpreter>
if "pythonVersion" == self.config_obj:
self.python_version = self.config_obj["pythonVersion"]
else:
self.python_version = "3.10"
self.python_version = "%d.%d" % (
sys.version_info.major,
sys.version_info.minor,
)
5 changes: 4 additions & 1 deletion partcad/src/partcad/runtime_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
import os
import pathlib
import subprocess
import sys


from . import runtime


class PythonRuntime(runtime.Runtime):
def __init__(self, ctx, sandbox, version="3.10"):
def __init__(self, ctx, sandbox, version=None):
if version is None:
version = "%d.%d" % (sys.version_info.major, sys.version_info.minor)
super().__init__(ctx, "python-" + sandbox + "-" + version)
self.version = version

Expand Down
2 changes: 1 addition & 1 deletion partcad/src/partcad/runtime_python_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class CondaPythonRuntime(runtime_python.PythonRuntime):
def __init__(self, ctx, version="3.10"):
def __init__(self, ctx, version=None):
super().__init__(ctx, "conda", version)

if not self.initialized:
Expand Down
2 changes: 1 addition & 1 deletion partcad/src/partcad/runtime_python_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class NonePythonRuntime(runtime_python.PythonRuntime):
def __init__(self, ctx, version="3.10"):
def __init__(self, ctx, version=None):
super().__init__(ctx, "none", version)

if not self.initialized:
Expand Down
2 changes: 1 addition & 1 deletion partcad/src/partcad/runtime_python_pypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class PyPyPythonRuntime(runtime_python.PythonRuntime):
def __init__(self, ctx, version="3.10"):
def __init__(self, ctx, version=None):
super().__init__(ctx, "pypy", version)

if not self.initialized:
Expand Down
6 changes: 3 additions & 3 deletions partcad/tests/unit/test_runtime_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import partcad as pc


def test_runtime_python_version_3_7():
def test_runtime_python_version_3_9():
ctx = pc.Context("partcad/tests")
runtime = ctx.get_python_runtime("3.7")
runtime = ctx.get_python_runtime("3.9")
version_string, errors = runtime.run(["--version"])
assert errors == ""
assert version_string.startswith("Python 3.7")
assert version_string.startswith("Python 3.9")


def test_runtime_python_version_3_10():
Expand Down

0 comments on commit 0d9e17e

Please sign in to comment.