Skip to content

Setup pixi - #95

Merged
benbovy merged 3 commits into
mainfrom
setup-pixi
Feb 4, 2025
Merged

benbovy merged 3 commits into
mainfrom
setup-pixi

Conversation

@benbovy

@benbovy benbovy commented Feb 4, 2025 •

Copy link
Copy Markdown
Owner

FYI @jorisvandenbossche.

There's no change in the existing functionality & configuration, I just added some extra configuration so it is possible to use pixi for contributing to the development of Spherely. (I've recently switched to it for most of the projects I'm currently working on and I'm pretty happy with it!)

The only downside is that the dependencies are declared in more duplicated places, i.e., pyproject.toml, ci/environment-xxx.yml, docs/environment.yml files. Not a big deal I think, though.

Add dependencies, environments and tasks.

Note: dependencies are currently duplicated in pyproject.toml since we
prefer installing spherely dependencies using conda packages instead of
getting them from pypi (see
prefix-dev/pixi#532).

The two "configure" and "compile" tasks consist of raw cmake command
calls so we can better debug any issue during these two stages. Those
tasks are not used to build and install Spherely. Instead, Spherely is
declared as an editable pypi-dependency so that pixi can re-build and
re-install it (via uv/pip and scikit-build-core) when needed. The
`build-dir` scikit-build option has been set to speed-up rebuilds.
@codecov

codecov Bot commented Feb 4, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.31%. Comparing base (f050013) to head (1f97466).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #95   +/-   ##
=======================================
  Coverage   86.31%   86.31%           
=======================================
  Files          13       13           
  Lines         804      804           
  Branches       63       63           
=======================================
  Hits          694      694           
  Misses         80       80           
  Partials       30       30           

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

@benbovy
benbovy merged commit 18eb795 into main Feb 4, 2025
@benbovy
benbovy deleted the setup-pixi branch February 4, 2025 12:50

@jorisvandenbossche jorisvandenbossche left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cool!

Comment thread pyproject.toml
Comment on lines +94 to +97
[tool.pixi.feature.dev.tasks.compile-commands]
cmd = "cmake -GNinja -S. -Bbuild/compile-commands -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cp build/compile-commands/compile_commands.json ."
inputs = ["CMakeLists.txt"]
outputs = ["compile_commands.json"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is this one exactly doing?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The compile_commands.json file is commonly used by language servers like clangd and ccls to get project specific configuration (include paths, compiler flags...). A default search path for this file is the project's root directory.

All I need to do in my case (emacs + eglot + clangd) is run this task once (re-run it after adding new files) for getting linting, auto-completion, etc.

I think that vscode supports it too via the C++ extension, although by default the latter uses another way to get project configuration.

(Note: we could add a description to this pixi task)

Comment thread pyproject.toml
Comment on lines +99 to +108
[tool.pixi.feature.dev.tasks.configure]
cmd = "cmake -GNinja -S. -Bbuild/python -DSKBUILD_PROJECT_NAME=spherely -DSKBUILD_PROJECT_VERSION=0.0.0"
inputs = ["CMakeLists.txt"]
outputs = ["build/python/CMakeFiles/"]

[tool.pixi.feature.dev.tasks.compile]
cmd = "cmake --build build/python --config Debug"
depends-on = ["configure"]
inputs = ["src/*"]
outputs = ["build/python/spherely*"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are you using this essentially like a python setup.py build_ext --inplace when using setuptools, i.e. to just re-build the extension without going each time through a full pip install ... ?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The idea here is compiling the Python module simply by calling cmake instead of via a Python build tool and the scikit-build-core backend, which is mostly for getting more readable compilation outputs (not hidden by the tool, no extra verbosity, colors, etc.) in case we need to inspect errors or warnings.

Pixi does not run or depend on this task for re-installing Spherely, I think it does that with uv since Spherely is declared as a local pypi-dependency. Spherely builds are configured with no isolation and in a defined build directory (so re-builds are faster).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the explanation!

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

That said, I had troubles with the spherely Python module not being automatically re-built / re-installed each time when doing pixi install ... or pixi run tests after changing the C++ code. Maybe I'm doing something wrong? prefix-dev/pixi#1695 may be relevant too.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants