question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pip install ignores extras defined under pyproject.toml

See original GitHub issue
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Issue

Hi, I’m trying to specify extras to my package,

My pyproject.toml contains optional dependencies:

[tool.poetry.dependencies]
mlflow = { version = "<2.0.0", optional = true }

And under extras I’ve defined it just like the documentation:

[tool.poetry.extras]
my_extra = ['mlflow']

The command poetry install -E my_extra works properly for local development.

But when I build the package, and try installing it with pip (from another project) running pip install mypkg[my_extra] I get the following message:

  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
  Ignoring mlflow: markers 'extra == "my_extra"' don't match your environment
...
...

I’m not sure why this is happening, previously with setup.py it never ignored my extras.

So I’ve tried playing around the pyproject.toml and I found a strange thing When I modified my_extra to specify the package versions:

[tool.poetry.extras]
my_extra = ['mlflow<2.0.0']

The installation with pip doesn’t ignore the extras anymore, BUT the poetry install -E my_extra command has stopped working…

Am I missing something? or is it a bug?

EDIT: The versions I’m using Poetry version: 1.1.4 pip version: 20.2.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
orleviicommented, Nov 22, 2020

Ok, I’ve figured it out -

if you name your extra with capital letters (in pyproject.toml), for some reason it ignores it with pip

The strange part is that apparently extras are case insensitive, so it doesn’t really matter pip install ./mypkg[EXT] is the same as pip install ./mypkg[ext] and yet, defining your extras like

[tool.poetry.extras]
EXT = ['...']

won’t work as intended.

I’m closing this issue, Thanks everyone for helping!

0reactions
sinoroccommented, Nov 25, 2020

OK. You had me worried. Thanks for confirmation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is poetry ignoring extras or pyproject.toml is misconfigured?
What in fact I want to achieve is to specify that extra for yolo project exists, it's called dev and includes installing ipdb....
Read more >
Pip not picking up build requirements from pyproject.toml
I'm trying to force my users to have to install wheel when they try to install my project for local development. However, it...
Read more >
The pyproject.toml file | Documentation | Poetry
When a script is added or updated, run poetry install to make them available in the project's virtualenv. extras #. Poetry supports extras...
Read more >
Changelog - pip documentation v22.3.1
When this field is present for a release link, pip will ignore the download when installing to a Python version that doesn't satisfy...
Read more >
Flit Documentation
python3 -m pip install flit. 3. Run flit init in the directory containing the module to create a pyproject.toml file. It will look...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found