Skip to content

Instantly share code, notes, and snippets.

@stavxyz
Last active August 29, 2015 13:57
Show Gist options
  • Save stavxyz/9863169 to your computer and use it in GitHub Desktop.
Save stavxyz/9863169 to your computer and use it in GitHub Desktop.
--minimal ( still mostly broken )

#the state of things with --minimal

What I have here is part conundrum, part dilemma, and part quagmire, but not really anything in between.

To demonstrate what it's been like trying to implement this...
quagmire

Though unlike Heisenberg I can confidently say I never willfully made things worse.

###skip to the tl;dr


pip's --install-option tag

pip install supports being called with the --install-option tag.
To use, any of the following are valid:

  • pip install <package> --install-option --minimal
  • pip install <package> --install-option=--minimal
  • pip install <package> --install-option="--minimal"

pip's verbatim description:

--install-option <options>  Extra arguments to be supplied to the setup.py install command
                            (use like --install-option="--install-scripts=/usr/local/bin").
                            Use multipl --install-option options to pass multiple options
                            to setup.py install.

However, when calling pip install with --install-option, it looks like pip is applying that option "too far". Not only is it applied when calling setup.py for the package you are installing, (in this case pyp-sandbox), but also to the setup.py of any dependency it installs during that process (in this case simplejson), resulting in:

Complete output from command /Users/smlstvnh/.virtualenvs/pyp-sandbox-dev/bin/python -c "import setuptools, tokenize;__file__='/Users/smlstvnh/.virtualenvs/pyp-sandbox-dev/build/simplejson/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/th/5hc9919d3dx18_f_6frt9f7r0000gn/T/pip-OdeXa2-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/smlstvnh/.virtualenvs/pyp-sandbox-dev/bin/../include/site/python2.7 --minimal:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help



error: option --minimal not recognized

####This is only the most recent roadblock I have hit, and I don't have a fix for it yet.


My current setup:

As soon as things proved to be non-trivial, I set up a python package repository to use as a sandbox rather than futzing with satori directly. I also traced some odd behavior (a nice way to say bug) I was seeing to some code in pbr, then forked and patched it: https://github.com/smlstvnh/pbr/tree/bug/no-clobber.

why exactly do you have a fork of pbr?

My fork includes a fix that allows for subclassing pbr's command classes. Without the patch, any command classes specified in your setup.cfg are clobbered by pbr on the lines addressed in this commit

https://github.com/smlstvnh/pbr/commit/5be16acf05195268d951815c3522982f23c4c58c

I plan on submitting this patch for review upstream soon. I had a very hard time tracking this down.


trying things

pyp-sandbox indicates a hard setup requirement for pbr-samstav, otherwise this won't work even a little bit. To test out the current functionality, or rather the lack thereof, you can use pip. Everything's on pypi.

To attempt to install the --minimal version:

# I think pip will complain about not finding a distribution if you don't include the version.
# the fact that you need to specify that git version is unrelated to the minimal tag

pip install pyp-sandbox==8411eb0 --install-option --minimal

If I observed correctly, this ^^ will bomb out with error: option --minimal not recognized, unless 1) you already have pyp-sandbox installed, or 2) you already have pyp-sandbox's dependencies installed. As I mentioned above, I believe the error occurs because pip passes down any option you give to --install-option to every setup.py it calls during a pacakge installation, including the setup.py of any dependency, which of course is not going to be using my custom install class which defines --minimal as an option.

The "minimal" version has the following dependencies:

requests
msgpack-python

Now, the normal version. Installing the normal version works as expected.

The following will install the "full" (normal) version of pyp-sandbox:

# I think pip will complain about not finding a distribution if you don't include the version.
# the fact that you need to specify that git version is unrelated to the minimal tag

pip install pyp-sandbox==8411eb0

The "full" (normal) version has the following dependencies:

simplejson
airbrake
msgpack-python
requests

Without pip

Technically, at this point, the only way to get a minimal install is to:

git clone [email protected]:smlstvnh/pyp-sandbox && cd pyp-sandbox
python setup.py install --minimal

If you think like I do, you're thinking, "It's ridiculous that that works and the other methods don't."

My opinion is: The fact that this ^^ works and the others things don't is proof that the python packaging toolchain sucks.

The sentiments are echoed:

Which brings me to, one of the only decent counter ideas: Create a metapackage for satori that understands the minimal option (or any option) and maybe use some kind of post-setup hook, or the custom run() method to "manually" install a list of reqs. That req would either be satori-full or satori-minimal, both of which would also be available on pypi and could be installed without an option by just saying pip install satori-minimal or pip install satori-full == pip install satori.


tl;dr

YES, lets make completely separate packages on pypi. No big deal.

####OR

Help me figure out how to overcome the most recent roadblock i.e. error: option --minimal not recognized, with the knowledge that I have already overcome 6 or 7 getting this far. Yes I tried popping it off of sys.argv.

To reproduce the latest roadblock, run

pip install pyp-sandbox==8411eb0 --install-option --minimal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment