public class PyConfig
extends java.lang.Object
A configuration object for setting Python initialization parameters.
These options map directly to the options documented at https://docs.python.org/3/c-api/init_config.html#pyconfig
This class was rewritten with the introduction of PEP-587. It contains many deprecated methods that reference the Python c-api available before PEP-587 was implemented and newer replacement methods that reference the current configuration c-api described in PEP-587. Although all methods still work the newer methods should be preferred and the deprecated methods will be removed in the future.
| Constructor and Description |
|---|
PyConfig()
|
| Modifier and Type | Method and Description |
|---|---|
static PyConfig |
isolated()
Create a new PyConfig with the default settings to isolate python from
the rest of the system.
|
static PyConfig |
python()
Create a new PyConfig with the default settings to behave as the regular
Python.
|
PyConfig |
setArgv(java.lang.String... argv)
Set sys.argv for
SharedInterpreters and shared modules used by
SubInterpreters. |
PyConfig |
setDontWriteBytecodeFlag(int dontWriteBytecodeFlag)
Deprecated.
Use
#setWriteBytecode(int) instead. |
PyConfig |
setHashRandomizationFlag(int hashRandomizationFlag)
Deprecated.
Use
setHashSeed(int) and
#setUseHashSeed(int) instead. |
PyConfig |
setHashSeed(int hashSeed)
If
setUseHashSeed(boolean) is false this value is ignored but if
it is true this is a fixed seed for generating the hash() of the types
covered by the hash randomization. |
PyConfig |
setHome(java.lang.String home)
Set the default Python "home" directory, that is, the location of the
standard Python libraries.
|
PyConfig |
setIgnoreEnvironmentFlag(int ignoreEnvironmentFlag)
Deprecated.
Use
#setUseEnvironment(int) instead. |
PyConfig |
setNoSiteFlag(int noSiteFlag)
Deprecated.
Use
#setSiteImport(int) instead. |
PyConfig |
setNoUserSiteDirectory(int noUserSiteDirectory)
Deprecated.
Use
#setUserSiteDirectory(int) instead. |
PyConfig |
setOptimizationLevel(int optimizationLevel)
Set the compilation optimization level:
0: Peephole optimizer, set __debug__ to True.
1: Level 0, remove assertions, set __debug__ to False.
2: Level 1, strip docstrings.
|
PyConfig |
setOptimizeFlag(int optimizeFlag)
Deprecated.
Use
setOptimizationLevel(int) instead. |
PyConfig |
setParseArgv(boolean parseArgv)
If true, parse argv the same way the regular Python parses command line
arguments, and strip Python arguments from argv.
|
PyConfig |
setProgramName(java.lang.String programName)
Set the program name used to initialize executable and in early error
messages during Python initialization.
|
PyConfig |
setPythonHome(java.lang.String pythonHome)
Deprecated.
Use
setHome(String) instead. |
PyConfig |
setSiteImport(boolean siteImport)
Import the site module at startup?
If false, disable the import of the module site and the site-dependent
manipulations of sys.path that it entails.
|
PyConfig |
setUseEnvironment(boolean useEnvironment)
Use environment variables?
If false, ignore the environment variables.
|
PyConfig |
setUseHashSeed(boolean useHashSeed)
If this is set to true the value of
hashSeed is used as a fixed
seed for generating the hash() of the types covered by the hash
randomization. |
PyConfig |
setUserSiteDirectory(boolean userSiteDirectory)
If true, add the user site directory to sys.path.
|
PyConfig |
setVerbose(int verbose)
Verbose mode.
|
PyConfig |
setVerboseFlag(int verboseFlag)
Deprecated.
Use
setVerbose(int) instead. |
PyConfig |
setWriteBytecode(boolean writeBytecode)
If false, Python won't try to write .pyc files on the import of source
modules.
|
java.lang.String |
toString() |
public PyConfig setArgv(java.lang.String... argv)
SharedInterpreters and shared modules used by
SubInterpreters.argv - command line argumentshttps://docs.python.org/3/c-api/init_config.html#c.PyConfig_SetArgvpublic PyConfig setHashSeed(int hashSeed)
setUseHashSeed(boolean) is false this value is ignored but if
it is true this is a fixed seed for generating the hash() of the types
covered by the hash randomization.hashSeed - a fixed seed to use for generating hash() valueshttps://docs.python.org/3/c-api/init_config.html#c.PyConfig.hash_seedpublic PyConfig setUseHashSeed(boolean useHashSeed)
hashSeed is used as a fixed
seed for generating the hash() of the types covered by the hash
randomization.useHashSeed - a boolean to indicate whether a fixed seed should be used.https://docs.python.org/3/c-api/init_config.html#c.PyConfig.use_hash_seedpublic PyConfig setHome(java.lang.String home)
home - the directory to use for Python home.https://docs.python.org/3/c-api/init_config.html#c.PyConfig.homepublic PyConfig setOptimizationLevel(int optimizationLevel)
optimizationLevel - the optimization level to use.https://docs.python.org/3/c-api/init_config.html#c.PyConfig.optimization_levelpublic PyConfig setParseArgv(boolean parseArgv)
parseArgv - a boolean to indicate whether python should parse command line
argumentshttps://docs.python.org/3/c-api/init_config.html#c.PyConfig.parse_argvpublic PyConfig setProgramName(java.lang.String programName)
programName - the name of the executable Python program.https://docs.python.org/3/c-api/init_config.html#c.PyConfig.program_namepublic PyConfig setSiteImport(boolean siteImport)
siteImport - whether to enable import of site module.https://docs.python.org/3/c-api/init_config.html#c.PyConfig.site_importpublic PyConfig setUseEnvironment(boolean useEnvironment)
useEnvironment - https://docs.python.org/3/c-api/init_config.html#c.PyConfig.use_environmentpublic PyConfig setUserSiteDirectory(boolean userSiteDirectory)
userSiteDirectory - whether to add user site directory to the path.https://docs.python.org/3/c-api/init_config.html#c.PyConfig.user_site_directorypublic PyConfig setVerbose(int verbose)
verbose - the level of verbosehttps://docs.python.org/3/c-api/init_config.html#c.PyConfig.verbosepublic PyConfig setWriteBytecode(boolean writeBytecode)
writeBytecode - whether to write bytecode files.https://docs.python.org/3/c-api/init_config.html#c.PyConfig.write_bytecode@Deprecated public PyConfig setNoSiteFlag(int noSiteFlag)
#setSiteImport(int) instead.noSiteFlag - value to pass to Python for Py_NoSiteFlag@Deprecated public PyConfig setNoUserSiteDirectory(int noUserSiteDirectory)
#setUserSiteDirectory(int) instead.noUserSiteDirectory - value to pass to Python for Py_NoUserSiteDirectory@Deprecated public PyConfig setIgnoreEnvironmentFlag(int ignoreEnvironmentFlag)
#setUseEnvironment(int) instead.ignoreEnvironmentFlag - value to pass to Python for Py_IgnoreEnvironmentFlag@Deprecated public PyConfig setVerboseFlag(int verboseFlag)
setVerbose(int) instead.verboseFlag - value to pass to Python for Py_VerboseFlag@Deprecated public PyConfig setOptimizeFlag(int optimizeFlag)
setOptimizationLevel(int) instead.optimizeFlag - value to pass to Python for Py_OptimizeFlag@Deprecated public PyConfig setDontWriteBytecodeFlag(int dontWriteBytecodeFlag)
#setWriteBytecode(int) instead.dontWriteBytecodeFlag - value to pass to Python for Py_DontWriteBytecodeFlag@Deprecated public PyConfig setHashRandomizationFlag(int hashRandomizationFlag)
setHashSeed(int) and
#setUseHashSeed(int) instead.hashRandomizationFlag - value to pass to Python for Py_HashRandomizationFlag@Deprecated public PyConfig setPythonHome(java.lang.String pythonHome)
setHome(String) instead.pythonHome - the home location of the python installationpublic static PyConfig python()
https://docs.python.org/3/c-api/init_config.html#python-configurationpublic static PyConfig isolated()
https://docs.python.org/3/c-api/init_config.html#isolated-configurationpublic java.lang.String toString()
toString in class java.lang.Object