Skip to content

Conversation

rgaiacs
Copy link
Contributor

@rgaiacs rgaiacs commented Aug 16, 2025

Related to #1427

This is not yet ready for review!

The code is based on the Pipfile buildpack. We probably want to refactor some portions to avoid code duplication.

@rgaiacs rgaiacs self-assigned this Aug 16, 2025
@rgaiacs rgaiacs marked this pull request as draft August 16, 2025 12:55
@rgaiacs rgaiacs force-pushed the 1427-support-pyproject branch from 83b5f11 to 577cb1b Compare August 18, 2025 12:24
@rgaiacs rgaiacs marked this pull request as ready for review August 18, 2025 12:26
@rgaiacs rgaiacs changed the title Add for pyproject.yml to configure container image Add for pyproject.toml to configure container image Aug 18, 2025
@rgaiacs
Copy link
Contributor Author

rgaiacs commented Aug 18, 2025

577cb1b implements a minimal working version. It was tested with https://github.com/rgaiacs/binder-examples-pyproject.

Required changes before merge

  • To parse the pyproject.toml, we require tomllib that is part of Python 3.11 standard library. This means that we will have to change the minimal version of Python required by repo2docker to Python 3.11 or later.

Changes that can be done in another pull request

@rgaiacs rgaiacs requested a review from minrk August 18, 2025 12:33
Comment on lines 129 to 131
"""PATH="${KERNEL_PYTHON_PREFIX}/bin:$PATH" \\
pip install --no-cache-dir --editable .
""",
Copy link
Member

Choose a reason for hiding this comment

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

Can we do:

Suggested change
"""PATH="${KERNEL_PYTHON_PREFIX}/bin:$PATH" \\
pip install --no-cache-dir --editable .
""",
"${KERNEL_PYTHON_PREFIX}/bin/python3 -m pip install --no-cache-dir --editable .",

to be even more explicit than relying on $PATH?

@rgaiacs rgaiacs changed the title Add for pyproject.toml to configure container image Add buildpack for pyproject.toml to configure container image Aug 19, 2025
@rgaiacs rgaiacs requested a review from minrk August 19, 2025 07:37
@rgaiacs
Copy link
Contributor Author

rgaiacs commented Aug 19, 2025

All tests are passing after support to Python < 3.11 was dropped.

@manics
Copy link
Member

manics commented Aug 19, 2025

We probably want to refactor some portions to avoid code duplication.

I've got a PR that refactors the handling of runtime.txt
#1428

@rgaiacs rgaiacs force-pushed the 1427-support-pyproject branch from ad70986 to 974a559 Compare September 8, 2025 14:55
@rgaiacs
Copy link
Contributor Author

rgaiacs commented Sep 8, 2025

I rebased this pull request and I made minor changes to reduce the code duplication. It need to be reviewed again.

@rgaiacs
Copy link
Contributor Author

rgaiacs commented Oct 1, 2025

Can we merge this? Or should we talk about it in jupyterhub/team-compass#814?

@minrk
Copy link
Member

minrk commented Oct 1, 2025

To parse the pyproject.toml, we require tomllib that is part of Python 3.11 standard library.

We can depend on tomli for Python < 3.11, which is the package that became tomllib in 3.11, so we should be able to:

try:
    import tomllib
except ImportError:
    import tomli as tomllib

without losing any supported environments.

I think reverting the baseline version change and depending on tomli, and fixing detection of pyproject.toml contents, I think this should be all set.


pyproject_file = self.binder_path("pyproject.toml")

return os.path.exists(pyproject_file)
Copy link
Member

Choose a reason for hiding this comment

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

As discussed here, we should not consider the presence of pyproject.toml sufficient. We should return False if pyproject.toml does not contain both project and build-system.requires.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants