Skip to content

Conversation

@LecrisUT
Copy link
Contributor

@LecrisUT LecrisUT commented Feb 5, 2025

  • Used setuptools-scm because it is simpler to configure for now. I don't think the reading version from python file is supported in scikit-build-core yet
  • Had to move the src/libmambapy/bindings to bindings because it interferes with pip install -e. It is cleaner to have the compilation source outside of the pure python files.

Other than that it should be effectively identical.

I did not review the build system, but at least there is an immediate issue that needs to be resolved

include("../cmake/CompilerWarnings.cmake")

This breaks all sdist builds because the archive starts from libmambapy folder. In practice, this is a purely developer option and there are neater ways to create one using targets instead. But if you really wish to keep it in that form, a solution is to make a symlink of the cmake folder.

Closes #3798

- scikit-build
- scikit-build-core
- setuptools-scm
- pybind11-stubgen <1.0
Copy link
Contributor Author

@LecrisUT LecrisUT Feb 5, 2025

Choose a reason for hiding this comment

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

Does conda still not have any integration with python build systems (PEP517)? Manually referencing them like this is very error-prone, particularly since some build dependencies are dynamically generated, setuptools-scm in this case.

@opoplawski
Copy link
Contributor

This is important for Fedora now that scikit-build has been dropped. Could this get rebased and moved forward?

@opoplawski
Copy link
Contributor

I'm trying to adapt the Fedora libmamba package to build with this but not having any luck:

+ cd libmambapy
+ export 'SKBUILD_CMAKE_ARGS=  -DCMAKE_BUILD_TYPE=RelWithDebInfo   -DBUILD_LIBMAMBA=ON   -DBUILD_LIBMAMBAPY=ON   -DBUILD_MICROMAMBA=OFF   -DBUILD_MAMBA_PACKAGE=OFF   -DBUILD_EXE=ON   -DBUILD_SHARED=ON   -DBUILD_STATIC=OFF   -DENABLE_TESTS=ON   -Dlibmamba_ROOT=/builddir/build/BUILD/libmamba-2.3.1-build/mamba-339715a4d3d1ec38046c87848b61b62c0c7e5db1/libmambapy/../install   -DMAMBA_WARNING_AS_ERROR=OFF'
+ SKBUILD_CMAKE_ARGS='  -DCMAKE_BUILD_TYPE=RelWithDebInfo   -DBUILD_LIBMAMBA=ON   -DBUILD_LIBMAMBAPY=ON   -DBUILD_MICROMAMBA=OFF   -DBUILD_MAMBA_PACKAGE=OFF   -DBUILD_EXE=ON   -DBUILD_SHARED=ON   -DBUILD_STATIC=OFF   -DENABLE_TESTS=ON   -Dlibmamba_ROOT=/builddir/build/BUILD/libmamba-2.3.1-build/mamba-339715a4d3d1ec38046c87848b61b62c0c7e5db1/libmambapy/../install   -DMAMBA_WARNING_AS_ERROR=OFF'
+ mkdir -p /builddir/build/BUILD/libmamba-2.3.1-build/mamba-339715a4d3d1ec38046c87848b61b62c0c7e5db1/.pyproject-builddir
+ CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  '
+ CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  '
+ FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules  '
+ FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules  '
+ VALAFLAGS=-g
+ RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn'
+ LDFLAGS='-Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  '
+ LT_SYS_LIBRARY_PATH=/usr/lib64:
+ CC=gcc
+ CXX=g++
+ TMPDIR=/builddir/build/BUILD/libmamba-2.3.1-build/mamba-339715a4d3d1ec38046c87848b61b62c0c7e5db1/.pyproject-builddir
+ /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_wheel.py /builddir/build/BUILD/libmamba-2.3.1-build/mamba-339715a4d3d1ec38046c87848b61b62c0c7e5db1/pyproject-wheeldir
Processing /builddir/build/BUILD/libmamba-2.3.1-build/mamba-339715a4d3d1ec38046c87848b61b62c0c7e5db1/libmambapy
  Preparing metadata (pyproject.toml): started
  Running command Preparing metadata (pyproject.toml)
  2025-08-05 08:01:37,216 - scikit_build_core - WARNING - Unknown keys in top-level of pyproject.toml: projet
  *** scikit-build-core 0.11.5 using CMake 3.31.6 (metadata_wheel)
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: libmambapy
  Building wheel for libmambapy (pyproject.toml): started
  Running command Building wheel for libmambapy (pyproject.toml)
  2025-08-05 08:01:37,398 - scikit_build_core - WARNING - Unknown keys in top-level of pyproject.toml: projet
  *** scikit-build-core 0.11.5 using CMake 3.31.6 (wheel)
  *** Configuring CMake...
  loading initial cache file /builddir/build/BUILD/libmamba-2.3.1-build/mamba-339715a4d3d1ec38046c87848b61b62c0c7e5db1/.pyproject-builddir/tmplg6vamgg/build/CMakeInit.txt
  -- The C compiler identification is GNU 15.1.1
  -- The CXX compiler identification is GNU 15.1.1
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/lib64/ccache/gcc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/lib64/ccache/g++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  CMake Error at CMakeLists.txt:13 (find_package):
    Could not find a package configuration file provided by "libmamba" with any
    of the following names:

      libmambaConfig.cmake
      libmamba-config.cmake

    Add the installation prefix of "libmamba" to CMAKE_PREFIX_PATH or set
    "libmamba_DIR" to a directory containing one of the above files.  If
    "libmamba" provides a separate development package or SDK, be sure it has
    been installed.


  -- Configuring incomplete, errors occurred!

work is here: https://src.fedoraproject.org/rpms/libmamba/pull-request/4

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Aug 5, 2025

I'm trying to adapt the Fedora libmamba package to build with this but not having any luck:

I will try to investigate the PR over the week. But a quick thing you can try is to pass libmamba_ROOT pointing to the build dir, similar to how I do on spglib.

@opoplawski
Copy link
Contributor

I'm am passing that, and I think I updated the environment variable used to pass in cmake options properly. So not sure what's up.

@LecrisUT LecrisUT force-pushed the scikit-build-core branch 3 times, most recently from e2f8bc1 to d2e4110 Compare August 6, 2025 12:35
@LecrisUT
Copy link
Contributor Author

LecrisUT commented Aug 6, 2025

@jaimergp @jjerphan could we get someone to look over this PR? As far as the scikit-build -> scikit-build-core change, this PR should be complete and ready for review.

Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

This must be done at a point, but we unfortunately are already swamped with work, and we have other priorities to honour.

Can you test this PR by opening another one on https://github.com/conda-forge/mamba-feedstock/ with the patch?

Copy link
Member

Choose a reason for hiding this comment

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

Can you motivate the changes made to this file using an inline-comment?

Also, can you indicate whether this is safe regarding the discussions given in pypa/setuptools-scm#806.

Copy link
Contributor Author

@LecrisUT LecrisUT Aug 6, 2025

Choose a reason for hiding this comment

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

I don't know if setuptools-scm accepts comments or any other tools that would also read this file, so if possible it would be better to address it in this PR.

Edit: Actually I will write a few words in the .gitattributes part.

Also, can you indicate whether this is safe regarding the discussions given in pypa/setuptools-scm#806.

Yes, I made the PR in the upstream to indicate that ref-names must be removed because that is the dangerous part. describe-name could in theory also be problematic if there are multiple tags added to the same commit that match the regex, but I don't think it's the case here

