Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-110722: Add PYTHON_PRESITE to import a module before site.py is run#110769

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ambv merged 10 commits intopython:mainfromambv:gh-110722-presite
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Add Blurb and fix a refleak before anybody notices
  • Loading branch information
@ambv
ambv committedOct 12, 2023
commit1ef282b75e78dce1cc035a24746a49c5c2eaae04
16 changes: 16 additions & 0 deletionsDoc/using/cmdline.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -552,6 +552,10 @@ Miscellaneous options
This option may be useful for users who need to limit CPU resources of a
container system. See also :envvar:`PYTHON_CPU_COUNT`.
If *n* is ``default``, nothing is overridden.
* :samp:`-X presite={package.module}` specifies a module that should be
imported before ``site.py`` is executed. Python needs to be
:ref:`built in debug mode <debug-build>` for this option to exist.
See also :envvar:`PYTHON_PRESITE <PYTHON_PRESITE=package.module>`.

It also allows passing arbitrary values and retrieving them through the
:data:`sys._xoptions` dictionary.
Expand DownExpand Up@@ -602,6 +606,8 @@ Miscellaneous options
.. versionadded:: 3.13
The ``-X cpu_count`` option.

The ``-X presite`` option.


Options you shouldn't use
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand DownExpand Up@@ -1100,3 +1106,13 @@ Debug-mode variables
Need Python configured with the :option:`--with-trace-refs` build option.

.. versionadded:: 3.11

.. envvar:: PYTHON_PRESITE=package.module

If this variable is set to a module, that module will be imported
early in the interpreter lifecycle, before ``site.py`` is executed.

See also the :option:`-X presite <-X>` command-line option,
which takes precedence over this variable.

.. versionadded:: 3.13
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
Add :envvar:`PYTHON_PRESITE=package.module` to import a module early in the
interpreter lifecycle before ``site.py`` is executed. Python needs to be
:ref:`built in debug mode <debug-build>` for this option to exist.
3 changes: 3 additions & 0 deletionsPython/initconfig.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,6 +305,9 @@ static const char usage_envvars[] =
#ifdef Py_STATS
"PYTHONSTATS : turns on statistics gathering\n"
#endif
#ifdef Py_DEBUG
"PYTHON_PRESITE=pkg.mod : import this module before site.py is run\n"
#endif
;

#if defined(MS_WINDOWS)
Expand Down
3 changes: 2 additions & 1 deletionPython/pylifecycle.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1170,10 +1170,11 @@ init_interp_main(PyThreadState *tstate)
else {
PyObject *presite = PyImport_Import(presite_modname);
if (presite == NULL) {
fprintf(stderr, "pre-site import failed; traceback:\n");
fprintf(stderr, "pre-site import failed:\n");
_PyErr_Print(tstate);
}
Py_XDECREF(presite);
Py_DECREF(presite_modname);
}
}
#endif
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp