Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage -fixdistributions #36135

Merged
merged 24 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5c17126
src/sage/misc/package_dir.py (update_distribution): New
mkoeppe Aug 22, 2023
534bcc7
sage --fixdistributions: New command
mkoeppe Aug 22, 2023
b5311bf
src/sage/misc/package_dir.py (update_distribution): Prevent self-muti…
mkoeppe Aug 22, 2023
0568108
sage --fixdistributions: Add switch --from-egg-info
mkoeppe Aug 23, 2023
299e6ce
src/doc/en/developer/packaging_sage_library.rst: Explain sage --fixdi…
mkoeppe Aug 25, 2023
db827cf
sage --fixpackages: Require at least one filename with --add and --set
mkoeppe Aug 25, 2023
a55265f
src/doc/en/developer/packaging_sage_library.rst: Explain sage --fixdi…
mkoeppe Aug 25, 2023
3e9af94
sage --fixdistributions: Put filename first in all messages
mkoeppe Aug 27, 2023
d1bbc45
sage --fixdistributions: Check all*.py and __init__.py files
mkoeppe Aug 27, 2023
54c5b79
src/sage/misc/package_dir.py: Make case of messages uniform
mkoeppe Aug 27, 2023
b61c491
sage --fixdistributions: Update --help epilog
mkoeppe Aug 27, 2023
59bb429
sage --fixdistributions: Improve --help
mkoeppe Aug 27, 2023
df4f405
src/sage/misc/package_dir.py (update_distribution): Fix for empty str…
mkoeppe Aug 27, 2023
be49fa7
sage --fixdistributions: Fix handling of file args, --set/--add
mkoeppe Aug 27, 2023
ebbca99
sage --fixdistributions: Use %(prog)s
mkoeppe Aug 27, 2023
af9bf68
sage --fixdistributions: Fix checks
mkoeppe Aug 28, 2023
47a89b5
sage --fixdistributions: Allow --set/add all --from-egg-info
mkoeppe Aug 28, 2023
e6083d5
sage --fixdistributions: Skip directories _vendor, .tox
mkoeppe Sep 1, 2023
71b9c3c
src/sage/misc/package_dir.py (read_distribution): Handle C comments
mkoeppe Sep 17, 2023
13bfb66
src/sage/misc/package_dir.py: Normalize distribution names, improve e…
mkoeppe Sep 20, 2023
9663e10
src/sage/misc/package_dir.py: Also recognize Lisp comments for sage_s…
mkoeppe Sep 22, 2023
331d02a
src/sage/misc/package_dir.py: Update distribution list
mkoeppe Oct 23, 2023
880776f
src/doc/en/developer/packaging_sage_library.rst: Document 'sage --fix…
mkoeppe Oct 23, 2023
f6fabd8
src/bin/sage: Suggested help string edit
mkoeppe Nov 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/bin/sage
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,13 @@ usage_advanced() {
echo " --fixdoctests file.py"
echo " -- Run doctests and replace output of failing doctests"
echo " with actual output."
echo " --fiximports <files|dir>"
echo " --fiximports <files|dirs>"
echo " -- Replace imports from sage.PAC.KAGE.all by specific"
echo " imports when sage.PAC.KAGE is an implicit namespace"
echo " package"
echo " --fixdistributions <files|dirs>"
echo " -- Check or update '# sage_setup: distribution'"
echo " directives in source files"
fi
echo " --sh [...] -- run a shell with Sage environment variables"
echo " as they are set in the runtime of Sage"
Expand Down Expand Up @@ -986,6 +989,11 @@ if [ "$1" = '-fiximports' -o "$1" = '--fiximports' ]; then
exec sage-python -m sage.misc.replace_dot_all "$@"
fi

if [ "$1" = '-fixdistributions' -o "$1" = '--fixdistributions' ]; then
shift
exec sage-python -m sage.misc.package_dir "$@"
fi

if [ "$1" = '-tox' -o "$1" = '--tox' ]; then
shift
if [ -n "$SAGE_SRC" -a -f "$SAGE_SRC/tox.ini" ]; then
Expand Down
28 changes: 28 additions & 0 deletions src/doc/en/developer/packaging_sage_library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,34 @@ The source directory of a distribution package, such as
controls which files and directories of the
monolithic Sage library source tree are included in the distribution

The manifest should be kept in sync with the directives of the form
``# sage_setup: distribution = sagemath-polyhedra`` at the top of
source files. Sage provides a tool ``sage --fixdistributions``
that assists with this task. For example::

$ ./sage --fixdistributions --set sagemath-polyhedra \
src/sage/geometry/polyhedron/base*.py

adds or updates the directives in the specified files; and::

$ ./sage --fixdistributions --add sagemath-polyhedra \
src/sage/geometry/polyhedron

adds the directive to all files in the given directory that do not
include a directive yet.

After a distribution has been built (for example, by the command
``make pypi-wheels``) or at least an sdist has been built (for
example, by the command ``make sagemath_polyhedra-sdist``), the
distribution directives in all files in the source distribution
can be updated using the switch ``--from--egg-info``::

$ ./sage --fixdistributions --set sagemath-polyhedra --from-egg-info

To take care of all distributions, use::

$ ./sage --fixdistributions --set all --from-egg-info

- `pyproject.toml <https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/>`_,
`setup.cfg <https://setuptools.pypa.io/en/latest/userguide/declarative_config.html>`_,
and `requirements.txt <https://pip.pypa.io/en/stable/user_guide/#requirements-files>`_ --
Expand Down
Loading