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

Replace bootstrap-conda by grayskull and update conda lock files #37447

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

tobiasdiez
Copy link
Contributor

@tobiasdiez tobiasdiez commented Feb 24, 2024

Using the metadata added in #37446, we automatically generate the conda environment files. This no longer makes any reference to the conda.txt files contained in sage-the-distribution. Thus sage-on-top-of-conda is now completely independent of sage-the-distribution (only relying on information specified by sage-the-library). In particular, after this PR is merged the conda.txt files could be deleted from sage-the-distribution.

In particular, we no longer need to maintain the mapping of pypi packages to conda packages but instead can rely on the offical mappings maintained by the conda team (https://github.com/regro/cf-graph-countyfair/tree/master/mappings/pypi).

To test:

pip install grayskull conda-lock
python tools/update-conda.py

The updated conda files are committed here as well.

Moreover, the environment-dev files have been deleted as there was only little difference between these files and some people rightfully complained that having too many files in the root folder is distracting.

As a byproduct, this fixes #34626.

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • 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

@tobiasdiez tobiasdiez requested a review from dimpase February 24, 2024 05:42
@mkoeppe mkoeppe added the disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ label Feb 24, 2024
@dimpase dimpase removed the disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ label Feb 26, 2024
@dimpase
Copy link
Member

dimpase commented Feb 26, 2024

I've removed disputed as it was added without a word of explanation. At least if you start a relabelling war, express what exactly you dispute.

@dimpase
Copy link
Member

dimpase commented Feb 26, 2024

do you mean pip install git+https://github.com/conda/grayskull ?

Anyhow, after I do the latter, I get

$ python tools/update-conda.py .
Conda environment file written to src/environment-3.9.yml
Updating lock file for src/environment-3.9.yml at src/environment-3.9-linux
Traceback (most recent call last):
  File "/mnt/opt/Sage/sage-clang/tools/update-conda.py", line 150, in <module>
    update_conda(Path(options.sourcedir))
  File "/mnt/opt/Sage/sage-clang/tools/update-conda.py", line 75, in update_conda
    subprocess.run(
  File "/usr/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'conda-lock'

What do I do wrong? Does it need to be run in a conda env?

@mkoeppe mkoeppe added the disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ label Feb 26, 2024
@tobiasdiez
Copy link
Contributor Author

What do I do wrong? Does it need to be run in a conda env?

Sorry, forgot that the script uses conda-lock as well. Please try again after pip install conda-lock. Later today, I'll add a bit of documentation to the script.

@dimpase dimpase removed the disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ label Feb 27, 2024
@mkoeppe mkoeppe added the disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ label Feb 27, 2024
@dimpase
Copy link
Member

dimpase commented Feb 28, 2024

Why do I see on an amd64 box

Locking dependencies for ['linux-aarch64']...

while running python tools/update-conda.py . ? Looks like an overkill, no?

@dimpase
Copy link
Member

dimpase commented Feb 28, 2024

I was getting errors about unresolved packages,so I applied

diff --git a/tools/update-conda.py b/tools/update-conda.py
index f123c7e4151..176b016d183 100644
--- a/tools/update-conda.py
+++ b/tools/update-conda.py
@@ -20,10 +20,6 @@ options = parser.parse_args()
 
 platforms = {
     "linux-64": "linux",
-    "linux-aarch64": "linux-aarch64",
-    "osx-64": "macos",
-    "osx-arm64": "macos-arm64",
-    "win-64": "win",
 }
 pythons = ["3.9", "3.10", "3.11"]
 tags = ["", "-dev"]

and this worked. Obv. win-64 won't fly, many Sage packages don't exist there.

Copy link
Member

@dimpase dimpase left a comment

Choose a reason for hiding this comment

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

please remove win-*-stuff

@tobiasdiez
Copy link
Contributor Author

Why do I see on an amd64 box

Locking dependencies for ['linux-aarch64']...

while running python tools/update-conda.py . ? Looks like an overkill, no?

Note that the update-conda script is not run at bootstrap time (there is no point in doing this as the env files are already in the src folder under version control) but only for maintenance, i.e to update the lock files for all systems. My plan is to automate the procedure and have a GH scheduled workflow that runs the script and opens a PR every two weeks or so. This is btw exactly the same setup as https://github.com/scikit-learn/scikit-learn/blob/main/build_tools/update_environments_and_lock_files.py.

please remove win-*-stuff

Good catch. Thanks! I've played around with the windows packages for a bit, but then forgot to uncomment it again. Done now.

@saraedum
Copy link
Member

Please clarify what about this PR is disputed. (@tobiasdiez is it possible that @mkoeppe is lacking the permission to comment here?)

@saraedum
Copy link
Member

I took the liberty to add the "needs work" label since it's unclear what's disputed here. (Also, you could maybe check or remove the checklist at the top of the PR to make it clear that there's nothing from that checklist missing here.)

@dimpase

This comment was marked as abuse.

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 17, 2024

@saraedum @roed314 @jhpalmieri I set "disputed" here because when the PR was opened, I was not able to comment because Tobias had blocked me without explanation or giving notice to the sage-abuse committee. It appears that now I can comment, so I am removing "disputed".

There has not been any meaningful review yet here, so conducting a vote would seem premature.

@mkoeppe mkoeppe removed the disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ label Mar 17, 2024
@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 17, 2024

It is correct that on my own PRs, @dimpase is blocked because of his persistent and aggressive code of conduct violations, including the type of denunciations that he has just written above.

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 17, 2024

In any case, this PR here is based on #37446, which is in disputed status because of #37446 (comment)

@dimpase

This comment was marked as abuse.

Copy link
Member

@dimpase dimpase left a comment

Choose a reason for hiding this comment

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

I am giving it a positive review; I tried it out, I pointed a problem, the problem got fixed - despite a rather abusive "There has not been any meaningful review yet here, so conducting a vote would seem premature" comment.

Copy link

github-actions bot commented Mar 20, 2024

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

Copy link
Member

@saraedum saraedum left a comment

Choose a reason for hiding this comment

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

I understand that there are reservations about having the pyproject.toml in the root directory. Otherwise, this PR does seem like a reasonable idea to me (replace a shell script with Python and relay some of the heavy lifting to an external project.)

Is there a better place for the pyproject.toml that would make this work for everybody?

@@ -0,0 +1,154 @@
#!/usr/bin/env python3
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good to add an explanation at the top that explains what this script does. Or maybe add a --help to the argument parser that prints such documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've now added a bit of documentation in the README file in the same directory, and a very short comment on the usage in this file. Do you think this is sufficient?

tools/update-conda.py Outdated Show resolved Hide resolved
tools/update-conda.py Outdated Show resolved Hide resolved
return dev_dependencies


update_conda(Path(options.sourcedir))
Copy link
Member

Choose a reason for hiding this comment

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

Not super important but if we put all the global bits of this script in a def main() and do the usual if __name__ == "__main__" or similar, then this could be imported by others to use bits of the machinery for other purposes.

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 20, 2024

Creating a new top-level tools/ directory should probably go through discussion in sage-devel.

And actually, there's no need for a new top-level directory: We already have a place for scripts of exactly this kind -- it is SAGE_ROOT/build/bin/.
In other words, the tools/update-conda.py script should just become part of the sage-bootstrap distribution package.

@tobiasdiez
Copy link
Contributor Author

Thanks Dima!

@vbraun
Copy link
Member

vbraun commented Dec 5, 2024

$ ./bootstrap -s
[...]
./bootstrap: installing /home/release/Sage/build/pkgs/sagemath_repl/src/requirements-editable.txt
./bootstrap: installing /home/release/Sage/build/pkgs/sagemath_repl/src/requirements.txt
./bootstrap: installing /home/release/Sage/build/pkgs/sagemath_sirocco/src/pyproject.toml
./bootstrap: installing /home/release/Sage/build/pkgs/sagemath_sirocco/src/requirements.txt
./bootstrap: installing /home/release/Sage/build/pkgs/sagemath_tdlib/src/pyproject.toml
./bootstrap: installing /home/release/Sage/build/pkgs/sagemath_tdlib/src/requirements.txt
configure.ac:64: installing 'config/compile'
configure.ac:64: installing 'config/config.guess'
configure.ac:64: installing 'config/config.sub'
configure.ac:50: installing 'config/install-sh'
configure.ac:50: installing 'config/missing'
Creating upstream/configure-33ed2859206b71e3ed381b33585d0139499ac34d.tar.gz...
find: warning: you have specified the global option -maxdepth after the argument -name, but global options are not positional, i.e., -maxdepth affects tests specified before it as well as those specified after it.  Please specify global options before other arguments.
tar: environment-3.[89].yml: Cannot stat: No such file or directory
tar: environment-3.1[0-9].yml: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 6, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Newer versions of numpy use meson instead of the old distutils. Needed
for sagemath#37447.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] 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 and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38983
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
@dimpase
Copy link
Member

dimpase commented Dec 6, 2024

How about something like this? (it does fix ./bootstrap -s)

--- a/bootstrap
+++ b/bootstrap
@@ -225,14 +225,14 @@ save () {
 	build/make/Makefile-auto.in \
 	src/doc/en/installation/*.txt \
 	$(find src/doc/en/reference/spkg -name index.rst -prune -o -maxdepth 1 -name "*.rst" -print) \
-	environment-3.[89].yml environment-3.1[0-9].yml \
-	src/Pipfile \
+	environment-3.[9]-*.yml environment-3.1[0-9]-*.yml \
 	build/pkgs/cypari/version_requirements.txt \
 	build/pkgs/cysignals/version_requirements.txt \
 	build/pkgs/cython/version_requirements.txt \
 	build/pkgs/gmpy2/version_requirements.txt \
 	build/pkgs/jupyter_core/version_requirements.txt \
 	build/pkgs/memory_allocator/version_requirements.txt \
+	build/pkgs/meson/version_requirements.txt \
 	build/pkgs/numpy/version_requirements.txt \
 	build/pkgs/pkgconfig/version_requirements.txt \
 	build/pkgs/pplpy/version_requirements.txt \

Also, what's the point of src/Pipfile.m4 - in particular as it's just a template, not filled in anymore?
And is src/Pipfile used anywhere?

vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 8, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Newer versions of numpy use meson instead of the old distutils. Needed
for sagemath#37447.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] 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 and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38983
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 8, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Newer versions of numpy use meson instead of the old distutils. Needed
for sagemath#37447.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] 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 and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38983
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
@tobiasdiez
Copy link
Contributor Author

How about something like this? (it does fix ./bootstrap -s)

--- a/bootstrap
+++ b/bootstrap
@@ -225,14 +225,14 @@ save () {
 	build/make/Makefile-auto.in \
 	src/doc/en/installation/*.txt \
 	$(find src/doc/en/reference/spkg -name index.rst -prune -o -maxdepth 1 -name "*.rst" -print) \
-	environment-3.[89].yml environment-3.1[0-9].yml \
-	src/Pipfile \
+	environment-3.[9]-*.yml environment-3.1[0-9]-*.yml \
 	build/pkgs/cypari/version_requirements.txt \
 	build/pkgs/cysignals/version_requirements.txt \
 	build/pkgs/cython/version_requirements.txt \
 	build/pkgs/gmpy2/version_requirements.txt \
 	build/pkgs/jupyter_core/version_requirements.txt \
 	build/pkgs/memory_allocator/version_requirements.txt \
+	build/pkgs/meson/version_requirements.txt \
 	build/pkgs/numpy/version_requirements.txt \
 	build/pkgs/pkgconfig/version_requirements.txt \
 	build/pkgs/pplpy/version_requirements.txt \

Thanks!

Also, what's the point of src/Pipfile.m4 - in particular as it's just a template, not filled in anymore? And is src/Pipfile used anywhere?

These files have been deleted now in #39031.

@tobiasdiez tobiasdiez mentioned this pull request Dec 9, 2024
5 tasks
vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 11, 2024
…da lock files

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

Using the metadata added in sagemath#37446,
we automatically generate the conda environment files. This no longer
makes any reference to the `conda.txt` files contained in sage-the-
distribution. Thus sage-on-top-of-conda is now completely independent of
sage-the-distribution (only relying on information specified by sage-
the-library). In particular, after this PR is merged the `conda.txt`
files could be deleted from sage-the-distribution.

In particular, we no longer need to maintain the mapping of pypi
packages to conda packages but instead can rely on the offical mappings
maintained by the conda team (https://github.com/regro/cf-graph-
countyfair/tree/master/mappings/pypi).

To test:
```
pip install grayskull conda-lock
python tools/update-conda.py
```

The updated conda files are committed here as well.

Moreover, the `environment-dev` files have been deleted as there was
only little difference between these files and some people rightfully
complained that having too many files in the root folder is distracting.

As a byproduct, this fixes sagemath#34626.

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [ ] The title is concise, informative, and self-explanatory.
- [ ] 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

- sagemath#37446: specifies additional
requirements in the pyproject.toml which are used to generate the conda
env files
- sagemath#38983: for the update of numpy
- sagemath#38982: to fix meson build

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#37447
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik, Julian Rüth, Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 12, 2024
…da lock files

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

Using the metadata added in sagemath#37446,
we automatically generate the conda environment files. This no longer
makes any reference to the `conda.txt` files contained in sage-the-
distribution. Thus sage-on-top-of-conda is now completely independent of
sage-the-distribution (only relying on information specified by sage-
the-library). In particular, after this PR is merged the `conda.txt`
files could be deleted from sage-the-distribution.

In particular, we no longer need to maintain the mapping of pypi
packages to conda packages but instead can rely on the offical mappings
maintained by the conda team (https://github.com/regro/cf-graph-
countyfair/tree/master/mappings/pypi).

To test:
```
pip install grayskull conda-lock
python tools/update-conda.py
```

The updated conda files are committed here as well.

Moreover, the `environment-dev` files have been deleted as there was
only little difference between these files and some people rightfully
complained that having too many files in the root folder is distracting.

As a byproduct, this fixes sagemath#34626.

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [ ] The title is concise, informative, and self-explanatory.
- [ ] 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

- sagemath#37446: specifies additional
requirements in the pyproject.toml which are used to generate the conda
env files
- sagemath#38983: for the update of numpy
- sagemath#38982: to fix meson build

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#37447
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik, Julian Rüth, Tobias Diez
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.

Minimize conda environment
6 participants