Question

I frequently find myself wanting to use some small function from another library but end up not doing because it's not worth pulling another dependency.

Considering BSD/MIT licenses, if I just copy/paste a function from another package, what would be the legal requirement when licensing my code? Also, as matter of netiquette, what would be the preferable way to give credit to the original author?

I understand this depends on the specific circumstances of each situation. The safe way would be to always ask the upstream author what does he want, but, sometimes, this happens so frequently that having a a default proposition for the upstream author can make the interaction smoother.

Was it helpful?

Solution

You need to follow the terms of the license(s).1

1Honestly, that's it.


For the licenses you cite (BSD, MIT) there is nothing within the license terms that say you must use the entire module. In fact, both of those licenses give you explicit permission to do what you're suggesting.

MIT

including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software

BSD

Redistribution and use in source and binary forms, with or without modification, are permitted ...

So go ahead and take those functions out of those modules that you want in order to avoid creating a dependency upon a whole library.

But what you can't do is fail to attribute the source of the code you used. Both licenses require that you include a copy of the license as well as the copyright notice.

That may mean you need to put a prolog around the modules you copy and provide copyright attribution. Or you may have to modify the license files to explicitly call out what portions of your code were sourced from where. It's going to depend upon your project and the extent of how much you borrowed.

You also said:

The safe way would be to always ask the upstream author what does he want

But that's not quite true. The upstream author has already expressly told you their intent through the license terms that they have released their code under. You only need to contact the upstream author if you want to do something outside of the terms of the license.

Licensed under: CC-BY-SA with attribution
scroll top