Skip to content

Commit 6e0d890

Browse files
author
Matthias Koeppe
committed
src/doc/en/developer/packaging.rst: Consolidate section on 'sage --package', add subsection on '... metrics'
1 parent c22ebf1 commit 6e0d890

File tree

1 file changed

+136
-38
lines changed

1 file changed

+136
-38
lines changed

src/doc/en/developer/packaging.rst

Lines changed: 136 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,13 +1035,10 @@ upstream is ``$SAGE_ROOT/upstream/FoO-1.3.tar.gz``, create a new file
10351035
tarball=FoO-VERSION.tar.gz
10361036
10371037
Sage internally replaces the ``VERSION`` substring with the content of
1038-
``package-version.txt``. To recompute the checksums, run::
1038+
``package-version.txt``.
10391039
1040-
[alice@localhost sage]$ sage --package fix-checksum foo
1041-
1042-
which will modify the ``checksums.ini`` file with the correct
1043-
checksums.
10441040
1041+
.. _section-spkg-upstream-urls:
10451042
10461043
Upstream URLs
10471044
-------------
@@ -1068,39 +1065,33 @@ For Python packages available from PyPI, you should use an
10681065
10691066
upstream_url=https://pypi.io/packages/source/m/matplotlib/matplotlib-VERSION.tar.gz
10701067
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.
10751074
1076-
which will automatically download the archive and update the
1077-
information in ``build/pkgs/``.
10781075
1079-
For Python packages available from PyPI, there is another shortcut::
1076+
.. _section-sage-package-command:
10801077
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+
==============================================
10851080
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.
10951083
10961084
1097-
Utility script to create packages
1098-
=================================
1085+
Creating packages
1086+
-----------------
10991087
11001088
Assuming that you have downloaded
11011089
``$SAGE_ROOT/upstream/FoO-1.3.tar.gz``, you can use::
11021090
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
11041095
11051096
to create ``$SAGE_ROOT/build/pkgs/foo/package-version.txt``,
11061097
``checksums.ini``, and ``type`` in one step.
@@ -1111,22 +1102,132 @@ set the ``upstream_url`` field in ``checksums.ini`` described above.
11111102
11121103
For Python packages available from PyPI, you can use::
11131104
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
11151107
11161108
This automatically downloads the most recent version from PyPI and also
11171109
obtains most of the necessary information by querying PyPI.
1110+
11181111
The ``dependencies`` file may need editing (watch out for warnings regarding
11191112
``--no-deps`` that Sage issues during installation of the package!).
11201113
Also you may want to set lower and upper bounds for acceptable package versions
11211114
in the file ``install-requires.txt``.
11221115
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.
11241131
1125-
[alice@localhost sage]$ sage --package create scikit_spatial --pypi --source pip --type optional
11261132
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+
11281162
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.
11301231
11311232
11321233
.. _section-manual-build:
@@ -1136,9 +1237,7 @@ Building the package
11361237
11371238
At this stage you have a new tarball that is not yet distributed with
11381239
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`).
11421241
11431242
Now you can install the package using::
11441243
@@ -1157,8 +1256,7 @@ or::
11571256
11581257
[alice@localhost sage]$ sage -f -c package_name
11591258
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
11621260
``SAGE_ROOT/build/pkgs``.
11631261
11641262

0 commit comments

Comments
 (0)