Skip to content

Commit

Permalink
Convert license header to "proper" Apache 2 license header. (#767)
Browse files Browse the repository at this point in the history
It comes from here, which the NVIDIA legal team recommends:

https://gist.github.com/Rypac/7349957f95f0713143fda2f3d3bc10c8

Basically, the NVIDIA legal team requires that my code contributions
have an Apache 2 license header. If I were to contribute to an
existing file (which I want to do), I would have to manually change
each file's header for legal compliance. @danpovey said that going
ahead and changing all the file headers to an official Apache 2 header
sounded reasonable.

I used codemod (`pip install codemod`) for this, with the following
script:

```
read -r -d '' replacement << EOM
   Copyright     \1 See LICENSE for clarification regarding multiple authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
EOM

codemod --exclude-paths build -m -d . --extensions cu,h \
        "Copyright \(c\) (.+) See LICENSE for clarification regarding multiple authors" \
        "$replacement"

read -r -d '' replacement << EOM
   Copyright     \1 authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
EOM

codemod --exclude-paths build -m -d . --extensions cmake,py \
        "Copyright \(c\) (.+) authors" \
        "$replacement"

codemod --exclude-paths build -m -d .github --extensions yml \
        "Copyright \(c\) (.+) authors" \
        "$replacement"

read -r -d '' replacement << EOM
   Copyright     \1
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
EOM

codemod --exclude-paths build -d scripts --extensions sh \
        "Copyright \(c\) (.+)" \
        "$replacement"
```

Codemod, unlike sed, is interactive. I manually checked that every
replacement made sense. Note that I applied this only to .cu, .h,
.cmake, and .py files.

Co-authored-by: Daniel Galvez <[email protected]>
  • Loading branch information
galv and galv authored Jun 17, 2021
1 parent 565c01b commit 5aabac0
Show file tree
Hide file tree
Showing 244 changed files with 3,172 additions and 244 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/build-cpu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2021 Fangjun Kuang ([email protected])
# Copyright 2021 Fangjun Kuang ([email protected])

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# refer to https://github.com/actions/starter-workflows/pull/47/files

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2020 Fangjun Kuang ([email protected])
# Copyright 2020 Fangjun Kuang ([email protected])

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# refer to https://github.com/actions/starter-workflows/pull/47/files

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/build_conda.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2021 Xiaomi Corp. (author: Fangjun Kuang)
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# refer to https://github.com/actions/starter-workflows/pull/47/files

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/build_conda_cpu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2021 Xiaomi Corp. (author: Fangjun Kuang)
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# refer to https://github.com/actions/starter-workflows/pull/47/files

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/nightly-cpu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2021 Fangjun Kuang ([email protected])
# Copyright 2021 Fangjun Kuang ([email protected])

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: nightly-cpu

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/nightly-windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2021 Fangjun Kuang ([email protected])
# Copyright 2021 Fangjun Kuang ([email protected])

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: nightly-windows

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/run-tests-cpu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2021 Fangjun Kuang ([email protected])
# Copyright 2021 Fangjun Kuang ([email protected])

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# refer to https://github.com/actions/starter-workflows/pull/47/files

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2020 Fangjun Kuang ([email protected])
# Copyright 2020 Fangjun Kuang ([email protected])

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# refer to https://github.com/actions/starter-workflows/pull/47/files

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/style_check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2020 Fangjun Kuang ([email protected])
# Copyright 2020 Fangjun Kuang ([email protected])

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: style_check

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/windows-conda.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2021 Fangjun Kuang ([email protected])
# Copyright 2021 Fangjun Kuang ([email protected])

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


name: build-windows-conda
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Copyright (c) 2021 Fangjun Kuang ([email protected])
# Copyright 2021 Fangjun Kuang ([email protected])

# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


name: build-windows
Expand Down
14 changes: 13 additions & 1 deletion cmake/cub.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Copyright (c) 2020 Fangjun Kuang ([email protected])
# Copyright 2020 Fangjun Kuang ([email protected])
# See ../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function(download_cub)
if(CMAKE_VERSION VERSION_LESS 3.11)
Expand Down
14 changes: 13 additions & 1 deletion cmake/googletest.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Copyright (c) 2020 Fangjun Kuang ([email protected])
# Copyright 2020 Fangjun Kuang ([email protected])
# See ../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function(download_googltest)
if(CMAKE_VERSION VERSION_LESS 3.11)
Expand Down
14 changes: 13 additions & 1 deletion cmake/moderngpu.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Copyright (c) 2020 Mobvoi AI Lab, Beijing, China (authors: Fangjun Kuang)
# Copyright 2020 Mobvoi AI Lab, Beijing, China (authors: Fangjun Kuang)
# See ../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function(download_moderngpu)
if(CMAKE_VERSION VERSION_LESS 3.11)
Expand Down
14 changes: 13 additions & 1 deletion cmake/pybind11.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Copyright (c) 2020 Fangjun Kuang ([email protected])
# Copyright 2020 Fangjun Kuang ([email protected])
# See ../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function(download_pybind11)
if(CMAKE_VERSION VERSION_LESS 3.11)
Expand Down
14 changes: 13 additions & 1 deletion cmake/transform.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Copyright (c) 2021 Fangjun Kuang ([email protected])
# Copyright 2021 Fangjun Kuang ([email protected])
# See ../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This function is used to copy foo.cu to foo.cc
# Usage:
Expand Down
14 changes: 13 additions & 1 deletion k2/csrc/algorithms.cu
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
/**
* Copyright (c) 2020 Xiaomi Corporation (authors: Haowen Qiu)
* Copyright 2020 Xiaomi Corporation (authors: Haowen Qiu)
*
* See LICENSE for clarification regarding multiple authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <algorithm>
Expand Down
14 changes: 13 additions & 1 deletion k2/csrc/algorithms.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
/**
* Copyright (c) 2020 Xiaomi Corporation (authors: Daniel Povey, Haowen Qiu)
* Copyright 2020 Xiaomi Corporation (authors: Daniel Povey, Haowen Qiu)
*
* See LICENSE for clarification regarding multiple authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef K2_CSRC_ALGORITHMS_H_
Expand Down
14 changes: 13 additions & 1 deletion k2/csrc/algorithms_test.cu
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
/**
* Copyright (c) 2020 Xiaomi Corporation (authors: Haowen Qiu)
* Copyright 2020 Xiaomi Corporation (authors: Haowen Qiu)
*
* See LICENSE for clarification regarding multiple authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <gmock/gmock.h>
Expand Down
14 changes: 13 additions & 1 deletion k2/csrc/array.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
/**
* Copyright (c) 2020 Xiaomi Corporation (authors: Daniel Povey, Haowen Qiu)
* Copyright 2020 Xiaomi Corporation (authors: Daniel Povey, Haowen Qiu)
* Mobvoi Inc. (authors: Fangjun Kuang)
*
* See LICENSE for clarification regarding multiple authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef K2_CSRC_ARRAY_H_
Expand Down
Loading

0 comments on commit 5aabac0

Please sign in to comment.