@@ -1035,13 +1035,10 @@ upstream is ``$SAGE_ROOT/upstream/FoO-1.3.tar.gz``, create a new file
1035
1035
tarball=FoO-VERSION.tar.gz
1036
1036
1037
1037
Sage internally replaces the ` ` VERSION` ` substring with the content of
1038
- ` ` package-version.txt` ` . To recompute the checksums, run::
1038
+ ` ` package-version.txt` ` .
1039
1039
1040
- [alice@localhost sage]$ sage --package fix-checksum foo
1041
-
1042
- which will modify the ` ` checksums.ini` ` file with the correct
1043
- checksums.
1044
1040
1041
+ .. _section-spkg-upstream-urls:
1045
1042
1046
1043
Upstream URLs
1047
1044
-------------
@@ -1068,39 +1065,33 @@ For Python packages available from PyPI, you should use an
1068
1065
1069
1066
upstream_url=https://pypi.io/packages/source/m/matplotlib/matplotlib-VERSION.tar.gz
1070
1067
1071
- A package that has the ` ` upstream_url` ` information can be updated by
1072
- simply typing::
1073
-
1074
- [alice@localhost sage]$ sage --package update numpy 3.14.59
1068
+ Developers who wish to test a package update from a PR branch before
1069
+ the archive is available on a Sage mirror. Sage falls back to
1070
+ downloading package tarballs from the ` ` upstream_url` ` after trying all
1071
+ Sage mirrors. (This can be disabled by using ` ` ./configure
1072
+ --disable-download-from-upstream-url` ` .) To speed up this process,
1073
+ you can trim ` ` upstream/mirror_list` ` to fewer mirrors.
1075
1074
1076
- which will automatically download the archive and update the
1077
- information in ` ` build/pkgs/` ` .
1078
1075
1079
- For Python packages available from PyPI, there is another shortcut: :
1076
+ .. _section-sage-package-command :
1080
1077
1081
- [alice@localhost sage]$ sage --package update-latest matplotlib
1082
- Updating matplotlib: 3.3.0 -> 3.3.1
1083
- Downloading tarball to ...matplotlib-3.3.1.tar.bz2
1084
- [...............................................................]
1078
+ Utility script to create and maintain packages
1079
+ ==============================================
1085
1080
1086
- The ` ` upstream_url` ` information serves yet another purpose.
1087
- Developers who wish to test a package update from a PR branch before
1088
- the archive is available on a Sage mirror can do so by configuring
1089
- their Sage tree using ` ` ./configure
1090
- --enable-download-from-upstream-url` ` . Then Sage will fall back to
1091
- downloading package tarballs from the ` ` upstream_url` ` after trying all
1092
- Sage mirrors. (To speed up this process, trim ` ` upstream/mirror_list` `
1093
- to fewer mirrors.)
1094
- It is then no longer necessary to manually download upstream tarballs.
1081
+ The command ` ` sage --package` ` offers a range of functionality for
1082
+ creating and maintaining packages of the Sage distribution.
1095
1083
1096
1084
1097
- Utility script to create packages
1098
- =================================
1085
+ Creating packages
1086
+ -----------------
1099
1087
1100
1088
Assuming that you have downloaded
1101
1089
` ` $SAGE_ROOT /upstream/FoO-1.3.tar.gz` ` , you can use::
1102
1090
1103
- [alice@localhost sage]$ sage --package create foo --version 1.3 --tarball FoO-VERSION.tar.gz --type experimental
1091
+ [alice@localhost sage]$ sage --package create foo \
1092
+ --version 1.3 \
1093
+ --tarball FoO-VERSION.tar.gz \
1094
+ --type experimental
1104
1095
1105
1096
to create ` ` $SAGE_ROOT /build/pkgs/foo/package-version.txt` ` ,
1106
1097
` ` checksums.ini` ` , and ` ` type` ` in one step.
@@ -1111,22 +1102,132 @@ set the ``upstream_url`` field in ``checksums.ini`` described above.
1111
1102
1112
1103
For Python packages available from PyPI, you can use::
1113
1104
1114
- [alice@localhost sage]$ sage --package create scikit_spatial --pypi --type optional
1105
+ [alice@localhost sage]$ sage --package create scikit_spatial --pypi \
1106
+ --type optional
1115
1107
1116
1108
This automatically downloads the most recent version from PyPI and also
1117
1109
obtains most of the necessary information by querying PyPI.
1110
+
1118
1111
The ` ` dependencies` ` file may need editing (watch out for warnings regarding
1119
1112
` ` --no-deps` ` that Sage issues during installation of the package! ).
1120
1113
Also you may want to set lower and upper bounds for acceptable package versions
1121
1114
in the file ` ` install-requires.txt` ` .
1122
1115
1123
- To create a pip package rather than a normal package, you can use::
1116
+ By default, when the package is available as a platform-independent
1117
+ wheel, the ` ` sage --package` ` creates a wheel package. To create a normal package
1118
+ instead (for example, when the package requires patching), you can use::
1119
+
1120
+ [alice@localhost sage]$ sage --package create scikit_spatial --pypi \
1121
+ --source normal \
1122
+ --type optional
1123
+
1124
+ To create a pip package rather than a normal or wheel package, you can use::
1125
+
1126
+ [alice@localhost sage]$ sage --package create scikit_spatial --pypi \
1127
+ --source pip \
1128
+ --type optional
1129
+
1130
+ When the package already exists, ` ` sage --package create` ` overwrites it.
1124
1131
1125
- [alice@localhost sage]$ sage --package create scikit_spatial --pypi --source pip --type optional
1126
1132
1127
- To create a wheel package rather than a normal package, you can use::
1133
+ Updating packages to a new version
1134
+ ----------------------------------
1135
+
1136
+ A package that has the ` ` upstream_url` ` information can be updated by
1137
+ simply typing::
1138
+
1139
+ [alice@localhost sage]$ sage --package update numpy 3.14.59
1140
+
1141
+ which will automatically download the archive and update the
1142
+ information in ` ` build/pkgs/numpy/` ` .
1143
+
1144
+ For Python packages available from PyPI, there is another shortcut::
1145
+
1146
+ [alice@localhost sage]$ sage --package update-latest matplotlib
1147
+ Updating matplotlib: 3.3.0 -> 3.3.1
1148
+ Downloading tarball to ...matplotlib-3.3.1.tar.bz2
1149
+ [...............................................................]
1150
+
1151
+ If you pass the switch ` ` --commit` ` , the script will run ` ` git commit` `
1152
+ for you.
1153
+
1154
+ If you prefer to make update a package ` ` foo` ` by making manual
1155
+ changes to the files in ` ` build/pkgs/foo` ` , you will need to run::
1156
+
1157
+ [alice@localhost sage]$ sage --package fix-checksum foo
1158
+
1159
+ which will modify the ` ` checksums.ini` ` file with the correct
1160
+ checksums.
1161
+
1128
1162
1129
- [alice@localhost sage]$ sage --package create scikit_spatial --pypi --source wheel --type optional
1163
+ Obtaining package metrics
1164
+ -------------------------
1165
+
1166
+ The command ` ` sage --package metrics` ` computes machine-readable
1167
+ aggregated metrics for all packages in the Sage distribution or a
1168
+ given list of packages::
1169
+
1170
+ [alice@localhost sage]$ sage --package metrics
1171
+ has_file_distros_arch_txt=181
1172
+ has_file_distros_conda_txt=289
1173
+ has_file_distros_debian_txt=172
1174
+ has_file_distros_fedora_txt=183
1175
+ has_file_distros_gentoo_txt=211
1176
+ has_file_distros_homebrew_txt=95
1177
+ has_file_distros_macports_txt=173
1178
+ has_file_distros_nix_txt=72
1179
+ has_file_distros_opensuse_txt=206
1180
+ has_file_distros_slackware_txt=32
1181
+ has_file_distros_void_txt=221
1182
+ has_file_patches=63
1183
+ has_file_spkg_check=106
1184
+ has_file_spkg_configure_m4=262
1185
+ has_file_spkg_install=322
1186
+ has_tarball_upstream_url=291
1187
+ line_count_file_patches=31904
1188
+ line_count_file_spkg_check=585
1189
+ line_count_file_spkg_configure_m4=3337
1190
+ line_count_file_spkg_install=4342
1191
+ packages=442
1192
+ type_base=1
1193
+ type_experimental=18
1194
+ type_optional=151
1195
+ type_standard=272
1196
+
1197
+ Developers can use these metrics to monitor the complexity and quality
1198
+ of the Sage distribution. Here are some examples:
1199
+
1200
+ - ` ` has_file_patches` ` indicates how many packages have non-empty
1201
+ ` ` patches/` ` directories, and ` ` line_count_file_patches` ` gives
1202
+ the total number of lines in the patch files.
1203
+
1204
+ Ideally, we would not have to carry patches for a
1205
+ package. For example, updating patches when a new upstream version
1206
+ is released can be a maintenance burden.
1207
+
1208
+ Developers can help by working with the upstream maintainers of the
1209
+ package to prepare a new version that requires fewer or smaller
1210
+ patches, or none at all.
1211
+
1212
+ - ` ` line_count_spkg_install` ` gives the total number of lines in
1213
+ ` ` spkg-install` ` or ` ` spkg-install.in` ` files; see
1214
+ :ref:` section-spkg-install` .
1215
+
1216
+ When we carry complex ` ` spkg-install.in` ` scripts for normal packages,
1217
+ it may indicate that the upstream package' s build and installation
1218
+ scripts should be improved.
1219
+
1220
+ Developers can help by working with the upstream maintainers of the
1221
+ package to prepare an improved version.
1222
+
1223
+ - ``has_file_spkg_check`` indicates how many packages have an
1224
+ ``spkg-check`` or ``spkg-check.in`` file; see :ref:`section-spkg-check`.
1225
+
1226
+ - ``has_file_spkg_configure_m4`` indicates how many packages
1227
+ are prepared to check for an equivalent system package, and
1228
+ ``has_file_distros_arch_txt``, ``has_file_distros_conda_txt``
1229
+ etc. count how many packages provide the corresponding system package
1230
+ information.
1130
1231
1131
1232
1132
1233
.. _section-manual-build:
@@ -1136,9 +1237,7 @@ Building the package
1136
1237
1137
1238
At this stage you have a new tarball that is not yet distributed with
1138
1239
Sage (``FoO-1.3.tar.gz`` in the example of section
1139
- :ref:` section-directory-structure` ). Now you need to manually place it
1140
- in the ` ` SAGE_ROOT/upstream/` ` directory and run
1141
- ` ` sage --fix-pkg-checksums` ` if you have not done that yet.
1240
+ :ref:`section-directory-structure`).
1142
1241
1143
1242
Now you can install the package using::
1144
1243
@@ -1157,8 +1256,7 @@ or::
1157
1256
1158
1257
[alice@localhost sage]$ sage -f -c package_name
1159
1258
1160
- If all went fine, open a PR, put a link to the original tarball in
1161
- the PR and upload a branch with the code under
1259
+ If all went fine, open a PR with the code under
1162
1260
``SAGE_ROOT/build/pkgs``.
1163
1261
1164
1262
0 commit comments