Skip to main content

Keep requirements.txt in sync with what your code actually imports.

Project description

reqsync

Keep requirements.txt in sync with what your code actually imports.

reqsync scans every .py file in your project using Python's AST parser, figures out which third-party packages you import, and cross-references that against your requirements.txt — showing you what's missing, unused, or unpinned.

Zero runtime dependencies. Works on any Python 3.8+ project.


Install

pip install reqsync

Usage

Check for drift

reqsync check

Show file locations of missing imports

reqsync check --locations

Fix — add missing packages automatically

reqsync fix

Preview what fix would do (no writes)

reqsync fix --dry-run

Fix and pin to installed versions

reqsync fix --pin

Also remove unused packages (careful — may include transitive deps)

reqsync fix --remove-unused

See all third-party imports found in the project

reqsync scan

How it works

  1. Scan — walks all .py files and extracts every import and from ... import statement using ast.parse()
  2. Resolve — maps import names to pip package names
  3. Diff — compares the resolved set against your requirements.txt.
  4. Fix — rewrites requirements.txt, preserving comments and existing pins.

Options reference

Flag Command Description
--root DIR all Project root to scan (default: .)
--req FILE all Requirements file (default: requirements.txt)
--no-tests all Exclude tests/ directories
--locations check Show file:line for each missing import
--no-unpinned check Hide unpinned warnings
--dry-run fix Preview without writing
--pin fix Pin to installed version when adding
--remove-unused fix Remove unused entries (use with care)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

importsync-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

importsync-0.1.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file importsync-0.1.0.tar.gz.

File metadata

  • Download URL: importsync-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for importsync-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7cf89853f3b17a38cddfa2681bd1c05cc46b88545669a9b14d9bb77669aeecd0
MD5 455a51ad2b35b502c8ba9e78d877d8d2
BLAKE2b-256 521771233499630fdd56223d0b2bf4d3b291d36e3d09b53206b9629b905f6aa0

See more details on using hashes here.

File details

Details for the file importsync-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: importsync-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for importsync-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c9cad98c992d88b46db2c943c787714bd7189e35aead541f7cda15f3640d842
MD5 4c6a4706125fc61b40502114abe24a0e
BLAKE2b-256 472afe15d88510246a9dbd3ffd29c6b709b801aadc79356ed4847ff53ba83351

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page