Skip to content
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

Issue with optparse #1

Open
mwarkentin opened this issue Feb 20, 2013 · 4 comments
Open

Issue with optparse #1

mwarkentin opened this issue Feb 20, 2013 · 4 comments

Comments

@mwarkentin
Copy link

I'm trying to use virtualenv-tools to clone a virtualenv on our servers during deploy, and ran into an issue while using it as described in the docs.

When attempting to run it like this: virtualenv-tools --update-path=/data/virtualenv/clone6 or this: virtualenv-tools --update-path /data/virtualenv/clone6, I get the following error:

error: . does not refer to a python installation

I added a print statement to debug what options and paths were being set to:
options, paths: {'update_path': '/data/virtualenv/clone6', 'reinitialize': None} []

I ended up running the following command, and it seemed to work:

2013-02-19--17-40-03)[mwarkentin@tide-acct-app-01 site-packages]$ virtualenv-tools --update-path=/data/virtualenv/clone6 /data/virtualenv/clone6
options, paths: {'update_path': '/data/virtualenv/clone6', 'reinitialize': None} ['/data/virtualenv/clone6']
A /data/virtualenv/clone6/bin/activate
A /data/virtualenv/clone6/bin/activate.fish
A /data/virtualenv/clone6/bin/activate.csh
B /data/virtualenv/clone6/lib/python2.7/copy_reg.pyo
B /data/virtualenv/clone6/lib/python2.7/warnings.pyc
B /data/virtualenv/clone6/lib/python2.7/posixpath.pyo
...

Should the docs be updated, or am I doing something wrong here?

@bracki
Copy link

bracki commented Apr 23, 2013

Apparently you have to run it from inside of your virtualenv you're wishing to relocate.

@nichochar
Copy link

Apparently you have to run it from inside of your virtualenv you're wishing to relocate

I think that's not true. It's just an option if you want to use auto.

I think it's just a bug in the way we try and get the arguments back from optparse:

    parser = optparse.OptionParser()
    parser.add_option('--reinitialize', action='store_true',
                      help='Updates the python installation '
                      'and reinitializes the virtualenv.')
    parser.add_option('--update-path', help='Update the path for all '
                      'required executables and helper files that are '
                      'supported to the new python prefix.  You can also set '
                      'this to "auto" for autodetection.')
    options, paths = parser.parse_args()
    print options
    print paths
    if not paths:
        paths = ['.']

Leads to this print:

{'update_path': '/Users/nicholas/dev/app, 'reinitialize': None}
[]
error: . does not refer to a python installation

So as we see. We want the variable path to contain options['update_path']... I'm modifying my script and if I have time later I'll make a pull request.

The fix I think is to add if not paths and not options.update_path to that if not path line above

Edit: I'm unsure now. Since this worked when run from within the env... How to refactor it properly. It's definitely broken, but not sure how to fix it elegantly right now. Might take a stab at it later

@jseadragon
Copy link

I ended up on this page because the docs are wrong here.

To get this working, I had to cd /tmp/build-cache. Should I open a new issue for this?

@nichochar
Copy link

This thread is a little stale, it may be a good idea.

asottile referenced this issue in Yelp/virtualenv-tools Nov 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants