change structure
Browse files- 02-cran-licenses.R +58 -52
- 03-cran-process.R +4 -1
- README.md +13 -14
- data/r/data-0.parquet +2 -2
- data/rmd/data-0.parquet +2 -2
- packages.parquet +2 -2
02-cran-licenses.R
CHANGED
@@ -100,13 +100,6 @@ parse_license <- function(license) {
|
|
100 |
)
|
101 |
}
|
102 |
|
103 |
-
# this list is based in the licenses.json file from the stack dataset
|
104 |
-
# see: https://huggingface.co/datasets/bigcode/the-stack-dedup/blob/main/licenses.json
|
105 |
-
|
106 |
-
allowed_license_codes <- c("MIT", "Apache", "BSD", "CC-BY", "Artistic", "CC0",
|
107 |
-
"FreeBSD")
|
108 |
-
|
109 |
-
|
110 |
# we now make the indirection from allowed codes to allowed License as specified
|
111 |
# in the DESCRIPTION.
|
112 |
license_codes <- licenses_table %>%
|
@@ -115,50 +108,63 @@ license_codes <- licenses_table %>%
|
|
115 |
) %>%
|
116 |
unnest(parsed)
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
# We then filter the allowed packages.
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
left_join(license_codes, by = "license", relationship = "many-to-many") %>%
|
133 |
-
count(license_code) %>%
|
134 |
-
mutate(n / nrow(licenses)) %>%
|
135 |
-
arrange(desc(n)) %>%
|
136 |
-
print(n = 100)
|
137 |
-
|
138 |
-
# # A tibble: 24 × 3
|
139 |
-
# license_code n `n/nrow(licenses)`
|
140 |
-
# <chr> <int> <dbl>
|
141 |
-
# 1 GPL 18440 0.726
|
142 |
-
# 2 MIT 4533 0.179
|
143 |
-
# 3 LGPL 556 0.0219
|
144 |
-
# 4 Apache 428 0.0169
|
145 |
-
# 5 BSD-Clause 343 0.0135
|
146 |
-
# 6 CC0 261 0.0103
|
147 |
-
# 7 AGPL 232 0.00914
|
148 |
-
# 8 Artistic 158 0.00622
|
149 |
-
# 9 NA 96 0.00378
|
150 |
-
# 10 Unlimited 76 0.00299
|
151 |
-
# 11 CC-BY 56 0.00221
|
152 |
-
# 12 MPL 52 0.00205
|
153 |
-
# 13 EUPL 35 0.00138
|
154 |
-
# 14 CC-BY-SA 34 0.00134
|
155 |
-
# 15 CeCILL 34 0.00134
|
156 |
-
# 16 BSD 33 0.00130
|
157 |
-
# 17 CC-BY-NC-SA 27 0.00106
|
158 |
-
# 18 FreeBSD 18 0.000709
|
159 |
-
# 19 BSL 10 0.000394
|
160 |
-
# 20 CC-BY-NC 6 0.000236
|
161 |
-
# 21 EPL 6 0.000236
|
162 |
-
# 22 ACM 5 0.000197
|
163 |
-
# 23 CPL 3 0.000118
|
164 |
-
# 24 CC-BY-NC-ND 1 0.0000394
|
|
|
100 |
)
|
101 |
}
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
# we now make the indirection from allowed codes to allowed License as specified
|
104 |
# in the DESCRIPTION.
|
105 |
license_codes <- licenses_table %>%
|
|
|
108 |
) %>%
|
109 |
unnest(parsed)
|
110 |
|
111 |
+
# we now map license_codes to the same classification used by github
|
112 |
+
|
113 |
+
gh_license_table <- license_codes %>%
|
114 |
+
mutate(
|
115 |
+
license_gh = case_when(
|
116 |
+
classif == "GPL (>=2)" ~ "gpl-3.0",
|
117 |
+
classif == "GPL (>=3)" ~ "gpl-3.0",
|
118 |
+
classif == "GPL (==3)" ~ "gpl-3.0",
|
119 |
+
classif == "GPL (==2)" ~ "gpl-2.0",
|
120 |
+
classif == "GPL" ~ "gpl-3.0",
|
121 |
+
classif %in% c("GPL (==3) | LGPL (==2.1)", "GPL (>2)", "GPL (>3)", "GPL (>=1)") ~ "gpl-3.0",
|
122 |
+
classif %in% c("GPL (<=2)", "GPL (==2) | LGPL (==2.1) | MPL (==1.1)") ~ "gpl-2.0",
|
123 |
+
|
124 |
+
classif == "AGPL (>=2)" ~ "agpl-3.0",
|
125 |
+
classif == "AGPL (>=3)" ~ "agpl-3.0",
|
126 |
+
classif == "AGPL (==3)" ~ "agpl-3.0",
|
127 |
+
classif == "AGPL (==2)" ~ "agpl-2.0",
|
128 |
+
classif == "AGPL" ~ "agpl-3.0",
|
129 |
+
|
130 |
+
classif == "LGPL (>=2)" ~ "lgpl-3.0",
|
131 |
+
classif == "LGPL (>=3)" ~ "lgpl-3.0",
|
132 |
+
classif %in% c("LGPL (==3)", "LGPL (>2)", "LGPL (>=2.1)") ~ "lgpl-3.0",
|
133 |
+
classif %in% c("LGPL (==2)", "LGPL (>=2, <3)", "LGPL (>= 2.0, < 3)", "LGPL (==2.1)", "LGPL (>= 2.0, < 3) | MPL") ~ "lgpl-2.0",
|
134 |
+
classif == "LGPL" ~ "lgpl-3.0",
|
135 |
+
|
136 |
+
classif == "BSD" ~ "bsd-3-clause",
|
137 |
+
classif == "BSD-Clause (==2)" ~ "bsd-2-clause",
|
138 |
+
classif == "BSD-Clause (==3)" ~ "bsd-3-clause",
|
139 |
+
|
140 |
+
classif %in% c("BSL", "BSL (==1)") ~ "bsl-1.0",
|
141 |
+
str_detect(classif, fixed("CC-BY (==4)")) ~ "cc-by-4.0",
|
142 |
+
str_detect(classif, fixed("CC-BY-SA (==4)")) ~ "cc-by-sa-4.0",
|
143 |
+
str_detect(classif, "CC0") ~ "cc0-1.0",
|
144 |
+
str_detect(classif, "FreeBSD") ~ "bsd-2-clause",
|
145 |
+
|
146 |
+
classif %in% c("MPL (==2)", "MPL (>=2)", "MPL") ~ "mpl-2.0",
|
147 |
+
classif %in% c("EUPL", "EUPL (==1.1)") ~ "eupl-1.1",
|
148 |
+
classif %in% c("EPL", "EPL (>=1)") ~ "epl-2.0",
|
149 |
+
|
150 |
+
str_detect(classif, "Apache") ~ "apache-2.0",
|
151 |
+
str_detect(classif, "Artistic") ~ "artistic-2.0",
|
152 |
+
str_detect(classif, "MIT") ~ "mit",
|
153 |
+
str_detect(classif, fixed("BSD-Clause (==2)")) ~ "bsd-2-clause",
|
154 |
+
str_detect(classif, fixed("BSD-Clause (==3)")) ~ "bsd-3-clause",
|
155 |
+
str_detect(classif, fixed("MPL (==2)")) ~ "mpl-2.0",
|
156 |
+
|
157 |
+
str_detect(classif, fixed("GPL (>=2")) ~ "gpl-2.0",
|
158 |
+
str_detect(classif, fixed("GPL (>=3")) ~ "gpl-3.0",
|
159 |
+
TRUE ~ "unknown"
|
160 |
+
)
|
161 |
+
)
|
162 |
|
163 |
# We then filter the allowed packages.
|
164 |
+
packages <- licenses %>%
|
165 |
+
mutate(license = stringr::str_trim(license)) %>%
|
166 |
+
left_join(gh_license %>% select(license, license_gh) %>% distinct(), by = "license") %>%
|
167 |
+
mutate(license_gh = coalesce(license_gh, "unknown"))
|
168 |
+
|
169 |
+
arrow::write_parquet(packages, "packages.parquet")
|
170 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
03-cran-process.R
CHANGED
@@ -35,7 +35,6 @@ packages <- arrow::read_parquet("packages.parquet")
|
|
35 |
opt_out <- readr::read_lines("optout.txt")
|
36 |
|
37 |
repos <- jsonlite::read_json("repos.json") %>%
|
38 |
-
keep(\(repo) as.character(repo$name) %in% packages$package) %>%
|
39 |
discard(\(repo) as.character(repo$name) %in% opt_out)
|
40 |
|
41 |
library(future)
|
@@ -51,6 +50,10 @@ make_data <- function(repos, ext) {
|
|
51 |
purrr::discard(\(x) inherits(x, "try-error")) |>
|
52 |
dplyr::bind_rows()
|
53 |
|
|
|
|
|
|
|
|
|
54 |
arrow::write_dataset(
|
55 |
files,
|
56 |
path = fs::path("data", ext),
|
|
|
35 |
opt_out <- readr::read_lines("optout.txt")
|
36 |
|
37 |
repos <- jsonlite::read_json("repos.json") %>%
|
|
|
38 |
discard(\(repo) as.character(repo$name) %in% opt_out)
|
39 |
|
40 |
library(future)
|
|
|
50 |
purrr::discard(\(x) inherits(x, "try-error")) |>
|
51 |
dplyr::bind_rows()
|
52 |
|
53 |
+
files <- files %>%
|
54 |
+
select(package, path = filename, content, size = uncompressed_size) %>%
|
55 |
+
left_join(packages %>% select(package, license = license_gh), by = "package")
|
56 |
+
|
57 |
arrow::write_dataset(
|
58 |
files,
|
59 |
path = fs::path("data", ext),
|
README.md
CHANGED
@@ -17,23 +17,22 @@ The dataset has been constructed using the following steps:
|
|
17 |
|
18 |
- Downloaded latest version from all packages on CRAN (see last updated). The source code has been downloaded from the [GitHub mirror](https://github.com/cran).
|
19 |
- Identified the licenses from each package from their DESCRIPTION file, and classified each of them into some license_code. See the licenses.csv file.
|
20 |
-
- Extract R and Rmd source files from packages
|
21 |
|
22 |
Datasets are provided as parquet files containing the following columns:
|
23 |
|
24 |
```
|
25 |
-
FileSystemDataset with
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$ permissions <ext<octmode>> 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, …
|
32 |
-
$ crc32 <ext<hexmode>> 6aafc73e, 6c7082a5, b1fdeb73, 8f6a4e25, 16941e78, bdd4943b, 6d0a1…
|
33 |
-
$ offset <double> 39452, 40140, 40812, 41023, 41528, 42500, 43030, 44474, 45288, 45…
|
34 |
-
$ package <string> "devtools", "devtools", "devtools", "devtools", "devtools", "devt…
|
35 |
-
$ content <string> "#' Environment variables to set when calling R\n#'\n#' Devtools …
|
36 |
-
Call `print()` for full schema details
|
37 |
```
|
38 |
|
39 |
-
Last updated: Jun
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
- Downloaded latest version from all packages on CRAN (see last updated). The source code has been downloaded from the [GitHub mirror](https://github.com/cran).
|
19 |
- Identified the licenses from each package from their DESCRIPTION file, and classified each of them into some license_code. See the licenses.csv file.
|
20 |
+
- Extract R and Rmd source files from all packages and joined with the package LICENSES.
|
21 |
|
22 |
Datasets are provided as parquet files containing the following columns:
|
23 |
|
24 |
```
|
25 |
+
FileSystemDataset with 1 Parquet file
|
26 |
+
package: string
|
27 |
+
path: string
|
28 |
+
content: large_string
|
29 |
+
size: double
|
30 |
+
license: string
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
```
|
32 |
|
33 |
+
Last updated: Jun 6th 2023
|
34 |
+
|
35 |
+
## Changelog
|
36 |
+
|
37 |
+
- v1: Initial version
|
38 |
+
- dev: added all CRAN files and a license field that allows filtering out per license. Also removed some unused columns.
|
data/r/data-0.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:60481845a82468ff4a92ced68e0d33e0b76c1ef7e2b05cef7111c4895b0579ed
|
3 |
+
size 882431711
|
data/rmd/data-0.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a2070624530bb1b2e77d7aa776e6bc929adfc67ce6b7c6312231a7408a60cabf
|
3 |
+
size 130531987
|
packages.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f6ab697f536e6239ffb64780b67b4a81be108495837aac9e3e2488e6a28f4a4b
|
3 |
+
size 314409
|