title: Install dependency’s extras if package’s specific extras is requested
body: <p>My project has Celery as a dependency. It’s a hard dependencies, ie. my project can’t live without it. However, it can use Redis as its backend, which my app doesn’t need specifically.</p>
  <p>I want my package to be set up so if a user installs dependencies with <code>poetry install -E redis</code>, it would install the <code>redis</code> block of Celery (as if it were specified in <code>pyproject.toml</code> as <code>celery = { version=&quot;^4.4.0&quot;, extras=[&quot;redis&quot;] }</code>).</p>
  <p>However, if a user uses a plain <code>poetry install</code> (without <code>-E redis</code>), i don’t want Celery’s Redis dependencies (as if it were only specified as <code>celery = &quot;^4.4.0&quot;</code>) to be installed.</p>
  <p>Is there a way to put this into Poetry config? Or should I track the optional requirements of <code>celery[redis]</code> and manually add them to my <code>pyproject.toml</code> file?</p>
  <p>I already checked the <a href="https://python-poetry.org/docs/dependency-specification/#expanded-dependency-specification-syntax" rel="nofollow noreferrer">Poetry documentation</a> on this matter, but it doesn’t offer a way to specify the same dependency (<code>celery</code> in my case) with different options.</p>