0

I have a small package and I want to customize my setup.py

from setuptools import setup, find_packages
import sys

if '--bla' in sys.argv:
    sys.argv.remove('--bla')
    print('bla!')

setup(name='my_pkg', packages=find_packages())

This setup.py allows me to run

python setup.py bdist_wheel and python setup.py bdist_wheel --bla

$ python setup.py bdist_wheel
running bdist_wheel
...


$ python setup.py bdist_wheel --bla
bla!
running bdist_wheel
...

however, running pip install -e --bla breaks:

$ pip install -e . --bla

Usage:   
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

no such option: --bla

Can I make pip respect the setup.py argument parser? Is there a better place to add the parser so I would be able to both create wheels and install in editable mode?

CIsForCookies
  • 12,097
  • 11
  • 59
  • 124
  • 1
    You probably want this answer: https://stackoverflow.com/a/53833930/9203110 – match Sep 02 '21 at 12:53
  • Does this answer your question? [How to obtain arguments passed to setup.py from pip with '--install-option'?](https://stackoverflow.com/questions/18725137/how-to-obtain-arguments-passed-to-setup-py-from-pip-with-install-option) – match Sep 02 '21 at 12:53
  • @user202729 not trying to compare. I want both options to work – CIsForCookies Sep 02 '21 at 12:53
  • @match this seems like a parser-per-command where my code should have handled all sub-commands... – CIsForCookies Sep 02 '21 at 12:55
  • @mat Not really a duplicate, but reading the linked question does solve this question (passing ` --install-option=--bla` to pip). https://meta.stackoverflow.com/questions/258804/duplicate-question-but-only-when-you-know-the-answer seems to suggest closing – user202729 Sep 02 '21 at 12:56
  • Besides the method linked there is the "proper" way to parse these arguments. – user202729 Sep 02 '21 at 12:57

0 Answers0