Skip to content

Commit a08fb60

Browse files
committed
LICENSE: split license file in standard BSD 3-clause and bundled.
Reason: the GitHub license detection method relies on the LICENSE file matching for at least 95% with a standard license. Adding even one more sentence changes the license displayed in the GitHub UI and also in the GitHub API that can be queried from BSD to "other". See numpy#13447 for more details. Note that this split license is what GitHub recommends to do, and is also what we do for wheels, where we append to the license file at build time.
1 parent f64ec0c commit a08fb60

File tree

3 files changed

+61
-31
lines changed

3 files changed

+61
-31
lines changed

LICENSE.txt

-30
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2828
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2929
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3030
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31-
32-
33-
34-
The NumPy repository and source distributions bundle several libraries that are
35-
compatibly licensed. We list these here.
36-
37-
Name: Numpydoc
38-
Files: doc/sphinxext/numpydoc/*
39-
License: 2-clause BSD
40-
For details, see doc/sphinxext/LICENSE.txt
41-
42-
Name: scipy-sphinx-theme
43-
Files: doc/scipy-sphinx-theme/*
44-
License: 3-clause BSD, PSF and Apache 2.0
45-
For details, see doc/scipy-sphinx-theme/LICENSE.txt
46-
47-
Name: lapack-lite
48-
Files: numpy/linalg/lapack_lite/*
49-
License: 3-clause BSD
50-
For details, see numpy/linalg/lapack_lite/LICENSE.txt
51-
52-
Name: tempita
53-
Files: tools/npy_tempita/*
54-
License: BSD derived
55-
For details, see tools/npy_tempita/license.txt
56-
57-
Name: dragon4
58-
Files: numpy/core/src/multiarray/dragon4.c
59-
License: One of a kind
60-
For license text, see numpy/core/src/multiarray/dragon4.c

LICENSE_bundled.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
The NumPy repository and source distributions bundle several libraries that are
2+
compatibly licensed. We list these here.
3+
4+
Name: Numpydoc
5+
Files: doc/sphinxext/numpydoc/*
6+
License: 2-clause BSD
7+
For details, see doc/sphinxext/LICENSE.txt
8+
9+
Name: scipy-sphinx-theme
10+
Files: doc/scipy-sphinx-theme/*
11+
License: 3-clause BSD, PSF and Apache 2.0
12+
For details, see doc/scipy-sphinx-theme/LICENSE.txt
13+
14+
Name: lapack-lite
15+
Files: numpy/linalg/lapack_lite/*
16+
License: 3-clause BSD
17+
For details, see numpy/linalg/lapack_lite/LICENSE.txt
18+
19+
Name: tempita
20+
Files: tools/npy_tempita/*
21+
License: BSD derived
22+
For details, see tools/npy_tempita/license.txt
23+
24+
Name: dragon4
25+
Files: numpy/core/src/multiarray/dragon4.c
26+
License: One of a kind
27+
For license text, see numpy/core/src/multiarray/dragon4.c

setup.py

+34-1
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,45 @@ def check_submodules():
186186
raise ValueError('Submodule not clean: %s' % line)
187187

188188

189+
class concat_license_files():
190+
"""Merge LICENSE.txt and LICENSE_bundled.txt for sdist creation
191+
192+
Done this way to keep LICENSE.txt in repo as exact BSD 3-clause (see
193+
gh-13447). This makes GitHub state correctly how NumPy is licensed.
194+
"""
195+
def __init__(self):
196+
self.f1 = 'LICENSE.txt'
197+
self.f2 = 'LICENSE_bundled.txt'
198+
199+
def __enter__(self):
200+
"""Concatenate files and remove LICENSE_bundled.txt"""
201+
with open(self.f1, 'r') as f1:
202+
self.bsd_text = f1.read()
203+
204+
with open(self.f1, 'a') as f1:
205+
with open(self.f2, 'r') as f2:
206+
self.bundled_text = f2.read()
207+
f1.write('\n\n')
208+
f1.write(self.bundled_text)
209+
210+
os.remove(self.f2)
211+
212+
def __exit__(self, exception_type, exception_value, traceback):
213+
"""Restore content of both files"""
214+
with open(self.f1, 'w') as f:
215+
f.write(self.bsd_text)
216+
217+
with open(self.f2, 'w') as f:
218+
f.write(self.bundled_text)
219+
220+
189221
from distutils.command.sdist import sdist
190222
class sdist_checked(sdist):
191223
""" check submodules on sdist to prevent incomplete tarballs """
192224
def run(self):
193225
check_submodules()
194-
sdist.run(self)
226+
with concat_license_files():
227+
sdist.run(self)
195228

196229

197230
def generate_cython():

0 commit comments

Comments
 (0)