Dependency to npm package?

My Python code has a dependency to a npm package.

Is there way to …:

  1. Define this dependency in my git repo?
  2. Resolve the dependency if the code gets installed?

Not if you mean you want pip to install the npm package when you install your Python project (wheel), no. Pip doesn’t know how to install things using npm.

Probably the closest option you’re going to find, and what a number
of projects in the OpenStack community are using, is XStatic

In short, you create a very basic Python package which includes a
copy of the file(s) from NPM, for example:

Note that some likely consider this “impure” but if you’re really
looking for a way to install a Javascript library somewhere using
pip, no solution is going to be especially pure. More commonly you’d
ship something like a separate yarn.lock file in your package and
expect people to take the additional step of using that to pull your
required versions of JS libs after installation.

1 Like

I had a look at the idea of xstatic: The Idea — XStatic 1.0.1 documentation

After thinking about it again, I realize that the idea is good, but not feasible.

Every language has its own way to package the source code.

I feel familiar with pip, since I use Python since several years.

If I have dependency to a JS library, it does not make sense to force the JS code into a container which feels more familiar for me.

I will use npm for third party JS-libraries in the future.

The dream to have a universal package manager is nice, but not reality. Like the esperanto (the constructed international auxiliary language)