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

back up/restore conftest.py #39363

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

Conversation

dimpase
Copy link
Member

@dimpase dimpase commented Jan 22, 2025

this will fix #39357

📝 Checklist

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

⌛ Dependencies

as autoconf's generated configure clobbers conftest*,
we are saving conftest.py from it by making a backup copy and then
restoring it after the real configure was run.
@dimpase
Copy link
Member Author

dimpase commented Jan 22, 2025

@vbraun - please have a look whether this doesn't break anything in your machinery

@dimpase
Copy link
Member Author

dimpase commented Jan 22, 2025

@orlitzky - can you have a look?

@dimpase
Copy link
Member Author

dimpase commented Jan 22, 2025

CI is failing in building docker images with

#23 66.22 cp: cannot stat 'configure_wrapper': No such file or directory

No idea what wrapper this is. @kwankyu - do you know?

@jhpalmieri
Copy link
Member

CI is failing in building docker images with

#23 66.22 cp: cannot stat 'configure_wrapper': No such file or directory

No idea what wrapper this is. @kwankyu - do you know?

I may not be understanding this correctly, but isn't it just referring to the file, newly created by this PR, called "configure_wrapper"?

@dimpase
Copy link
Member Author

dimpase commented Jan 22, 2025

Perhaps I've broken make configure - something that is used by the docker creation. I'm not sure this make target should be preserved - it's not standard, people can and should instead run ./bootstrap directly.

@kwankyu
Copy link
Collaborator

kwankyu commented Jan 23, 2025

No idea what wrapper this is. @kwankyu - do you know?

No idea either.

Perhaps I've broken make configure - something that is used by the docker creation. I'm not sure this make target should be preserved - it's not standard, people can and should instead run ./bootstrap directly.

If something is broken, the standard way is to fix it (after understanding how it went broken), not to remove it.

@dimpase
Copy link
Member Author

dimpase commented Jan 23, 2025

No idea what wrapper this is. @kwankyu - do you know?

No idea either.

Perhaps I've broken make configure - something that is used by the docker creation. I'm not sure this make target should be preserved - it's not standard, people can and should instead run ./bootstrap directly.

If something is broken, the standard way is to fix it (after understanding how it went broken), not to remove it.

Creating configure scripts using make is highly non-standard, and totally unneeded. I don't know why we're stuck with this for so long. It makes the build system even more complicated than necessary - because normally speaking makefiles are built by ./configure, not the other way around. So we're creating a chicken vs egg situation for no reason at all.

Anyhow, my latest attempt shows that it's not the issue. The issue is that the docker does not find configure_wrapper, and for the life of me I don't understand why. This file is a new file present in this branch, the branch we are testing!

https://github.com/sagemath/sage/actions/runs/12916470243/job/36020720010?pr=39363#step:13:517

@orlitzky
Copy link
Contributor

I saw your post on the autoconf list and had been planning to try this. It's worse than you say:

  1. The fact that ./configure will remove all conftest* files has been documented for many many years, so it was an interesting choice by pytest to name their file conftest.py.
  2. Not only does autoconf remove conftest* files, it removes them with rm -rf, so we can't fix this with e.g. chmod a-w conftest.py.
  3. Not only does autoconf rm -rf them, it does so in a trap handler to ensure that they are removed as the very last action taken by ./configure. So we can't e.g. move conftest.py to _conftest.py and then symlink it at the end of ./configure.

@dimpase
Copy link
Member Author

dimpase commented Jan 23, 2025

I saw your post on the autoconf list and had been planning to try this. It's worse than you say:
I mentioned somewhere that I got a reply to my post on the autoconf list, too, basically confirming your observations.

it was an interesting choice by pytest to name their file conftest.py.
There aren't many python packages around built with autotools. (cpython itself was like this IIRC, but, well...)

@dimpase
Copy link
Member Author

dimpase commented Jan 23, 2025

Are we in one of these situations when our docker-based CI won't work until this PR is merged in develop? @kwankyu ?

@kwankyu
Copy link
Collaborator

kwankyu commented Jan 23, 2025

I have no idea what you are asking... What is "these situations"? I was not following the present issue and have no background understanding.

@kwankyu
Copy link
Collaborator

kwankyu commented Jan 23, 2025

By the way, I do not object to changing "make configure" with "./bootstrap" for now if it helps. But removing the existing feature "make configure" as you seem to advocate is another matter.

@dimpase
Copy link
Member Author

dimpase commented Jan 23, 2025

I have no idea what you are asking... What is "these situations"? I was not following the present issue and have no background understanding.

basically, running ./configure removes all the files matching conftest* in Sageroot, but pytest needs a file named conftest.py in there.
There is basically no way to modify ./configure to avoid this, so we need to run it in a wrapper which will restore conftest.py after ./configure is run.

to preserve our workflow, we rename configure to real_configure and install configure_wrapper as ./configure. This is done in ./bootstrap. All works just fine on a local machine.
But the part of CI which creates a docker container breaks down while running ./bootstrap,
as it can't find configure_wrapper - which is a new file introduced in this PR.
IMHO it's a bug in CI, but I don't see where.

@user202729
Copy link
Contributor

Probably #39373 , let's see.

Copy link

github-actions bot commented Jan 24, 2025

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

@dimpase
Copy link
Member Author

dimpase commented Jan 24, 2025

@user202729 - CI passes (modulo unrelated doctest failures on some platforms). Can you give this a positive review?

@jhpalmieri
Copy link
Member

By the way, I do not object to changing "make configure" with "./bootstrap" for now if it helps. But removing the existing feature "make configure" as you seem to advocate is another matter.

I would not have any objections, either, but it is a publicly advertised way to install Sage — it's in the top-level README.md, for example — and so make configure would need to go through the usual deprecation process, we can't just delete it.

@dimpase
Copy link
Member Author

dimpase commented Jan 24, 2025

By the way, I do not object to changing "make configure" with "./bootstrap" for now if it helps. But removing the existing feature "make configure" as you seem to advocate is another matter.

I would not have any objections, either, but it is a publicly advertised way to install Sage — it's in the top-level README.md, for example — and so make configure would need to go through the usual deprecation process, we can't just delete it.

This goes without saying, certainly. The thing is that make configure isn't even an explicit make target, it's using the generic target for spkgs. I can make an explicit target which just runs ./bootstrap.

Copy link
Contributor

@user202729 user202729 left a comment

Choose a reason for hiding this comment

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

haven't actually reviewed it carefully, just a few minor changes then should be good

@@ -0,0 +1,4 @@
#! /bin/sh
cp conftest.py bak_conftest.py
./real_configure $@
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be safer to change $@ to "$@" to avoid arguments with spaces being broken up (not sure if it's portable, at least it works in bash)

also does the real_configure script support running it in a different directory? if yes then it may be a good idea to also support it by changing it to "$(dirname "$0")"/real_configure

@@ -196,7 +196,7 @@ ARG MAKEFLAGS="-j2"
ENV MAKEFLAGS $MAKEFLAGS
ARG SAGE_NUM_THREADS="2"
ENV SAGE_NUM_THREADS $SAGE_NUM_THREADS
RUN make configure
RUN ./bootstrap
Copy link
Contributor

Choose a reason for hiding this comment

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

does make configure still work? (if yes maybe leave it alone to be conservative, if not maybe we need to fix it)

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, make configure should still work. However, I don't know how, and trying to figure it out gives me a headache. OK, let's revert this change and see.

.github/workflows/build.yml Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

name clash between (generated) conftest.py and this in m4 macros
5 participants