sashahart / vex

Run a command in the named virtualenv.
MIT License
372 stars 26 forks source link

WIP: Make default python configurable #47

Closed ncoghlan closed 5 years ago

ncoghlan commented 8 years ago

I keep forgetting to specify /usr/bin/python3 when creating new virtual environments, so I'd like to be able to specify that in .vexrc as python=/usr/bin/python3.

I've marked it as a work-in-progress, since it still needs at least docs and test updates, but I figured it made sense to see what you thought of the general idea and implementation strategy before working on those.

sashahart commented 5 years ago

Thanks for engaging politely and marking this a WIP and noting that more work is required.

You can use ~/.gitignore to ignore .pyc and .egg-info files, and then you don't have to duplicate that configuration for every project, and have surprises when it is or isn't included. So I don't want that change in the repo. Can you remove it from the PR? edit: also, I neglected to mention, the version bump. I would like to manage that.

Otherwise, I am fine with adding this one small thing to vexrc, even though I would not use it. The main blocker would be to rough out a test. I might do that when I have time, or someone else could supply it. In any case, I will be happy to bump the version number and push another version when this is cooked.

ncoghlan commented 5 years ago

For the test, I'm wondering if it may make sense to also add a --dry-run option for --make, such that the --python option can be tested without having to actually follow through and make a virtual environment. That way the --python test wouldn't need to provide a reference to a real target Python: it could just check that the passed in value appeared in the --dry-run output.

The --dry-run option itself could be tested by comparing what it emits to what actually gets used as the base for the created virtual environment.

sashahart commented 5 years ago

Your code works fine for me on python3.7, python3.6, pypy3.5, python2.7 and pypy. I did not test python3.4, 3.3 or 3.2 because I am lazy and doubt there are many surprises there.

I created branch default-python on this repo.

See if it works for you as you expect. If you're happy, I'll rebase your final-draft commit on top of the test and toss a line or two into the README.

The test I wrote is crude and perfunctory - it points to an included script as if it were a python interpreter, and doesn't really run virtualenv - but I think it does what I want at least for now.

ncoghlan commented 5 years ago

@sashahart That branch looks excellent to me, thanks!

Regarding the new test case, that's definitely a lot simpler and more straightforward than what I had in mind.

I wondered whether there might be cases where the shebang line didn't resolve correctly but the tests would pass otherwise, but suspect it probably makes sense to wait and see if anyone actually runs into problems with that, rather than making the test more complex without a demonstrated need.

sashahart commented 5 years ago

Sorry about the delay. Check out #57

ncoghlan commented 5 years ago

Incorporated into #57, so this isn't needed. Thanks @sashahart!