templates = {
"libmamba": "libmamba/include/mamba/version.hpp.tmpl",
"micromamba": "micromamba/src/version.hpp.tmpl",
"libmambapy": "libmambapy/src/libmambapy/version.py.tmpl",
Copy link
Member

Choose a reason for hiding this comment

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

This file is required.

Can you revert this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is instead generated by setuptools_scm. It is generated every time the python build system is called and it tracks better the git distance and such. For the CMake only build it indeed would not have that file, but there are other issues with building the CMake-only build of the python bindings, primarily the lack of the dist-info metadata which would allow to pip uninstall.

Are there other pitfalls that the lack of this file could have?

@jjerphan jjerphan added the release::maintenance For PRs related to maintenance label Aug 6, 2025
@LecrisUT LecrisUT force-pushed the scikit-build-core branch from d2e4110 to b42ff41 Compare August 6, 2025 16:44
LecrisUT added a commit to LecrisUT/mamba-feedstock that referenced this pull request Aug 6, 2025
@LecrisUT
Copy link
Contributor Author

LecrisUT commented Aug 6, 2025

This must be done at a point, but we unfortunately are already swamped with work, and we have other priorities to honour.

Of course, just want to make sure it doesn't fall through the cracks. I am also rapidly distracted so I also forget to follow up on PRs.

Can you test this PR by opening another one on https://github.com/conda-forge/mamba-feedstock/ with the patch?

I can never remember how to do that, hope this one works: conda-forge/mamba-feedstock#341

@opoplawski
Copy link
Contributor

Looks like this needs to get rebased with the latest version number bump. Any chance this could get merged? Any other concerns that need to be addressed?

@JohanMabille
Copy link
Member

The feedstock with the patch is failing, I need to check why. I'll have a look next week, hopefully we can fix the failures and get this merged.

Signed-off-by: Cristian Le <[email protected]>
Also move the Config.cmake binary files to the top of the build-dir

Signed-off-by: Cristian Le <[email protected]>
setuptools_scm does not seem to read the file if it is from git root, it has to be next to pyproject.toml
@LecrisUT
Copy link
Contributor Author

The feedstock with the patch is failing, I need to check why. I'll have a look next week, hopefully we can fix the failures and get this merged.

Sorry, I've said that I would try to build it locally, but never got around to it. I've did a quick build now and found the issue (setuptools_scm does not seem to check ../.git_archival.txt, only from the current folder). The latest change should fix it, I'll rebase the feedstock also

LecrisUT added a commit to LecrisUT/mamba-feedstock that referenced this pull request Aug 29, 2025
Copy link
Member

@AntoinePrv AntoinePrv left a comment

Choose a reason for hiding this comment

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

Great work setting that up!

My only point is about version.py. If possible I would prefer NOT switch to setuptools-scm as it does not play well with the rest of the release process.
I don't think there is a point of having something smart if we still have the other templated files. A single definition is better until we can improve globally.


EDIT: Just saw

Used setuptools-scm because it is simpler to configure for now. I don't think the reading version from python file is supported in scikit-build-core yet

And I found that we can get it from regex, I would much rather use that than mixing our release with VCS and git archival things.

@LecrisUT
Copy link
Contributor Author

EDIT: Just saw

Used setuptools-scm because it is simpler to configure for now. I don't think the reading version from python file is supported in scikit-build-core yet

And I found that we can get it from regex, I would much rather use that than mixing our release with VCS and git archival things.

Yes, I thought about it a bit, and it is possible to do it, and there would be different approaches depending on how it is stored. Either regex or dynamic provider would be used. But I need assistance to point me to the source.

Note: that generation of version.py would have to stay the same, otherwise the following build scenario would fail

$ pip install "libmambapy@git+https://github.com/mamba-org/mamba"

(and derivatives)

@codecov
Copy link

codecov bot commented Aug 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.99%. Comparing base (2b643d1) to head (3490069).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3802   +/-   ##
=======================================
  Coverage   63.99%   63.99%           
=======================================
  Files         303      303           
  Lines       38938    38938           
  Branches     2863     2871    +8     
=======================================
  Hits        24918    24918           
  Misses      13953    13953           
  Partials       67       67           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AntoinePrv
Copy link
Member

@LecrisUT should I push a commit here with my proposal?

@LecrisUT
Copy link
Contributor Author

@LecrisUT should I push a commit here with my proposal?

Feel free to do so

@AntoinePrv
Copy link
Member

That's my take on it. I'm off for the weekend, feel free to keep making changes, revert etc if you need to.

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Aug 29, 2025

Looks fine with me 👍. Didn't look into your release procedure, but w.r.t. pip installability from other sources it is ok. The version_prerelease is not covered, but no idea of the format to know how to recommend it to be.

@AntoinePrv
Copy link
Member

Note about pip installability that the current python build assumes to find libmamba separately (already installed).

Not sure about the prerelease either. To me there should not be a . between a the patch and trailing string.

@LecrisUT
Copy link
Contributor Author

Not sure about the prerelease either. To me there should not be a . between a the patch and trailing string.

If you're not sure about the format to use there, here is a quick reference. If it's like rcN format, then yes you can just append it to the end without .. If it's a different format 🤷

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Sep 1, 2025

Had to double check if scikit-build-core would error out on the non-standard version string, and it seems it will not

>>> import packaging.version
>>> packaging.version.Version("1.3.5.alpha4")
<Version('1.3.5a4')>

However, keep in mind that the real package version, artifacts, etc. will use the normalize format, i.e. 1.3.5a4, so the conda package might break in similar ways that we saw before with the SETUPTOOLS_SCM_PRETEND_VERSION we saw earlier

Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

Thank you, @LecrisUT and @AntoinePrv for adaptation.

I think we could have a pre-release version after this PR is merged to test that the new build system works properly. If it does not, we can bug-fix before the official release.

What do you think?

@AntoinePrv
Copy link
Member

Feedstock CI is ✅

@AntoinePrv AntoinePrv merged commit 9872bed into mamba-org:main Sep 1, 2025
62 of 63 checks passed
@AntoinePrv
Copy link
Member

Thank you for your work and your patience @LecrisUT !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release::maintenance For PRs related to maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migration to scikit-build-core

6 participants