Skip to content

Commit

Permalink
rewind support python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Oct 16, 2024
1 parent 806df8b commit 175ea31
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

# We don't need to run on all platforms since this package is
# platform-agnostic. The output wheel is something like
# "monotonic_attention-<version>-py3-none-any.whl".
# "urdf2mjcf-<version>-py3-none-any.whl".
runs-on: ubuntu-latest

steps:
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.8"

- name: Install dependencies
run: |
Expand All @@ -42,6 +42,3 @@ jobs:

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.8"

- name: Restore cache
id: restore-cache
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Setup script for the project."""

import re
from typing import List

from setuptools import setup

Expand All @@ -11,11 +12,11 @@


with open("urdf2mjcf/requirements.txt", "r", encoding="utf-8") as f:
requirements: list[str] = f.read().splitlines()
requirements: List[str] = f.read().splitlines()


with open("urdf2mjcf/requirements-dev.txt", "r", encoding="utf-8") as f:
requirements_dev: list[str] = f.read().splitlines()
requirements_dev: List[str] = f.read().splitlines()


with open("urdf2mjcf/__init__.py", "r", encoding="utf-8") as fh:
Expand All @@ -32,7 +33,7 @@
url="https://github.com/kscalelabs/urdf2mjcf",
long_description=long_description,
long_description_content_type="text/markdown",
python_requires=">=3.11",
python_requires=">=3.8",
install_requires=requirements,
tests_require=requirements_dev,
extras_require={"dev": requirements_dev},
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Defines PyTest configuration for the project."""

import random
from typing import List

import pytest
from _pytest.python import Function
Expand All @@ -11,5 +12,5 @@ def set_random_seed() -> None:
random.seed(1337)


def pytest_collection_modifyitems(items: list[Function]) -> None:
def pytest_collection_modifyitems(items: List[Function]) -> None:
items.sort(key=lambda x: x.get_closest_marker("slow") is not None)
5 changes: 3 additions & 2 deletions urdf2mjcf/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import tempfile
import xml.etree.ElementTree as ET
from pathlib import Path
from typing import Union

import mujoco

Expand Down Expand Up @@ -416,8 +417,8 @@ def add_cameras(root: ET.Element, distance: float = 3.0, height_offset: float =


def convert_urdf_to_mjcf(
urdf_path: str | Path,
mjcf_path: str | Path | None = None,
urdf_path: Union[str, Path],
mjcf_path: Union[str, Path, None] = None,
no_collision_mesh: bool = False,
copy_meshes: bool = False,
camera_distance: float = 3.0,
Expand Down
10 changes: 6 additions & 4 deletions urdf2mjcf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
import re
import xml.etree.ElementTree as ET
from pathlib import Path
from typing import Iterator
from typing import Iterator, Optional, Tuple, Union
from xml.dom import minidom


def iter_meshes(
urdf_path: Path,
no_collision_mesh: bool = False,
) -> Iterator[tuple[tuple[ET.Element, Path] | tuple[None, None], tuple[ET.Element, Path] | tuple[None, None]]]:
) -> Iterator[
Tuple[Union[Tuple[ET.Element, Path], Tuple[None, None]], Union[Tuple[ET.Element, Path], Tuple[None, None]]]
]:
urdf_tree = ET.parse(urdf_path)

def get_mesh(visual_or_collision: ET.Element | None) -> tuple[ET.Element, Path] | tuple[None, None]:
def get_mesh(visual_or_collision: Optional[ET.Element]) -> Union[Tuple[ET.Element, Path], Tuple[None, None]]:
if visual_or_collision is None:
return (None, None)
if (geometry := visual_or_collision.find("geometry")) is None:
Expand Down Expand Up @@ -49,7 +51,7 @@ def get_mesh(visual_or_collision: ET.Element | None) -> tuple[ET.Element, Path]
yield visual_mesh, collision_mesh


def save_xml(path: str | Path | io.StringIO, tree: ET.ElementTree | ET.Element) -> None:
def save_xml(path: Union[str, Path, io.StringIO], tree: Union[ET.ElementTree, ET.Element]) -> None:
if isinstance(tree, ET.ElementTree):
tree = tree.getroot()
xmlstr = minidom.parseString(ET.tostring(tree)).toprettyxml(indent=" ")
Expand Down

0 comments on commit 175ea31

Please sign in to comment.