shotesss
shotesss

Reputation: 21

Vendoring python packages for a published package

I currently have a package that I would like to publish to pypi, which requires another package (https://github.com/CrisisTextLine/scrubadub) that is a fork of the original scrubadub package. I am trying to vendor the scrubadub fork, but I haven't found any resource on how to vendor packages in python.

I'd like to support python2 and python3 for the package I distribute. My concerns include:

How would I go about this?

Upvotes: 2

Views: 5805

Answers (2)

sorin
sorin

Reputation: 170798

As of 2022, if you are about to use a tool to ease the vendoring process instead of DIY (manually), I would recommend https://pypi.org/project/vendoring/ because that is used actively by pip itself.

There were other projects but I checked them and they do not seem to be actively maintained.

Upvotes: 2

MatthewMartin
MatthewMartin

Reputation: 33183

If you are redistributing

  • check if the license is compatible
  • Copy the code into your modules folder
  • Update all the import statements until all the imports resolve again
  • Include licenses for vendorized
  • Yes, you'll need to either vendorize dependencies, or at least add them to your own dependency list in setup.py.

Consider using something like python-vendorize to automate and make the workflow less ad hoc.

If you are not redistributing, then the vendor folder acts sort of like a manual virtual environment folder or extra site-packages folder.

  • add a folder, e.g. /vendor/
  • copy all vendorized modules there.
  • You don't have to update namespaces
  • You could pip install . -e them, or add their dependencies to your dependency files (requirements.txt, Pipfile, etc)
  • Update PYTHONPATH to include the /vendor/ folder.

Consider using something like Vendy to automate this and make the workflow less ad hoc.

Upvotes: 1

Related Questions