Skip to content

Conversation

ulgens
Copy link
Member

@ulgens ulgens commented Sep 20, 2025

Replaces psycopg[c] with psycopg[binary] for development.

Relates to #2215

@ulgens ulgens force-pushed the psycopg-binary branch 4 times, most recently from 680ef1f to 8b9975f Compare September 20, 2025 17:02
@ulgens ulgens mentioned this pull request Sep 20, 2025
@ulgens ulgens requested review from Copilot and a team September 20, 2025 17:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the Django project to use the binary distribution of psycopg instead of the C extension version, switching from psycopg[c] to psycopg[binary] to simplify the deployment process.

  • Changes the psycopg dependency from the C extension variant to the binary distribution
  • Removes PostgreSQL development dependencies from the Docker build process
  • Simplifies the Docker image by eliminating compilation requirements

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
requirements/common.txt Updates psycopg dependency from [c] to [binary] variant
Dockerfile Removes PostgreSQL client tools and development libraries no longer needed for binary distribution

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ulgens ulgens self-assigned this Sep 20, 2025
@ulgens ulgens marked this pull request as ready for review September 20, 2025 17:34
@ulgens ulgens added the dependencies Pull requests that update a dependency file label Sep 21, 2025
gcc \
libc6-dev \
libpq-dev \
zlib1g-dev \
Copy link
Member

Choose a reason for hiding this comment

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

If finally we're going to use psycopg[binary] check if this depenencies are not needed to the compilation of other dependencies (eg: pillow).

If not, and we don't need any more of these system dependencies to compile python packages, I'll invite you to get rid of the whole section of installing debian packages (also compilers), and removing an leaving only the pip install line.

Copy link
Member Author

Choose a reason for hiding this comment

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

gcc and g++ are required for libsass. I looked for an alternative that doesn't require compiling but couldn't find one yet.

Copy link
Member

Choose a reason for hiding this comment

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

Is libsass requiring both gcc and g++ ?
Since you studied it, can we open a PR for the libsass repo to ask a wheel for recent python versions?

Copy link
Member

Choose a reason for hiding this comment

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

Or we can find an alternate package to replace 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.

I'll check this again.

https://github.com/sass/libsass-python says

Provides prebuilt wheel binaries for Linux, Windows, and Mac.

but our build fails with

77.32   × Building wheel for libsass (pyproject.toml) did not run successfully.
...
77.32       error: command 'gcc' failed: No such file or directory

when those dependencies are not installed.

This feels more a like bug, rather than a missing feature in the libsass package.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for checking.
It seems there isn't a valid python alternative to libsass-python that I know.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there any action needed here?

Copy link
Member

@tobiasmcnulty tobiasmcnulty left a comment

Choose a reason for hiding this comment

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

Thanks for working on this.

As mentioned by @pauloxnet, psql was only recently removed and re-added, and should be restored before this is merged.

Also, it appears we can solve the compilation issue for local dev and still use the [c] variant in the production image.

Copy link
Member

@tobiasmcnulty tobiasmcnulty left a comment

Choose a reason for hiding this comment

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

In reviewing this PR again and the psycopg release notes, I noticed the PR description mentions this PR supersedes #2205, but this PR doesn't bump the version of psycopg to 3.2.10 like #2205. Is there a reason to keep it at 3.2.9?

@ulgens ulgens force-pushed the psycopg-binary branch 2 times, most recently from fd601f2 to 752036c Compare September 23, 2025 23:13
@ulgens
Copy link
Member Author

ulgens commented Sep 23, 2025

Is there a reason to keep it at 3.2.9?

No, I don't intend to keep the version outdated. We can update this PR and close the Dependabot PR, or we can merge this PR, and Dependabot will create another PR to update it. My point was that we don't need both PRs to be merged.

@ulgens
Copy link
Member Author

ulgens commented Sep 23, 2025

I updated the dependency version, separated the definitions for dev and prod, reverted the removal of runtime dependencies, and updated the PR title.

The CI failure doesn't seem related to the changes in the PR and I could use help to handle it: https://github.com/django/djangoproject.com/actions/runs/17961730284#summary-51086239582

@ulgens ulgens requested a review from pauloxnet September 23, 2025 23:17
@ulgens ulgens marked this pull request as draft September 23, 2025 23:22
@ulgens ulgens changed the title Use the binary version of psycopg Use the binary version of psycopg for development Sep 23, 2025
@tobiasmcnulty
Copy link
Member

The CI failure doesn't seem related to the changes in the PR and I could use help to handle it:

I reverted the offending commit for now. Hopefully the build will pass if you rebase again.

@ulgens ulgens marked this pull request as ready for review September 24, 2025 11:17
@ulgens
Copy link
Member Author

ulgens commented Sep 24, 2025

I reverted the offending commit for now. Hopefully the build will pass if you rebase again.

Thanks you. CI is passing now. I moved the PR out of draft status.

@ulgens ulgens requested a review from a team October 1, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants