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

Already on GitHub? Sign in to your account

custom / per user import path #125

Closed
chrysn opened this Issue Jun 5, 2012 · 18 comments

Comments

Projects
None yet
5 participants
Contributor

chrysn commented Jun 5, 2012

it would be useful for users to set their own import path using an environment variable OPENSCADPATH in the same spirit as python's PYTHONPATH or a shell's PATH. this would allow them to use their own libraries without either having to specify absolute paths or needing write permissions on /usr/share/.

if there is consensus about where per-user libraries would go (~/.config/openscad/libraries?), that path could be included in the search path, but having an OPENSCADPATH would be nice nevertheless.

(copied from #123 as it was a different issue and closed without addressing this)

Owner

kintel commented Jun 5, 2012

It would make sense to add corresponding functionality in the GUI, to accommodate users not using OpenSCAD from the cmd-line.

@ghost ghost assigned kintel Jul 1, 2012

kintel added a commit that referenced this issue Oct 24, 2012

Support specifying an OPENSCADPATH environment variable which will ha…
…ve precedence over the hardcoded library paths. First step of issue #125
Owner

kintel commented Oct 24, 2012

TODO:
o parsersettings.cc:
// FIXME: Support specifying more than one path in OPENSCADPATH
// FIXME: Add ~/.openscad/libraries
// FIXME: Add ~/Documents/OpenSCAD/libraries on Mac?
o Add GUI

+1

The path according MacOS standard filesystem layout would be ~/Library/Application Support/OpenSCAD/libraries

Thanks for picking up this issue. Handling custom libraries is quite a pain on Mac, when upgrading OpenSCAD.app.

Owner

kintel commented Oct 27, 2012

I was thinking ~/Library/Application Support as well, but Apple discourages users to edit files there, and on 10.7+, the ~/Library folder is actually hidden.
The reason I suggested ~/Documents/OpenSCAD is that there's where Arduino and Processing put stuff. Alternative suggestions are welcome though :)

Owner

kintel commented Feb 13, 2013

Added:
o Support specifying more than one path in OPENSCADPATH
o ~/Documents/OpenSCAD/libraries on Mac

..in this commit: 4948c24

Owner

kintel commented Feb 13, 2013

A standard location for Linux and Windows would be cool. Ideas/patches are welcome :)

Owner

kintel commented Apr 10, 2013

Remaining tasks:

  1. Standard library location for Windows
  2. Standard library location for Linux
  3. GUI for specifying your own OPENSCADPATH

Unless there are better suggestions, I'll look at what Arduino does and do the same for 1. and 2.

Member

donbright commented Apr 10, 2013

My only idea here is to consider adding a 'standard library' location that is within the users $HOME directory. (in addition to any system-wide thing which many Linux/BSD distros will probably try to override anyway).

Many people (students) do not have root access and do not understand how to set environment variables (leading to the massive confusion one usually sees in any beginner trying to use Javac and CLASSPATH for example). Something like $HOME/OpenSCAD/libraries or something>

Just an idea.

Member

donbright commented Apr 11, 2013

( I guess $HOME/OpenSCAD/libraries would maybe be better, as there is apparently no standard '$HOME/Documents' on Windows/Linux )

Owner

kintel commented Apr 11, 2013

..and I'm not sure Windows even have a concept of $HOME. Every time I use Windows, I'm confused about where files end up (I admittedly don't use Windows more than once every few months though).

Contributor

chrysn commented Apr 11, 2013

on linux and other free unices, the paths should follow the fdo basedir spec. for openscad library includes, that means for inclusion of a relative file $x (in pseudo code):

$XDG_DATA_HOME = $XDG_DATA_HOME if defined, otherwise ${HOME}/.local/share
$XDG_DATA_DIRS = $XDG_DATA_DIRS if defined, otherwise /usr/local/share/:/usr/share/
$xdgpaths = $XDG_DATA_HOME:$XDG_DATA_DIRS
$searchpaths = $xdgpaths, and append /openscad/libraries/ to each part separated by ':'
if $OPENSCADPATH is defined
    $searchpaths = $OPENSCADPATH:$searchpaths
for every $part of $searchpaths split by ':'
    if file $part/$x is readable:
        include that file

this also catches the current default paths /usr/share/openscad/libraries or /usr/local/share/openscad/libraries. if other paths can be configured at compile time, they should be appended to $searchpaths. (ie the default paths should stay there to conform to basedir spec).

Owner

kintel commented Apr 11, 2013

Specs are good, but in this case I ask myself if any software actually supports ~/.local/share/ as a place to put user files, and if users actually find that useful (or find that folder at all).

If all library handling was done through the GUI and the users wouldn't need to browse the file system, it would be a different story..

..or perhaps I've been using a Mac for too long and unlearnt that dot-files are supposed to be user-editable ;)

Contributor

chrysn commented Apr 11, 2013

i currently have over fifty directories in there (savegames, nautilus' right-click scripts, gajim plugins, ...). users have to be pointed to the location where they should install their libraries anyway, unless they use OPENSCADPATH, and i'd consider it bad style to require well-known non-dotfiles in a user's home directory.

for easy access, the openscad options could offer a "open library directory" button in the preferences (or one for every searched path).

Owner

kintel commented Apr 11, 2013

I like the "open library directory" function

rohieb commented Apr 17, 2013

I support @chrysn's motion about using XDG config dirs like ~/.local/share/openscad/lib. Canonical non-dot directories seem like a strange concept on Linux (I know only two applications that use non-dotdirs for their purpose, and I'm irritated every time I see those in ls -l). But in this case, an "open library directory" menu item is the absolute must for the lesser Linux-savvy users.

Owner

kintel commented May 21, 2013

For Windows, I suggest My Documents\OpenSCAD\libraries\

Owner

kintel commented May 21, 2013

Done:

  • Added menu entry: Show Library Folder
  • Added Windows path (My Documents) - needs testing!
  • Added Linux/Unix path (~/.local/share)

Missing:

  • XDG compliance (but we can live without it for a while - if it doesn't get done this or next week I'll open a new issue and release the next version as is).

This was referenced May 21, 2013

Owner

kintel commented May 25, 2013

Created separate issue #373 for XDG compliance. closing this.

@kintel kintel closed this May 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment