Repository: tox-dev/tox

Issue:
Foward NUMBER_OF_PROCESSORS environment variable by default
Hi there!

In one project, I have a Python 2.7-only dependency that uses [`multiprocessing.cpu_count()`](https://docs.python.org/2/library/multiprocessing.html#multiprocessing.cpu_count) on Windows.  This has a hidden dependency on the `NUMBER_OF_PROCESSORS` environment variable.  This is quite confusing when porting this type of project into Tox.

**Note**: in Python 3.4+, this is API is superseeded by [`os.cpu_count()`](https://docs.python.org/3/library/os.html#os.cpu_count) which does not depend on this environment variable.

The case is a bit weak (Python up to 3.3 only, plus multiprocessing is not popular on Windows), but I feel like the standard library should work by default inside a Tox test environment.

I'm willing to work on a patch if you would accept such a contribution!

Discussion:

Patch:
diff --git a/CHANGELOG b/CHANGELOG
index befff952..84e10651 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,8 @@ Not released yet
 
 - #474: Start using setuptools_scm for tag based versioning.
 - #506: With `-a`: do not show additional environments header if there are none
+- #517: Forward NUMBER_OF_PROCESSORS by default on Windows to fix
+        `multiprocessor.cpu_count()`.
 - #518: Forward `USERPROFILE` by default on Windows.
 
 2.7.0
diff --git a/tox/config.py b/tox/config.py
index a1b1cbf6..a61fe7ca 100755
--- a/tox/config.py
+++ b/tox/config.py
@@ -489,6 +489,9 @@ def tox_addoption(parser):
             passenv.add("COMSPEC")      # needed for distutils cygwincompiler
             passenv.add("TEMP")
             passenv.add("TMP")
+            # for `multiprocessing.cpu_count()` on Windows
+            # (prior to Python 3.4).
+            passenv.add("NUMBER_OF_PROCESSORS")
             passenv.add("USERPROFILE")  # needed for `os.path.expanduser()`.
         else:
             passenv.add("TMPDIR")


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index 5a87159f..827934ef 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -864,6 +864,7 @@ class TestConfigTestEnv:
             assert "COMSPEC" in envconfig.passenv
             assert "TEMP" in envconfig.passenv
             assert "TMP" in envconfig.passenv
+            assert "NUMBER_OF_PROCESSORS" in envconfig.passenv
             assert "USERPROFILE" in envconfig.passenv
         else:
             assert "TMPDIR" in envconfig.passenv