Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-187: Support environment variables PYTHON_GIL / PYTHON_CPU_COUNT #188

Merged
merged 8 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,54 @@ jobs:
- run: tox -e ${{ matrix.tox-job }}
build:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} - ${{ matrix.python }} ${{ matrix.build }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ['3.12']
build: ['']
include:
- os: ubuntu-latest
python: 'pypy3.10'
build: ''
- os: ubuntu-latest
python: 'pypy3.9'
build: ''
- os: ubuntu-latest
python: 'pypy3.8'
build: ''
- os: ubuntu-latest
python: '3.8'
build: ''
- os: ubuntu-latest
python: '3.9'
build: ''
- os: ubuntu-latest
python: '3.10'
build: ''
- os: ubuntu-latest
python: '3.11'
build: ''
- os: ubuntu-latest
python: '3.12'
build: ''
- os: ubuntu-latest
python: '3.13-dev'
build: 'free-threading'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
if: ${{ matrix.build != 'free-threading' }}
with:
python-version: ${{ matrix.python }}
- name: Set up Python ${{ matrix.python }} using deadsnakes
uses: deadsnakes/[email protected]
if: ${{ matrix.build == 'free-threading' }}
with:
python-version: ${{ matrix.python }}
nogil: true
- name: Install Tox and any other packages
run: pip install tox
- name: Run Tox
Expand Down
6 changes: 4 additions & 2 deletions pyperf/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,10 @@ def create_environ(inherit_environ, locale, copy_all):
if copy_all:
return os.environ
env = {}

copy_env = ["PATH", "PYTHONPATH", "HOME", "TEMP", "COMSPEC", "SystemRoot", "SystemDrive"]
copy_env = ["PATH", "HOME", "TEMP", "COMSPEC", "SystemRoot", "SystemDrive"]
# TODO: In the future, maybe we should manage CPython environment variables
# depending on the Python version.
copy_env.extend(["PYTHONPATH", "PYTHON_CPU_COUNT", "PYTHON_GIL"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just put it directly in the list, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well let's separate CPython specific variables :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can separate them with a comment and/or a newline.

Copy link
Member Author

@corona10 corona10 May 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I am not sure why you want to maintain the single list declaration even though this is not a performance-sensitive code

if locale:
copy_env.extend(('LANG', 'LC_ADDRESS', 'LC_ALL', 'LC_COLLATE',
'LC_CTYPE', 'LC_IDENTIFICATION', 'LC_MEASUREMENT',
Expand Down