Skip to content

Remove deprecated stdlib cgi usage, replace pipenv with uv, bundle requirements in pyproject.toml#100

Open
spwoodcock wants to merge 2 commits intoopengisch:masterfrom
hotosm:build/no-requirements-txt
Open

Remove deprecated stdlib cgi usage, replace pipenv with uv, bundle requirements in pyproject.toml#100
spwoodcock wants to merge 2 commits intoopengisch:masterfrom
hotosm:build/no-requirements-txt

Conversation

@spwoodcock
Copy link
Contributor

@spwoodcock spwoodcock commented Mar 11, 2026

  • The initial issue I was encountering was installing a modifed version of this lib, the deps were not installed. That's because they are defined in an external requriements.txt file, instead of pyproject.toml, as read by most dependency solvers these days.
  • To give this SDK a fresh lick of paint, I updated a few things together (they can be separated out if preferred):
    1. The stdlib cgi module was deprecated in Python 3.11 and removed in 3.13. I replaced the single instance of usage with the stdlib email package, a pretty common approach (albiet somewhat hacky). See the detailed commit message for more info.
    2. Replace pipenv with uv. Pipenv was a great project at the time. Now imo the alternatives are uv, poetry, pdm (with better conformance to subsequent PEPs).
    3. Removed requirements.txt and instead listed the requirements directly in the pyproject.toml file. Now when I install a custom version (from a git branch), the dependencies come along with it).
  • I took the liberty to bumb the minimum python version from 3.8 --> 3.9 (which is still EOL, but I didn't want to push it too far - that can be another PR).
  • Python 3.13 should in theory be supported now the cgi usage is removed.

Checks:

  • Updated the docs
  • Confirmed the tests all pass ENVIRONMENT=test uv run python -m unittest tests.test_cli_client
  • Verify building still works

A commonly recommended replacement for the deprecated cgi package in PEP594. Using an email Message object to parse an HTTP header is a little hacky, but since HTTP's Content-Disposition syntax was derived from MIME, they're compatible enough in practice
@suricactus
Copy link
Collaborator

Thanks!

Saved me a few hours, I am using uv recently with greater confidence it's simpler than any other tool before.

The only question I have is whether the publishing on PyPi will work, but this is something we should worry about.

Will be merged soon, just be a bit patient.

BTW, you had to modify the library because you extended QFC on your own, or because it's current behaviour had shortcomings?

@spwoodcock
Copy link
Contributor Author

I think publishing to PyPi shouldn't be affected, as it's using build outside of uv & building the dist succeeds with the new setup. One one way to find out for real though!

Yesterday I work working on adding an API to QFC to create new users, including updating to this lib to allow doing it via the SDK too.

I planned to make a PR for both & see what your thoughts were (not certain how it fits into the roadmap / current thinking internally. I can keep it custom for now if needed, or we can find a way forward for it)

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