Skip to content

Commit

Permalink
Add --copy-env (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 authored Mar 15, 2021
1 parent 5db3519 commit 61555e8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
7 changes: 6 additions & 1 deletion doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

Version 2.2.0 (TBA)
-------------------

* ``--track-memory`` option now supports macOS by using ``psutil``.
* Added ``--copy-env`` command line option that inherits all environment variables.

Version 2.1.0 (2021-01-14)
--------------------------

Expand Down Expand Up @@ -674,4 +680,3 @@ Version 0.1 (2016-06-02)
------------------------

* First public release

3 changes: 3 additions & 0 deletions doc/runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ Option::
--python-names REF_NAME:CHANGED_NAME
--affinity=CPU_LIST
--inherit-environ=VARS
--copy-env
--no-locale
--track-memory
--tracemalloc

Expand All @@ -119,6 +121,7 @@ Option::
only the following variables are inherited: ``PATH``, ``HOME``, ``TEMP``,
``COMSPEC``, ``SystemRoot`` and locale environment variables. See the
``--no-locale`` below for locale environment variables.
* ``--copy-env``: Inherit all environment variables.
* ``--no-locale``: Don't inherit locale environment variables:

- ``LANG``
Expand Down
3 changes: 2 additions & 1 deletion pyperf/_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def worker_cmd(self, calibrate_loops, calibrate_warmups, wpipe):

def spawn_worker(self, calibrate_loops, calibrate_warmups):
env = create_environ(self.args.inherit_environ,
self.args.locale)
self.args.locale,
self.args.copy_env)

rpipe, wpipe = create_pipe()
with rpipe:
Expand Down
3 changes: 3 additions & 0 deletions pyperf/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def __init__(self, values=None, warmups=None, processes=None,
help='Comma-separated list of environment '
'variables inherited by worker child '
'processes.')
parser.add_argument("--copy-env",
dest="copy_env", action="store_true", default=False,
help="Copy all environment variables")
parser.add_argument("--no-locale",
dest="locale", action="store_false", default=True,
help="Don't copy locale environment variables "
Expand Down
4 changes: 3 additions & 1 deletion pyperf/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ def abs_executable(python):
return os.path.normpath(python)


def create_environ(inherit_environ, locale):
def create_environ(inherit_environ, locale, copy_all):
if copy_all:
return os.environ
env = {}

copy_env = ["PATH", "HOME", "TEMP", "COMSPEC", "SystemRoot", "SystemDrive"]
Expand Down

0 comments on commit 61555e8

Please sign in to comment.