Advice for seeder plugin #2245
-
I've read the docs & source code of the built-in seeders but I can't quite figure out what to do. Essentially, all I need is to install a certain package/wheel when each virtual environment is created. cc @gaborbernat do you have any recommendations? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 1 reply
-
Bump 🙂 Does anyone have an example of this? |
Beta Was this translation helpful? Give feedback.
-
Ah forgot about this, can you ping me again on Monday? 😁And I'll have a look and path forward. |
Beta Was this translation helpful? Give feedback.
-
So my original idea was that in this case, you could extend your code from an existing seeder, and then you can do it at the end of the run method: from virtualenv.seed.embed.via_app_data.via_app_data import FromAppData
class CustomSeeder(FromAppData):
def run(self, creator):
super().run()
subprocess.run([self.exe, '-m', 'pip', 'install', 'magic']) # setup.cfg
virtualenv.seed =
custom = virtualenv_plugin.CustomSeeder One thing that's not really solved, though, is how you enable this seeder. The user would have to opt-in to use it explicitly via config/CLI args. Of course, you can always use monkey patch the default here ... but there's no official way at the moment to change the default seeder without explicit opt-in. |
Beta Was this translation helpful? Give feedback.
-
Thanks! If I ship the wheel, is there a way to add it to the list of embedded wheels so it automatically gets installed? I tried |
Beta Was this translation helpful? Give feedback.
-
You can extend the list of packages to install under https://github.com/pypa/virtualenv/blob/main/src/virtualenv/seed/embed/base_embed.py#L38. You might need to patch the embed file list under https://github.com/pypa/virtualenv/blob/main/src/virtualenv/seed/wheels/embed/__init__.py#L7 to get picked up. Tag me as a reviewer if you can, so can double-check how you do it looks good. |
Beta Was this translation helpful? Give feedback.
-
Hey guys! I also need this, I need a certain package ( It seems that you guys are talking exactly about this, aren't you? Do you know how to configure virtualenv, so that it does what I need? Thank you! |
Beta Was this translation helpful? Give feedback.
-
I don't think that plugin has been created, so you'd likely need to do so 👍 |
Beta Was this translation helpful? Give feedback.
So my original idea was that in this case, you could extend your code from an existing seeder, and then you can do it at the end of the run method:
One thing that's not really solved, though, is how you enable this seeder. The user would have to opt-in to use it explicitly via config/CLI args. Of course, you can always use monkey patch the default…