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

src/sage/features/sagemath.py: Add feature SAGE_SRC #37650

Merged
merged 2 commits into from
May 2, 2024

Conversation

mkoeppe
Copy link
Contributor

@mkoeppe mkoeppe commented Mar 22, 2024

This feature is for conditionalizing some doctests.

Fixes doctest failure reported in #37645.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

⌛ Dependencies

@mkoeppe mkoeppe self-assigned this Mar 22, 2024
@mkoeppe mkoeppe requested a review from tornaria March 22, 2024 07:22
@mkoeppe mkoeppe requested a review from kiwifb March 24, 2024 18:54
@kiwifb
Copy link
Member

kiwifb commented Mar 24, 2024

That's an interesting solution, using features more is a good idea. Here SAGE_SRC is /usr/lib/python3.12/site-packages and I certainly hope no one put a file VERSION.txt at that level of the tree.

It is cool that it addresses the failures in package_dir.py and sage_setup/find.py but I have no issues with the other two files. Nevertheless, it is probably a good idea, future change may cause breakage.

Copy link
Member

@kiwifb kiwifb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 24, 2024

Here SAGE_SRC is /usr/lib/python3.12/site-packages

Yes, this feature test does take care of this situation, but at some point we will probably also want to get rid of the SAGE_SRC fallback to SAGE_LIB.

@kiwifb
Copy link
Member

kiwifb commented Mar 24, 2024

That'd be great.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 24, 2024

@mkoeppe mkoeppe force-pushed the feature_SAGE_SRC branch 2 times, most recently from 6f2537c to 0aafe3f Compare April 1, 2024 00:53
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 3, 2024

Setting to "positive review" based on @kiwifb's review.

@@ -111,6 +111,7 @@ def read_distribution(src_file):

EXAMPLES::

sage: # needs SAGE_SRC
sage: from sage.env import SAGE_SRC
sage: from sage.misc.package_dir import read_distribution
sage: read_distribution(os.path.join(SAGE_SRC, 'sage', 'graphs', 'graph_decompositions', 'tdlib.pyx'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line # needs tdlib as explained in #37645. You act as if SAGE_SRC indicates that you have the whole source tree, but in fact sagemath-standard sdist contains VERSION.txt afaict.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fair point that I had not thought about. I was only thinking of the case where you test with an installation of sage that is not in source. In which case VERSION.txt is not installed and cannot be found.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact sagemath-standard sdist contains VERSION.txt afaict.

Very good point. And in fact all of the modularized distributions have VERSION.txt too.
Suggestions what we should test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presence of the bin or doc folders? It also has to be something that will be stable - for some time at least.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Producing a sdist right now to make sure I do not say something stupid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add a sentinel file in src/sage/features/ that is never included in any distribution? Using an arbitrary existing file is just asking for trouble when later that file is changed for an unrelated reason, etc.

OTOH, it feels weird that testing sage-setup needs SAGE_SRC. The read_distribution() function seems like a part of sage-setup not of sagelib, and why can't it be unit tested instead of testing with a .pyx from the sage source?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally get what you mean about the test, but it is meant to test "distribution", so stuff like sagemath-bliss or as in this case sagemath-tdlib. If you want to keep things in source tree, you have to provide the test suite with a "fake" mini distribution to test.

As for the file to test, it is arbitrary and I would have probably chosen pyproject.tml.m4 myself. But I think the file chosen is there for a long time which is a criterion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is wrong with a file src/sage/features/this-file-only-in-the-source.txt which IIUC it's never included in a sdist by default (https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html)

The file can have a simple explanation of its purpose, being a text file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an arbitrary existing file is just asking for trouble when later that file is changed for an unrelated reason, etc.

Well, this particular file I chose is not arbitrary but by its design has exactly the right properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The read_distribution() function seems like a part of sage-setup not of sagelib

No, it's in the right place. This module, like sage.features, is part of sagemath-environment.

Copy link

github-actions bot commented Apr 4, 2024

Documentation preview for this PR (built with commit 576d8bf; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@tornaria

This comment was marked as off-topic.

@mkoeppe

This comment was marked as off-topic.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 9, 2024

Let's get this in please

@kiwifb
Copy link
Member

kiwifb commented Apr 29, 2024

I was reminded of this because of #37645 which address only the tdlib.pyx tests occurring in sagemath-standard without covering the ones in sage_setup. I confirm my positive review now that the one contentious point has been solved.

@tornaria
Copy link
Contributor

image

I'm not arguing that my comment was not offtopic. It was.

But there's no record of who marked it as offtopic (it wasn't me); I don't like that someone can anonymously hide comments. FWIW, I do NOT have this ability. It seems can mark my own comments as offtopic, but not others (not even in my own PRs).

It's the same asymmetry where some developers can modify PRs they don't own, but others don't have this ability (I don't).

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 29, 2024

Thanks, Francois.

@vbraun vbraun merged commit 0a75254 into sagemath:develop May 2, 2024
13 of 14 checks passed
@mkoeppe mkoeppe added this to the sage-10.4 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants