Actually activate the venv when building the wheelhouse #282

Merged
merged 1 commit into from Nov 14, 2016

Conversation

Projects
None yet
3 participants
Member

johnsca commented Nov 14, 2016

Description of change

Checklist

  • Have you followed Juju Solutions hacking guide?
  • Are all your commits [logically] grouped and squashed appropriately?
  • Does this patch have code coverage?
  • Does your code pass make test?

Fixes #276

Also removes a deprecation warning by switching to pip download and
pins the pip version used in the venv to prevent unexpected major
version changes in the future.

Member

johnsca commented Nov 14, 2016

I believe this should also fix #274

#274 is actually fixed by 3625af6

charmtools/build/tactics.py
+ def _pip(self, *args):
+ # have to use bash to call pip to activate the venv properly first
+ utils.Process(('bash', '-c', ' '.join(
+ ('.', self._venv / 'bin' / 'activate', ';', 'pip3') + args
@mbruzek

mbruzek Nov 14, 2016

Contributor

You initialize _venv to None. Do you need to check for none before doing this path creation?

@johnsca

johnsca Nov 14, 2016

Member

It's an internal method that should only be called from call. I can add an assertion; it will blow up either way but maybe the error will be more useful.

+ ('virtualenv', '--python', 'python3', self._venv)
+ ).exit_on_error()()
+ self._pip('install', '-U',
+ '"pip>=9.0.0,<10.0.0"',
@mbruzek

mbruzek Nov 14, 2016

Contributor

Is version 9.x valid in all cases? I saw a PR come through recently where version 1.x was used to fix a bug on trusty. Do we need to carry that through here as well? Series determination I mean.

@johnsca

johnsca Nov 14, 2016

Member

Version 1.x is required in the install_requires because that has to match the pre-installed system pip in order for the command to launch. This is installing a newer version of pip into the venv, which is needed to be able to build the wheelhouse.

Edit: To clarify, the system-level pip (1.x) is required to bootstrap the process and is used to create the venv and install into the venv the newer version of pip which supports the download and wheel commands.

charmtools/build/tactics.py
- create_venv = venv is None
- venv = venv or path(tempfile.mkdtemp())
- pip = venv / 'bin' / 'pip3'
+ create_venv = self._venv is None
@mbruzek

mbruzek Nov 14, 2016

Contributor

This method does not use the "venv" parameter in this version of the code. I would recommend removing or keeping the logic as it was previously.

Actually activate the venv when building the wheelhouse
Fixes #276

Also removes a deprecation warning by switching to `pip download` and
pins the pip version used in the venv to prevent unexpected major
version changes in the future.
Contributor

mbruzek commented Nov 14, 2016

I have reviewed this code and the logic looks good to me. +1

Thanks for addressing my comments!

@marcoceppi marcoceppi merged commit bf840f5 into master Nov 14, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@marcoceppi marcoceppi deleted the issue-276 branch Nov 14, 2016

marcoceppi added a commit that referenced this pull request Nov 14, 2016

#282: Actually activate the venv when building the wheelhouse (fixes #…
…276)

* Removes a deprecation warning by switching to `pip download`
* Pins the pip version used in the venv to prevent unexpected major version changes in the future
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment