Rstan & StanHeaders merger? A heads-up!

Ok, I see. Thanks for the replies!

Also, correct me if I am wrong but don’t think that cmdstanr will be making it to CRAN anytime soon. So rstan is the only option to have CRAN packages that use Stan.

1 Like

It depends on what “anytime soon” means. We are close to closing all 1.0-release milestone issues and will then go with a RC and then CRAN.

Cant really give an exact timeline for this but I am hoping it will be this year.

1 Like

I got the following update from NumFOCUS:

our team is actively discussing this question with various channels (legal, our board etc.) We hope to have an answer for you shortly. GPL’s are challenging so we want to make sure we get a definitive response. Thanks for your patience.

So a little bit more patients but they are working on an answer for us.

3 Likes

Okay, that definitely sounds like quite soont then, great!

@wds15, we got a reply from the legal team at NumFOCUS:

There is no problem with combining the software as they propose. As I understand it, we have:

StanHeaders (BSD-3-Clause)
including
StanMath
including
RStan (GPLv3+).

On compilation, StanHeaders and RStan are combined.

It is acceptable to combine GPLv3 software with BSD-3- Clause-licensed software. It’s a bit inaccurate to say the GPL license requires “relicensing” of third-party software that is already under a different license. The accurate statement is that any software combined with GPL software cannot have compliance requirements that are inconsistent with those in the GPL license. So as long as the third party license’s terms are consistent in all ways with the GPL, then they can be combined.

The requirements for the BSD-3-Clause are:

The copyright notice and a copy of the license must be included in source code.
The copyright notice and a copy of the license must be included in materials provided with a binary distribution.
One cannot use the name of the author of the code to promote products.
There is a waiver of warranty and liability.

The GPLv3 license has these same requirements in Section 4, stating that copyright notices must be retained and a copy of the license must be provided. The GPLv3 also has similar warranty disclaimer language. So there is nothing in the 3 Clause BSD license that imposes any different requirements than what the GPL also requires, so they are considered “compatible.”

The Free Software Foundation, the license steward of the GPL license, lists the Modified BSD License (another name for the 3 Clause BSD license) under its category of “GPL-Compatible Free Software Licenses.” So the Free Software Foundation believes it’s acceptable to combine them.

Conceptually, when you do combine them you can think of it as having passed along fewer rights in the BSD software than you received, which one is allowed to do with permissive licenses. Another way to think of it is that the BSD-licensed software now has a new layer of added restraints, for example a new duty to provide the source code. However in reality no one thinks of it these ways, because of course anyone can always just go to the original source for the BSD code and get a copy without any added restrictions. The Software Freedom Law Center also publishes a guide on maintaining permissively licensed software in a GPL distribution if you’re interested in maintaining a more freely licensed version of permissively licensed software alongside the GPL code.

I hope that helps, and let me know if there are any follow-up questions or you want to have a call about it.

Does this help to move forward or would you like for me to arrange the call that is offered?

3 Likes

Thanks a lot for the info so far. This describes our current state of things. My question is toward how we would like to change things to. In a future version we would like to have

rstan - being GPLv3 - bundles the Stan-math sources in a sub-directory. So Stan-math (BSD licences) is contained in a sub-directory of rstan now.

StanHeaders - currently this is BSD-3 - will NOT anymore include Stan-math sources, but only act as a proxy to the Stan-math sources which live under rstan / Stan-math.

The question now is, can StanHeaders stay BSD-3 or not? R package used to include from StanHeaders say the file stan/math/rev.hpp with the actual source code. In the future the file stan/math/rev.hpp as part of StanHeaders will NOT anymore contain the actual source code, but instead it will include the correct content of the file as part of rstan / stan-math. So you only get to include the correct source in an indirect way. The issue now is that rstan as a whole is GPL-3, but the sub-directory with Stan-math is BSD… what’s now the license for this new “proxy” StanHeaders.

Is that now clearer?

Maybe we should have a call on this, sure.

1 Like

Hi!

After iterating a bit, I do think we now have clarity! The short news is that we can have a “StanHeaders”-proxy style R package. Such a proxy style StanHeaders would pull its Stan-math sources from a sub-directory of rstan. While rstan is as a whole GPL-3, the Stan-math contained in it (as a sub-directory) can stay as BSD. R packages only relying on the new StanHeaders proxy can stay BSD licensed! That’s great news. Here is the full answer from NumFocus:

As I understand it, rather than the original structure I analyzed:

StanHeaders (BSD-3-Clause)
including
StanMath
including
RStan (GPLv3+).

the proposal is now to change it to:

RStan (GPLv3+)
has subdirectory of StanHeaders (BSD-3-Clause)
StanMath (BSD-3-Clause) will also use the StanHeaders program that is in the RStan subdirectory, but by including it rather than have a second copy of the source code within StanMath

I’m not sure what “R package” is, but I’m assuming it is the above software collection after it is compiled.

If I have accurately described the proposed change, this arrangement is also fine.

The GPL says “You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged.” However, one cannot change the license for someone else’s code. Only the copyright owner has the right to grant a license. Therefore this requirement in the GPLv3+ that one must “license the entire work” is understood to mean that one must comply with both licenses at the same time, the GPLv3+ and, in the case of StanHeaders, the BSD-3-Clause. There is nothing in the BSD-3-Clause license that prohibits adding on more requirements, such as those found in the GPLv3+. (This is the same reason that BSD-3-Clause software can be included in proprietary software, with licenses the prohibit redistribution and reverse engineering, etc.) What changes is that when distributing StanHeaders as part of RStan, one must now also provide the source code and meet the other additional requirements of the GPLv3+, which one would not have to do if you were distributing StanHeaders by itself.

So StanHeaders is still under the BSD-3-Clause license, but because it is a part of RStan, you will also have to comply with the GPL license requirements for StanHeaders. When it is distributed separately from RStan, then one only has to meet the requirements of the BSD-3-Clause license. For example, if you were to distribute a compiled version that had only StanMath and StanHeaders, both under the BSD-3-Clause license, you would have to comply only with the BSD-3-Clause license, not the GPLv3+.

@bgoodri @hsbadr

It would be great to have a discussion on this on one of the next Stan meetings. With the above answer from NumFOCUS lawyers it should be OK to move to a StanHeaders proxy package as described above. The question to the Stan meeting would be if that is a shared understanding such that we can start to restructure things along these lines. Users of StanHeaders will get to use a BSD style package like before; it’s just that the file contents would have been moved to rstan without imparting the BSD licence status.

4 Likes