Distribute script that uses third party libraries

For anyone interested, my current approach is to add the desired 3rd party libraries to a separate ‘lib’ extension:

  1. Create a ‘lib’ extension
  2. Mimic the CPython engine embedded in PyRevit by creating a Conda environment with the same Python version
  3. Activate the environment and pip install the desired 3rd party libraries to the ‘lib’ extension: pip install <packages> --target=<path to lib extension>
  4. Remove unnecessary files (e.g. __pycache__)
  5. Add the ‘lib’ extension as dependency to extensions where you want to use the 3rd party libraries

This avoids users from mimicking the CPython environment themselves, as all 3rd party library files are in the ‘lib’ extension. Not sure if I will run into issues later, but for now it seems to work.

6 Likes