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

use seems to not handle relative path correctly #168

Open
jeff-dh opened this issue May 17, 2021 · 0 comments · May be fixed by #175
Open

use seems to not handle relative path correctly #168

jeff-dh opened this issue May 17, 2021 · 0 comments · May be fixed by #175

Comments

@jeff-dh
Copy link
Contributor

jeff-dh commented May 17, 2021

When I change the examples/basic_scad_include.py file to use the demo_scad_use function instead of the demo_import_scad function SolidPython is -- at least in my environment -- not able to resolve scad_to_include.scad in certain situations.

Running basic_scad_include.py (with demo_scad_use enabled) from a directory that is not in sys.path results in the following trace:

jeff@nups ~/code $python3 SolidPython/solid/examples/basic_scad_include.py 
Traceback (most recent call last):
  File "SolidPython/solid/examples/basic_scad_include.py", line 31, in <module>
    a = demo_scad_use()
  File "SolidPython/solid/examples/basic_scad_include.py", line 26, in demo_scad_use
    return steps(5)
  File "<string>", line 4, in __init__
  File "/home/jeff/.local/lib/python3.6/site-packages/solid/solidpython.py", line 372, in __init__
    self.include_file_path = self._get_include_path(include_file_path)
  File "/home/jeff/.local/lib/python3.6/site-packages/solid/solidpython.py", line 396, in _get_include_path
    raise ValueError(f"Unable to find included SCAD file: {include_file_path} in sys.path")
ValueError: Unable to find included SCAD file: SolidPython/solid/examples/scad_to_include.scad in sys.path

The issue is caused by the ctor of the IncludedOpenSCADObject. It calls self._get_include_path to resolve the file but the self._get_include_path function -- for some reason -- tries to find the file using the Python-Path (sys.path) to resolve a *.scad file. This seems pretty strange to me and only works by accident if you call it from withing sys.path and/or SolidPython is installed in sys.path (I can't wrap my head around it which combinations it is exactly but these two factors seem to be the key).

Replacing the call to self._get_include_path with a call to objects._find_library seems to work but I'm not sure whether it's supposed to be that way and whether -- or not -- this might have side effects.

Note: when using import_scad everything is fine.

jeff-dh added a commit to jeff-dh/SolidPython that referenced this issue May 22, 2021
	- I'm pretty sure this is what it is supposed to be
	- I would suggest to rename the function to `resolve_scad_filename`
@jeff-dh jeff-dh linked a pull request May 22, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant