npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

sync-pyproject-nx-deps

v1.2.0

Published

Sync pyproject.toml workspace dependencies to Nx project.json implicitDependencies

Readme

sync-pyproject-nx-deps

A TypeScript CLI tool that automatically synchronizes Python workspace dependencies from pyproject.toml files to Nx monorepo project.json files.

Overview

This tool bridges the gap between Python's uv package manager workspace dependencies and Nx's implicit dependencies system. It automates the process of keeping Nx's dependency graph in sync with Python workspace dependencies, preventing manual errors and maintaining accurate build graphs.

Features

  • Automatic Synchronization: Keeps Nx implicitDependencies in sync with Python workspace deps
  • Smart Updates: Only writes files when changes are detected
  • Graceful Error Handling: Warnings don't stop the entire sync process
  • Deterministic Output: Dependencies are always sorted alphabetically
  • Quoted Name Support: Handles special characters in package names
  • Package Name Mapping: Translates between Python package names and Nx project names

Installation

npm install -g sync-pyproject-nx-deps

Or use directly with npx:

npx sync-pyproject-nx-deps

Usage

CLI

# Sync dependencies in the current directory
sync-pyproject-nx-deps

# Sync dependencies in a specific directory
sync-pyproject-nx-deps ./python

# Using npx
npx sync-pyproject-nx-deps ./python

Programmatic API

import { syncPyprojectDeps } from 'sync-pyproject-nx-deps';

await syncPyprojectDeps('./python');

How It Works

Architecture

The tool follows a pipeline-based architecture with 4 main stages:

Scanner → Mapper → Parser → Updater
  1. Scanner: Discovers all pyproject.toml files in the monorepo
  2. Mapper: Maps Python package names to Nx project names
  3. Parser: Extracts workspace dependencies from [tool.uv.sources]
  4. Updater: Updates project.json files with implicitDependencies

End-to-End Workflow

User runs: sync-pyproject-nx-deps ./python

1. Scanner finds:
   python/package-a/pyproject.toml
   python/package-b/pyproject.toml

2. Mapper builds mapping:
   { "package-a": "python-package-a", "package-b": "python-package-b" }

3. Parser extracts workspace deps from package-a's pyproject.toml:
   [tool.uv.sources]
   package-b = { workspace = true }

4. Mapper translates Python names to Nx names:
   ["package-b"] → ["python-package-b"]

5. Updater writes to package-a's project.json:
   { "implicitDependencies": ["python-package-b"] }

Example

Python Workspace Setup

python/package-a/pyproject.toml:

[project]
name = "package-a"

[tool.uv.sources]
package-b = { workspace = true }
"quoted-package" = { workspace = true }

python/package-a/project.json:

{
  "name": "python-package-a"
}

After Running sync-pyproject-nx-deps

python/package-a/project.json:

{
  "name": "python-package-a",
  "implicitDependencies": ["python-package-b", "python-quoted-package"]
}

Requirements

  • Node.js >= 18
  • Python projects using uv package manager
  • Nx monorepo with project.json files

Project Structure

src/
├── cli.ts              # CLI entry point
├── index.ts            # Library entry point
└── lib/
    ├── scanner.ts      # Finds all pyproject.toml files
    ├── mapper.ts       # Maps Python package names to Nx project names
    ├── parser.ts       # Extracts workspace dependencies
    ├── updater.ts      # Updates project.json files
    └── sync.ts         # Main orchestrator

Development

Setup

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Run in development
npm run dev

Testing

The project includes comprehensive test coverage:

npm test

Tests cover:

  • Parser for various pyproject.toml scenarios
  • Updater for file modification behavior
  • Integration tests for the full sync workflow
  • Edge cases: empty dependencies, quoted names, missing sections

Use Case

This tool is designed for Python monorepos managed by Nx that use the uv package manager. It solves the problem of manual dependency synchronization:

  • Python side: Uses pyproject.toml with [tool.uv.sources] for workspace dependencies
  • Nx side: Uses project.json with implicitDependencies for build graph
  • This tool: Automates the bidirectional translation and keeps them in sync

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.