Closed Bug 1458812 Opened 7 years ago Closed 6 years ago

Use pipenv to manage environment for mach python-test command

Categories

(Firefox Build System :: General, enhancement)

3 Branch
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1388013

People

(Reporter: davehunt, Assigned: davehunt)

References

Details

Attachments

(11 files)

59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
ahal
: review+
Details
59 bytes, text/x-review-board-request
ahal
: review+
Details
59 bytes, text/x-review-board-request
ahal
: review+
Details
Splitting this out as a blocker for bug 1388013. Here I'll aim to get the |mach python-test| command to use pipenv to manage the environment using Python 2.7, which we can then build on for optionally switching to Pyhton 3.
Initially I wanted to make this switch |mach python-test| to pipenv, but there are several subsuites that will take additional work. For example, I hit issues running the mach tests due to some mach packages not being included in the distribution, leading to some potential refactoring so that these packages are included, but without including the tests themselves. I managed to get some working without too much trouble, such as taskgraph and marionette harness, but rather than fight my way through these I decided to make pipenv a command line opt-in for now. I was thinking that once all of the suites are capable of running through pipenv, then we can remove this option and make it the default behaviour. For now, I've focused on the mozbase tests.
Comment on attachment 8974356 [details] Bug 1458812 - Vendor pytest 3.5.1; https://reviewboard.mozilla.org/r/242698/#review248540 ::: third_party/python/pytest/.coveragerc:1 (Diff revision 1) > +[run] > +omit = > + # standlonetemplate is read dynamically and tested by test_genscript > + *standalonetemplate.py Could you vendor the unzipped wheels instead of the source distributions? This way it'll exclude all of the extra repo and test files, saving a bit of space. I normally run: $ cd third_party/python $ pip wheel pytest==3.5.1 # this also downloads dependency wheels Then for each package: $ rm -rf pytest $ unzip pytest-3.5.1-py2.py3-none-any.whl -d pytest -x "*.dist-info/*" $ unzip pytest-3.5.1-py2.py3-none-any.whl -d pytest "*.dist-info/LICENSE.*" $ mv pytest/*.dist-info/* pytest $ hg addremove pytest We should probably put this in a script somewhere, at least until we implement a proper `mach vendor python` that uses pipenv. I just added the LICENSE step, so for many of these packages, it'll be a new file being added. p.s, I don't really care if these are split out into separate commits or not. So feel free to vendor pytest and all the dependencies in the same commit if that's easier for you.
Attachment #8974356 - Flags: review?(ahalberstadt) → review-
Comment on attachment 8974356 [details] Bug 1458812 - Vendor pytest 3.5.1; https://reviewboard.mozilla.org/r/242698/#review248540 > Could you vendor the unzipped wheels instead of the source distributions? This way it'll exclude all of the extra repo and test files, saving a bit of space. > > I normally run: > > $ cd third_party/python > $ pip wheel pytest==3.5.1 # this also downloads dependency wheels > > Then for each package: > > $ rm -rf pytest > $ unzip pytest-3.5.1-py2.py3-none-any.whl -d pytest -x "*.dist-info/*" > $ unzip pytest-3.5.1-py2.py3-none-any.whl -d pytest "*.dist-info/LICENSE.*" > $ mv pytest/*.dist-info/* pytest > $ hg addremove pytest > > We should probably put this in a script somewhere, at least until we implement a proper `mach vendor python` that uses pipenv. I just added the LICENSE step, so for many of these packages, it'll be a new file being added. > > p.s, I don't really care if these are split out into separate commits or not. So feel free to vendor pytest and all the dependencies in the same commit if that's easier for you. Talked to davehunt offline. He mentioned two reasons for using source distributions over wheels: 1) Pipenv needs a setup.py to install from 2) Binary wheels are not always compatible with both python 2 and python 3 Given that, I think it's fine if these extra files are vendored in for now. Eventually I'd like if we could solve this problem in the future `mach vendor python` command (maybe by using setuptools programmatically). But for now it's not worth worrying about.
Comment on attachment 8974365 [details] Bug 1458812 - Allow using pipenv to manage environment for mach python-test command; https://reviewboard.mozilla.org/r/242716/#review248546 ::: python/Pipfile:7 (Diff revision 1) > +url = "https://pypi.org/simple" > +verify_ssl = true > +name = "pypi" > + > +[packages] > +"d5b4a14" = {path = "./mach"} How did you generate these identifiers? Could you put the steps for adding a new package in the commit message? ::: python/mach_commands.py:70 (Diff revision 1) > + @CommandArgument('--pipenv', > + default=False, > + action='store_true', > + help='Use pipenv to manage the virtual environment.') Is there a reason this needs to be an option? I'd prefer to just make it the *only* way. Or will the non-pipenv path be removed in a follow-up bug?
Comment on attachment 8974363 [details] Bug 1458812 - Add mach.mixin to mach distribution; https://reviewboard.mozilla.org/r/242712/#review248548 ::: python/mach/setup.py:23 (Diff revision 1) > long_description=README, > license='MPL 2.0', > author='Gregory Szorc', > author_email='gregory.szorc@gmail.com', > url='https://developer.mozilla.org/en-US/docs/Developer_Guide/mach', > - packages=['mach'], > + packages=['mach', 'mach.mixin'], Why is this change needed? Shouldn't the mixin package already be accessible via `from mach import mixin`? Please also add the motivation for this to the commit message.
Attachment #8974364 - Flags: review?(ahalberstadt) → review+
Attachment #8974366 - Flags: review?(ahalberstadt) → review+
Comment on attachment 8974356 [details] Bug 1458812 - Vendor pytest 3.5.1; https://reviewboard.mozilla.org/r/242698/#review248608 ::: third_party/python/pytest/doc/en/Makefile:1 (Diff revision 1) > +# Makefile for Sphinx documentation As discussed on irc I'd like if we could at least remove the doc and test dirs (misc top-level files are probably fine to keep). I'm going to unflag myself from the other vendor commits for the time being to keep my review queue sane.
Attachment #8974356 - Flags: review-
Comment on attachment 8974365 [details] Bug 1458812 - Allow using pipenv to manage environment for mach python-test command; https://reviewboard.mozilla.org/r/242716/#review248610
Attachment #8974365 - Flags: review?(ahalberstadt) → review+
Comment on attachment 8974365 [details] Bug 1458812 - Allow using pipenv to manage environment for mach python-test command; https://reviewboard.mozilla.org/r/242716/#review248546 > Is there a reason this needs to be an option? I'd prefer to just make it the *only* way. Or will the non-pipenv path be removed in a follow-up bug? Missed the explanation for this in the bug. Please resolve this issue by copying that explanation into the commit message.
Attachment #8974357 - Flags: review?(ahalberstadt)
Attachment #8974358 - Flags: review?(ahalberstadt)
Attachment #8974359 - Flags: review?(ahalberstadt)
Attachment #8974360 - Flags: review?(ahalberstadt)
Attachment #8974361 - Flags: review?(ahalberstadt)
Attachment #8974362 - Flags: review?(ahalberstadt)
Attachment #8974363 - Flags: review?(ahalberstadt)
Depends on: 1464082
There are some issues with running the existing tests using pipenv, which will need to be resolved when adding support for Python 3. For this reason, I don't think it's worthwhile trying to use pipenv for running against Python 2 at this time. Resolving as a duplicate of bug 1388013, which will use pipenv to run against Python 3.
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Version: Version 3 → 3 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: