Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice for seeder plugin #1980

Closed
ofek opened this issue Oct 13, 2020 · 8 comments
Closed

Advice for seeder plugin #1980

ofek opened this issue Oct 13, 2020 · 8 comments

Comments

@ofek
Copy link
Contributor

ofek commented Oct 13, 2020

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?

@ofek
Copy link
Contributor Author

ofek commented Nov 7, 2020

Bump 🙂

Does anyone have an example of this?

@gaborbernat
Copy link
Contributor

Ah forgot about this, can you ping me again on Monday? 😁And I'll have a look and path forward.

@ofek
Copy link
Contributor Author

ofek commented Nov 10, 2020

Ping!

@gaborbernat
Copy link
Contributor

cc @gaborbernat do you have any recommendations?

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.

@ofek
Copy link
Contributor Author

ofek commented Nov 10, 2020

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 --extra-search-dir but that did not work.

@gaborbernat
Copy link
Contributor

gaborbernat commented Nov 10, 2020

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.

@acmpo6ou
Copy link

acmpo6ou commented Dec 9, 2021

Hey guys!

I also need this, I need a certain package (rich) to be installed in every venv I create with virtualenv. But I need it to be fast, so that when I create a venv it is created fast and it contains pip, wheel, setuptools and rich. It probably has to use the magic app-data and not pip when installing rich.

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!

@gaborbernat
Copy link
Contributor

I don't think that plugin has been created, so you'd likely need to do so 👍

@pypa pypa locked and limited conversation to collaborators Dec 9, 2021
@gaborbernat gaborbernat converted this issue into discussion #2245 Dec 9, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants