cmdstan
cmdstan copied to clipboard
ease use of cmdstan makefiles
Summary:
This aims to simplify how users can use cmdstan with its makefiles.
Description:
Currently users have to change into the directory of cmdstan in order to build any Stan program like
cd path/to/cmdstan
make path/to/model
It would be much nicer if the user would not have to change into the directory of cmdstan, but can merely do this in any directory:
make -f path/to/cmdstan/makefile model
This currently does not work as the makefiles expect to be in the top-level directory of cmdstan. If the above would work, then users can define an alias like
alias stanmake=`make -f absolute/path/to/cmdstan/makefile`
and then people can just to
stanmake model
and that's it. Much simpler.
Reproducible Steps:
NA
Current Output:
NA
Expected Output:
NA
Additional Information:
Provide any additional information here.
Current Version:
v2.21.0
This doesn’t work if there are spaces in paths. This is a technical limitation that’s introduced by make: I haven’t found a way to escape the target if there’s a space.
If you have a workaround, it’d be great to know about it!
On Wed, Jan 8, 2020 at 5:23 AM wds15 [email protected] wrote:
Summary:
This aims to simplify how users can use cmdstan with its makefiles. Description:
Currently users have to change into the directory of cmdstan in order to build any Stan program like
cd path/to/cmdstan make path/to/model
It would be much nicer if the user would not have to change into the directory of cmdstan, but can merely do this in any directory:
make -f path/to/cmdstan/makefile model
This currently does not work as the makefiles expect to be in the top-level directory of cmdstan. If the above would work, then users can define an alias like
alias stanmake=
make -f absolute/path/to/cmdstan/makefile
and then people can just to
stanmake model
and that's it. Much simpler. Reproducible Steps:
NA Current Output:
NA Expected Output:
NA Additional Information:
Provide any additional information here. Current Version:
v2.21.0
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stan-dev/cmdstan/issues/791?email_source=notifications&email_token=AADH6F6TGJEV476ZOIYU2ZTQ4WSQPA5CNFSM4KEGBVL2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEXBURQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADH6F2B72FRRMBENTLPN43Q4WSQPANCNFSM4KEGBVLQ .
but it will work without spaces. I don't see it as a necessary requirement to have this functionality working with spaces (but we should mention that with spaces it breaks, sure).
agree with Daniel - it needs to work for all legal filepaths on *nix, Mac, and Windows.
That's not what @syclik said to my understanding.
I think we should make it work as described above for cases where no spaces are involved. We can still give as default in our manuals the instruction to cd into the cmdstan dir. Only those user who do not use spaces in their paths have an additional and very comfortable option.
Other wise we can cose the issue.
I think we should make it work as described above for cases where no spaces are involved. We can still give as default in our manuals the instruction to cd into the cmdstan dir. Only those user who do not use spaces in their paths have an additional and very comfortable option.
Is the issue with spaces in the directory in which cmdstan is installed or in the Stan program file?
What's the relation between cd-ing to the cmdstan directory and spaces?
Do our current makefiles work with spaces in cmdstan directory and/or in program files?
The issue will be present if there are spaces in the path (including the file name) of the Stan program.
I tried to do this once and I believe in order to implement this well, it will introduce a problem where our current build will no longer work in directories with spaces, but someone better at make might be able to figure out a better solution using make.
I’d suggest building a separate bash script to do this instead of make. Make can return the include paths as a string and the bash script can use that to build starting in arbitrary paths and build in paths that have spaces. That would be much easier to get right.
On Thu, Jan 9, 2020 at 5:15 PM Bob Carpenter [email protected] wrote:
I think we should make it work as described above for cases where no spaces are involved. We can still give as default in our manuals the instruction to cd into the cmdstan dir. Only those user who do not use spaces in their paths have an additional and very comfortable option.
Is the issue with spaces in the directory in which cmdstan is installed or in the Stan program file?
What's the relation between cd-ing to the cmdstan directory and spaces?
Do our current makefiles work with spaces in cmdstan directory and/or in program files?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/stan-dev/cmdstan/issues/791?email_source=notifications&email_token=AADH6F7JGKK4N2TP6Q563E3Q46OXJA5CNFSM4KEGBVL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIR7H3Q#issuecomment-572781550, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADH6F7WM2KSUDOZSHVDRX3Q46OXJANCNFSM4KEGBVLQ .
Do our current makefiles work with spaces in cmdstan directory and/or in program files?
They do not.
But if the location of your cmdstan folder is /home/user/folder withspaces/cmdstan
and you compile a model in a location without spaces, for example make /home/user/test/model
, that will work. make /home/user/test spaces/model
however wont.
With this approach if you cd to /home/user/test/
and run make -f /home/user/folder withspaces/cmdstan/make/makefil model
it wont work, because cmdstan is in a location with spaces.
However, if you put cmdstan in a location without spaces, this solution would actually allow compiling models in locations with spaces. So you could compile both models in the first example. Hopefully I am making some sense. So we can look at this as a solution for those cases, barring the user installs cmdstan in a location without spaces.
@syclik yeah, using bash stuff makes things easily work. So I have defined myself a bash function which is
function stanmake
{
make -f /absolute/path/to/cmdstan/makefile -C /absolute/path/to/cmdstan/ "${PWD}/$1"
}
which does its job just fine... it's just that this is a bash-only solution and if our makefiles would be a bit more robust, then an alias can be set which should work without requiring bash if I am not wrong.
@wds15, that isn’t what I meant. I meant you could write a bash script that calls make to return back the right compiler invocation, i.e. clang++ -I...
And then from the bash file call the compiler : linker directly. Once everything in CmdStan is built, there should be only a few steps: calling the stanc compiler to go from Stan to hpp, compiling the hpp properly using the c++ compiler, and linking the c++ program using either the c++ compiler or linker.
On Fri, Jan 10, 2020 at 3:32 AM wds15 [email protected] wrote:
@syclik https://github.com/syclik yeah, using bash stuff makes things easily work. So I have defined myself a bash function which is
function stanmake { make -f /absolute/path/to/cmdstan/makefile -C /absolute/path/to/cmdstan/ "${PWD}/$1" }
which does its job just fine... it's just that this is a bash-only solution and if our makefiles would be a bit more robust, then an alias can be set which should work without requiring bash if I am not wrong.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/stan-dev/cmdstan/issues/791?email_source=notifications&email_token=AADH6F3JWFOIHOIUOSWPMPLQ5AXBFA5CNFSM4KEGBVL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEITDDNY#issuecomment-572928439, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADH6F6CM2AIY64M6MSZVUDQ5AXBFANCNFSM4KEGBVLQ .
Hmm... I am not sure I follow along. I anyway just wanted to share what I have configured on our systems for me.
But this leads me to another way to approach this: We could add a stanmake.sh
file to the bin
directory of cmdstan
. This can be generated on the fly from the makefiles during build. Then people can merely add to their PATH
variable the bin
sub-folder and everything will work just fine. This is probably doable with ugly spaces in the path leading to cmdstan as the script will look like
#!/bin/bash
MODEL="$PWD/$1"
cd absolute/path/to/cmdstan
make $MODEL
How about that?
does this work with the git commands - make stan-update
?
I agree with the suggestion that we write a script to compile models - I don't see how you can change the makefile, because there are a bunch of tasks that only make sense if you're in the top-level CmdStan directory - all of the build
tasks, ditto developer tasks - maintaining existing tools, testing, etc.
This ticket here targets end-users who do a make build
a single time. This can be expected to be done in the top-level directory. After having done that, it would be much nicer for users to not being forced to change for every Stan model they want to compile into the top-level dir of cmdstan. Compilation of Stan models should work just anywhere in file system.
So creating a bin/stanmake.sh
with the build
target and then asking users to add that bin directory to the PATH is a solution for that, I think.
note that proposal for CmdStan3 would remove need for this feature: https://github.com/stan-dev/design-docs/blob/cmdstan3/designs/0005-cmdstan3.md