sizmailov / pybind11-stubgen

Generate stubs for python modules
Other
232 stars 47 forks source link

pip uninstall myModule - Not deleting entire myModule folder #84

Closed nyckmaia closed 2 years ago

nyckmaia commented 2 years ago

Hi,

After I generate the Python stubs using pybind11-stubgen, I installed this stubs using a custom Python script that copies all generated stubs files to inside the myModule installed directory (which in my case is: ~/.local/lib/python3.8/site-packages/myModule/

All works good! No problems.

Problem

Now, if I try to uninstall this package using pip uninstall myModule, this command deletes all files inside the myModule installed directory, but remains the root folder and the copied stubs files.

Question

What I need to do to be able to call pip uninstall myModule and get all files and the MyModule root installed directory deleted?

Thank you,

My System:

sizmailov commented 2 years ago

Since you "installed" files with a custom script the uninstallation must be custom too :) To make it more straightforward make the stubs a part of your package distribution.

nyckmaia commented 2 years ago

@sizmailov I would like to make it straightforward making the stubs a part of my package distribution.

That was my first question here: https://github.com/sizmailov/pybind11-stubgen/issues/79#issuecomment-1196813093

My doubt is: How can I put the stubs inside my Python package if to generate the stubs is necessary that myPackage MUST BE already installed in my Python environment?

Could you please help me about how can I generate the stubs before install myPackage?

sizmailov commented 2 years ago

The only requirement for pybind11-stubgen is to be able to import the module. All you need is to make your module available for import.

Probably you would do something along those lines in CI:

  1. Build module and make it importable by python interpreter.
  2. Generate stubs & place them in the source tree and add it to MANIFEST.in
  3. Package your module and stubs into a package distribution
  4. (optional) Upload distribution to PYPI

I don't have an example script at hand that does all that, so I can't provide you with the exact script with step-by-step instructions. Maybe some of the dependent projects already do something like that, please check.

Sorry for the little help here.