del env py
This commit is contained in:
@@ -1,247 +0,0 @@
|
|||||||
<#
|
|
||||||
.Synopsis
|
|
||||||
Activate a Python virtual environment for the current PowerShell session.
|
|
||||||
|
|
||||||
.Description
|
|
||||||
Pushes the python executable for a virtual environment to the front of the
|
|
||||||
$Env:PATH environment variable and sets the prompt to signify that you are
|
|
||||||
in a Python virtual environment. Makes use of the command line switches as
|
|
||||||
well as the `pyvenv.cfg` file values present in the virtual environment.
|
|
||||||
|
|
||||||
.Parameter VenvDir
|
|
||||||
Path to the directory that contains the virtual environment to activate. The
|
|
||||||
default value for this is the parent of the directory that the Activate.ps1
|
|
||||||
script is located within.
|
|
||||||
|
|
||||||
.Parameter Prompt
|
|
||||||
The prompt prefix to display when this virtual environment is activated. By
|
|
||||||
default, this prompt is the name of the virtual environment folder (VenvDir)
|
|
||||||
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
|
|
||||||
|
|
||||||
.Example
|
|
||||||
Activate.ps1
|
|
||||||
Activates the Python virtual environment that contains the Activate.ps1 script.
|
|
||||||
|
|
||||||
.Example
|
|
||||||
Activate.ps1 -Verbose
|
|
||||||
Activates the Python virtual environment that contains the Activate.ps1 script,
|
|
||||||
and shows extra information about the activation as it executes.
|
|
||||||
|
|
||||||
.Example
|
|
||||||
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
|
|
||||||
Activates the Python virtual environment located in the specified location.
|
|
||||||
|
|
||||||
.Example
|
|
||||||
Activate.ps1 -Prompt "MyPython"
|
|
||||||
Activates the Python virtual environment that contains the Activate.ps1 script,
|
|
||||||
and prefixes the current prompt with the specified string (surrounded in
|
|
||||||
parentheses) while the virtual environment is active.
|
|
||||||
|
|
||||||
.Notes
|
|
||||||
On Windows, it may be required to enable this Activate.ps1 script by setting the
|
|
||||||
execution policy for the user. You can do this by issuing the following PowerShell
|
|
||||||
command:
|
|
||||||
|
|
||||||
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
||||||
|
|
||||||
For more information on Execution Policies:
|
|
||||||
https://go.microsoft.com/fwlink/?LinkID=135170
|
|
||||||
|
|
||||||
#>
|
|
||||||
Param(
|
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[String]
|
|
||||||
$VenvDir,
|
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[String]
|
|
||||||
$Prompt
|
|
||||||
)
|
|
||||||
|
|
||||||
<# Function declarations --------------------------------------------------- #>
|
|
||||||
|
|
||||||
<#
|
|
||||||
.Synopsis
|
|
||||||
Remove all shell session elements added by the Activate script, including the
|
|
||||||
addition of the virtual environment's Python executable from the beginning of
|
|
||||||
the PATH variable.
|
|
||||||
|
|
||||||
.Parameter NonDestructive
|
|
||||||
If present, do not remove this function from the global namespace for the
|
|
||||||
session.
|
|
||||||
|
|
||||||
#>
|
|
||||||
function global:deactivate ([switch]$NonDestructive) {
|
|
||||||
# Revert to original values
|
|
||||||
|
|
||||||
# The prior prompt:
|
|
||||||
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
|
|
||||||
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
|
|
||||||
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
|
|
||||||
}
|
|
||||||
|
|
||||||
# The prior PYTHONHOME:
|
|
||||||
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
|
|
||||||
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
|
|
||||||
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
|
|
||||||
}
|
|
||||||
|
|
||||||
# The prior PATH:
|
|
||||||
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
|
|
||||||
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
|
|
||||||
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
|
|
||||||
}
|
|
||||||
|
|
||||||
# Just remove the VIRTUAL_ENV altogether:
|
|
||||||
if (Test-Path -Path Env:VIRTUAL_ENV) {
|
|
||||||
Remove-Item -Path env:VIRTUAL_ENV
|
|
||||||
}
|
|
||||||
|
|
||||||
# Just remove VIRTUAL_ENV_PROMPT altogether.
|
|
||||||
if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
|
|
||||||
Remove-Item -Path env:VIRTUAL_ENV_PROMPT
|
|
||||||
}
|
|
||||||
|
|
||||||
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
|
|
||||||
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
|
|
||||||
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
|
|
||||||
}
|
|
||||||
|
|
||||||
# Leave deactivate function in the global namespace if requested:
|
|
||||||
if (-not $NonDestructive) {
|
|
||||||
Remove-Item -Path function:deactivate
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
<#
|
|
||||||
.Description
|
|
||||||
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
|
|
||||||
given folder, and returns them in a map.
|
|
||||||
|
|
||||||
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
|
|
||||||
two strings separated by `=` (with any amount of whitespace surrounding the =)
|
|
||||||
then it is considered a `key = value` line. The left hand string is the key,
|
|
||||||
the right hand is the value.
|
|
||||||
|
|
||||||
If the value starts with a `'` or a `"` then the first and last character is
|
|
||||||
stripped from the value before being captured.
|
|
||||||
|
|
||||||
.Parameter ConfigDir
|
|
||||||
Path to the directory that contains the `pyvenv.cfg` file.
|
|
||||||
#>
|
|
||||||
function Get-PyVenvConfig(
|
|
||||||
[String]
|
|
||||||
$ConfigDir
|
|
||||||
) {
|
|
||||||
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
|
|
||||||
|
|
||||||
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
|
|
||||||
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
|
|
||||||
|
|
||||||
# An empty map will be returned if no config file is found.
|
|
||||||
$pyvenvConfig = @{ }
|
|
||||||
|
|
||||||
if ($pyvenvConfigPath) {
|
|
||||||
|
|
||||||
Write-Verbose "File exists, parse `key = value` lines"
|
|
||||||
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
|
|
||||||
|
|
||||||
$pyvenvConfigContent | ForEach-Object {
|
|
||||||
$keyval = $PSItem -split "\s*=\s*", 2
|
|
||||||
if ($keyval[0] -and $keyval[1]) {
|
|
||||||
$val = $keyval[1]
|
|
||||||
|
|
||||||
# Remove extraneous quotations around a string value.
|
|
||||||
if ("'""".Contains($val.Substring(0, 1))) {
|
|
||||||
$val = $val.Substring(1, $val.Length - 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
$pyvenvConfig[$keyval[0]] = $val
|
|
||||||
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $pyvenvConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
<# Begin Activate script --------------------------------------------------- #>
|
|
||||||
|
|
||||||
# Determine the containing directory of this script
|
|
||||||
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
|
||||||
$VenvExecDir = Get-Item -Path $VenvExecPath
|
|
||||||
|
|
||||||
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
|
|
||||||
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
|
|
||||||
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
|
|
||||||
|
|
||||||
# Set values required in priority: CmdLine, ConfigFile, Default
|
|
||||||
# First, get the location of the virtual environment, it might not be
|
|
||||||
# VenvExecDir if specified on the command line.
|
|
||||||
if ($VenvDir) {
|
|
||||||
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
|
|
||||||
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
|
|
||||||
Write-Verbose "VenvDir=$VenvDir"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Next, read the `pyvenv.cfg` file to determine any required value such
|
|
||||||
# as `prompt`.
|
|
||||||
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
|
|
||||||
|
|
||||||
# Next, set the prompt from the command line, or the config file, or
|
|
||||||
# just use the name of the virtual environment folder.
|
|
||||||
if ($Prompt) {
|
|
||||||
Write-Verbose "Prompt specified as argument, using '$Prompt'"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
|
|
||||||
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
|
|
||||||
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
|
|
||||||
$Prompt = $pyvenvCfg['prompt'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
|
|
||||||
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
|
|
||||||
$Prompt = Split-Path -Path $venvDir -Leaf
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Verbose "Prompt = '$Prompt'"
|
|
||||||
Write-Verbose "VenvDir='$VenvDir'"
|
|
||||||
|
|
||||||
# Deactivate any currently active virtual environment, but leave the
|
|
||||||
# deactivate function in place.
|
|
||||||
deactivate -nondestructive
|
|
||||||
|
|
||||||
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
|
|
||||||
# that there is an activated venv.
|
|
||||||
$env:VIRTUAL_ENV = $VenvDir
|
|
||||||
|
|
||||||
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
|
|
||||||
|
|
||||||
Write-Verbose "Setting prompt to '$Prompt'"
|
|
||||||
|
|
||||||
# Set the prompt to include the env name
|
|
||||||
# Make sure _OLD_VIRTUAL_PROMPT is global
|
|
||||||
function global:_OLD_VIRTUAL_PROMPT { "" }
|
|
||||||
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
|
|
||||||
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
|
|
||||||
|
|
||||||
function global:prompt {
|
|
||||||
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
|
|
||||||
_OLD_VIRTUAL_PROMPT
|
|
||||||
}
|
|
||||||
$env:VIRTUAL_ENV_PROMPT = $Prompt
|
|
||||||
}
|
|
||||||
|
|
||||||
# Clear PYTHONHOME
|
|
||||||
if (Test-Path -Path Env:PYTHONHOME) {
|
|
||||||
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
|
|
||||||
Remove-Item -Path Env:PYTHONHOME
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add the venv to the PATH
|
|
||||||
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
|
|
||||||
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
# This file must be used with "source bin/activate" *from bash*
|
|
||||||
# You cannot run it directly
|
|
||||||
|
|
||||||
deactivate () {
|
|
||||||
# reset old environment variables
|
|
||||||
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
|
|
||||||
PATH="${_OLD_VIRTUAL_PATH:-}"
|
|
||||||
export PATH
|
|
||||||
unset _OLD_VIRTUAL_PATH
|
|
||||||
fi
|
|
||||||
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
|
|
||||||
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
|
|
||||||
export PYTHONHOME
|
|
||||||
unset _OLD_VIRTUAL_PYTHONHOME
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Call hash to forget past commands. Without forgetting
|
|
||||||
# past commands the $PATH changes we made may not be respected
|
|
||||||
hash -r 2> /dev/null
|
|
||||||
|
|
||||||
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
|
||||||
PS1="${_OLD_VIRTUAL_PS1:-}"
|
|
||||||
export PS1
|
|
||||||
unset _OLD_VIRTUAL_PS1
|
|
||||||
fi
|
|
||||||
|
|
||||||
unset VIRTUAL_ENV
|
|
||||||
unset VIRTUAL_ENV_PROMPT
|
|
||||||
if [ ! "${1:-}" = "nondestructive" ] ; then
|
|
||||||
# Self destruct!
|
|
||||||
unset -f deactivate
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# unset irrelevant variables
|
|
||||||
deactivate nondestructive
|
|
||||||
|
|
||||||
# on Windows, a path can contain colons and backslashes and has to be converted:
|
|
||||||
if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
|
|
||||||
# transform D:\path\to\venv to /d/path/to/venv on MSYS
|
|
||||||
# and to /cygdrive/d/path/to/venv on Cygwin
|
|
||||||
export VIRTUAL_ENV=$(cygpath "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv")
|
|
||||||
else
|
|
||||||
# use the path as-is
|
|
||||||
export VIRTUAL_ENV="/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv"
|
|
||||||
fi
|
|
||||||
|
|
||||||
_OLD_VIRTUAL_PATH="$PATH"
|
|
||||||
PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
||||||
export PATH
|
|
||||||
|
|
||||||
# unset PYTHONHOME if set
|
|
||||||
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
|
|
||||||
# could use `if (set -u; : $PYTHONHOME) ;` in bash
|
|
||||||
if [ -n "${PYTHONHOME:-}" ] ; then
|
|
||||||
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
|
|
||||||
unset PYTHONHOME
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
|
|
||||||
_OLD_VIRTUAL_PS1="${PS1:-}"
|
|
||||||
PS1="(.venv) ${PS1:-}"
|
|
||||||
export PS1
|
|
||||||
VIRTUAL_ENV_PROMPT="(.venv) "
|
|
||||||
export VIRTUAL_ENV_PROMPT
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Call hash to forget past commands. Without forgetting
|
|
||||||
# past commands the $PATH changes we made may not be respected
|
|
||||||
hash -r 2> /dev/null
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
# This file must be used with "source bin/activate.csh" *from csh*.
|
|
||||||
# You cannot run it directly.
|
|
||||||
|
|
||||||
# Created by Davide Di Blasi <davidedb@gmail.com>.
|
|
||||||
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
|
|
||||||
|
|
||||||
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
|
|
||||||
|
|
||||||
# Unset irrelevant variables.
|
|
||||||
deactivate nondestructive
|
|
||||||
|
|
||||||
setenv VIRTUAL_ENV "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv"
|
|
||||||
|
|
||||||
set _OLD_VIRTUAL_PATH="$PATH"
|
|
||||||
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
|
|
||||||
|
|
||||||
|
|
||||||
set _OLD_VIRTUAL_PROMPT="$prompt"
|
|
||||||
|
|
||||||
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
|
|
||||||
set prompt = "(.venv) $prompt"
|
|
||||||
setenv VIRTUAL_ENV_PROMPT "(.venv) "
|
|
||||||
endif
|
|
||||||
|
|
||||||
alias pydoc python -m pydoc
|
|
||||||
|
|
||||||
rehash
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
# This file must be used with "source <venv>/bin/activate.fish" *from fish*
|
|
||||||
# (https://fishshell.com/). You cannot run it directly.
|
|
||||||
|
|
||||||
function deactivate -d "Exit virtual environment and return to normal shell environment"
|
|
||||||
# reset old environment variables
|
|
||||||
if test -n "$_OLD_VIRTUAL_PATH"
|
|
||||||
set -gx PATH $_OLD_VIRTUAL_PATH
|
|
||||||
set -e _OLD_VIRTUAL_PATH
|
|
||||||
end
|
|
||||||
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
|
|
||||||
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
|
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME
|
|
||||||
end
|
|
||||||
|
|
||||||
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
|
|
||||||
set -e _OLD_FISH_PROMPT_OVERRIDE
|
|
||||||
# prevents error when using nested fish instances (Issue #93858)
|
|
||||||
if functions -q _old_fish_prompt
|
|
||||||
functions -e fish_prompt
|
|
||||||
functions -c _old_fish_prompt fish_prompt
|
|
||||||
functions -e _old_fish_prompt
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
set -e VIRTUAL_ENV
|
|
||||||
set -e VIRTUAL_ENV_PROMPT
|
|
||||||
if test "$argv[1]" != "nondestructive"
|
|
||||||
# Self-destruct!
|
|
||||||
functions -e deactivate
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Unset irrelevant variables.
|
|
||||||
deactivate nondestructive
|
|
||||||
|
|
||||||
set -gx VIRTUAL_ENV "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv"
|
|
||||||
|
|
||||||
set -gx _OLD_VIRTUAL_PATH $PATH
|
|
||||||
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
|
|
||||||
|
|
||||||
# Unset PYTHONHOME if set.
|
|
||||||
if set -q PYTHONHOME
|
|
||||||
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
|
|
||||||
set -e PYTHONHOME
|
|
||||||
end
|
|
||||||
|
|
||||||
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
|
|
||||||
# fish uses a function instead of an env var to generate the prompt.
|
|
||||||
|
|
||||||
# Save the current fish_prompt function as the function _old_fish_prompt.
|
|
||||||
functions -c fish_prompt _old_fish_prompt
|
|
||||||
|
|
||||||
# With the original prompt function renamed, we can override with our own.
|
|
||||||
function fish_prompt
|
|
||||||
# Save the return status of the last command.
|
|
||||||
set -l old_status $status
|
|
||||||
|
|
||||||
# Output the venv prompt; color taken from the blue of the Python logo.
|
|
||||||
printf "%s%s%s" (set_color 4B8BBE) "(.venv) " (set_color normal)
|
|
||||||
|
|
||||||
# Restore the return status of the previous command.
|
|
||||||
echo "exit $old_status" | .
|
|
||||||
# Output the original/"old" prompt.
|
|
||||||
_old_fish_prompt
|
|
||||||
end
|
|
||||||
|
|
||||||
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
|
|
||||||
set -gx VIRTUAL_ENV_PROMPT "(.venv) "
|
|
||||||
end
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from debugpy.server.cli import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from numpy.f2py.f2py2e import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from fiona.fio.main import main_group
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main_group())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from fontTools.__main__ import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from IPython import start_ipython
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(start_ipython())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from IPython import start_ipython
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(start_ipython())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from jupyter_core.command import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from jupyter_client.kernelapp import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from jupyter_client.kernelspecapp import KernelSpecApp
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(KernelSpecApp.launch_instance())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from jupyter_core.migrate import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from jupyter_client.runapp import RunApp
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(RunApp.launch_instance())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from jupyter_core.troubleshoot import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from charset_normalizer.cli import cli_detect
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(cli_detect())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from numpy._configtool import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from pip._internal.cli.main import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from pip._internal.cli.main import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from pip._internal.cli.main import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from fontTools.merge import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from fontTools.subset import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from pygments.cmdline import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from pyproj.__main__ import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
python3
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
/usr/bin/python3
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
python3
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
'''exec' "/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/California Equity/california_equity_git/.venv/bin/python" "$0" "$@"
|
|
||||||
' '''
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from fontTools.ttx import main
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
|
||||||
sys.exit(main())
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
/* -*- indent-tabs-mode: nil; tab-width: 4; -*- */
|
|
||||||
|
|
||||||
/* Greenlet object interface */
|
|
||||||
|
|
||||||
#ifndef Py_GREENLETOBJECT_H
|
|
||||||
#define Py_GREENLETOBJECT_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <Python.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This is deprecated and undocumented. It does not change. */
|
|
||||||
#define GREENLET_VERSION "1.0.0"
|
|
||||||
|
|
||||||
#ifndef GREENLET_MODULE
|
|
||||||
#define implementation_ptr_t void*
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct _greenlet {
|
|
||||||
PyObject_HEAD
|
|
||||||
PyObject* weakreflist;
|
|
||||||
PyObject* dict;
|
|
||||||
implementation_ptr_t pimpl;
|
|
||||||
} PyGreenlet;
|
|
||||||
|
|
||||||
#define PyGreenlet_Check(op) (op && PyObject_TypeCheck(op, &PyGreenlet_Type))
|
|
||||||
|
|
||||||
|
|
||||||
/* C API functions */
|
|
||||||
|
|
||||||
/* Total number of symbols that are exported */
|
|
||||||
#define PyGreenlet_API_pointers 12
|
|
||||||
|
|
||||||
#define PyGreenlet_Type_NUM 0
|
|
||||||
#define PyExc_GreenletError_NUM 1
|
|
||||||
#define PyExc_GreenletExit_NUM 2
|
|
||||||
|
|
||||||
#define PyGreenlet_New_NUM 3
|
|
||||||
#define PyGreenlet_GetCurrent_NUM 4
|
|
||||||
#define PyGreenlet_Throw_NUM 5
|
|
||||||
#define PyGreenlet_Switch_NUM 6
|
|
||||||
#define PyGreenlet_SetParent_NUM 7
|
|
||||||
|
|
||||||
#define PyGreenlet_MAIN_NUM 8
|
|
||||||
#define PyGreenlet_STARTED_NUM 9
|
|
||||||
#define PyGreenlet_ACTIVE_NUM 10
|
|
||||||
#define PyGreenlet_GET_PARENT_NUM 11
|
|
||||||
|
|
||||||
#ifndef GREENLET_MODULE
|
|
||||||
/* This section is used by modules that uses the greenlet C API */
|
|
||||||
static void** _PyGreenlet_API = NULL;
|
|
||||||
|
|
||||||
# define PyGreenlet_Type \
|
|
||||||
(*(PyTypeObject*)_PyGreenlet_API[PyGreenlet_Type_NUM])
|
|
||||||
|
|
||||||
# define PyExc_GreenletError \
|
|
||||||
((PyObject*)_PyGreenlet_API[PyExc_GreenletError_NUM])
|
|
||||||
|
|
||||||
# define PyExc_GreenletExit \
|
|
||||||
((PyObject*)_PyGreenlet_API[PyExc_GreenletExit_NUM])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PyGreenlet_New(PyObject *args)
|
|
||||||
*
|
|
||||||
* greenlet.greenlet(run, parent=None)
|
|
||||||
*/
|
|
||||||
# define PyGreenlet_New \
|
|
||||||
(*(PyGreenlet * (*)(PyObject * run, PyGreenlet * parent)) \
|
|
||||||
_PyGreenlet_API[PyGreenlet_New_NUM])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PyGreenlet_GetCurrent(void)
|
|
||||||
*
|
|
||||||
* greenlet.getcurrent()
|
|
||||||
*/
|
|
||||||
# define PyGreenlet_GetCurrent \
|
|
||||||
(*(PyGreenlet * (*)(void)) _PyGreenlet_API[PyGreenlet_GetCurrent_NUM])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PyGreenlet_Throw(
|
|
||||||
* PyGreenlet *greenlet,
|
|
||||||
* PyObject *typ,
|
|
||||||
* PyObject *val,
|
|
||||||
* PyObject *tb)
|
|
||||||
*
|
|
||||||
* g.throw(...)
|
|
||||||
*/
|
|
||||||
# define PyGreenlet_Throw \
|
|
||||||
(*(PyObject * (*)(PyGreenlet * self, \
|
|
||||||
PyObject * typ, \
|
|
||||||
PyObject * val, \
|
|
||||||
PyObject * tb)) \
|
|
||||||
_PyGreenlet_API[PyGreenlet_Throw_NUM])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PyGreenlet_Switch(PyGreenlet *greenlet, PyObject *args)
|
|
||||||
*
|
|
||||||
* g.switch(*args, **kwargs)
|
|
||||||
*/
|
|
||||||
# define PyGreenlet_Switch \
|
|
||||||
(*(PyObject * \
|
|
||||||
(*)(PyGreenlet * greenlet, PyObject * args, PyObject * kwargs)) \
|
|
||||||
_PyGreenlet_API[PyGreenlet_Switch_NUM])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PyGreenlet_SetParent(PyObject *greenlet, PyObject *new_parent)
|
|
||||||
*
|
|
||||||
* g.parent = new_parent
|
|
||||||
*/
|
|
||||||
# define PyGreenlet_SetParent \
|
|
||||||
(*(int (*)(PyGreenlet * greenlet, PyGreenlet * nparent)) \
|
|
||||||
_PyGreenlet_API[PyGreenlet_SetParent_NUM])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PyGreenlet_GetParent(PyObject* greenlet)
|
|
||||||
*
|
|
||||||
* return greenlet.parent;
|
|
||||||
*
|
|
||||||
* This could return NULL even if there is no exception active.
|
|
||||||
* If it does not return NULL, you are responsible for decrementing the
|
|
||||||
* reference count.
|
|
||||||
*/
|
|
||||||
# define PyGreenlet_GetParent \
|
|
||||||
(*(PyGreenlet* (*)(PyGreenlet*)) \
|
|
||||||
_PyGreenlet_API[PyGreenlet_GET_PARENT_NUM])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* deprecated, undocumented alias.
|
|
||||||
*/
|
|
||||||
# define PyGreenlet_GET_PARENT PyGreenlet_GetParent
|
|
||||||
|
|
||||||
# define PyGreenlet_MAIN \
|
|
||||||
(*(int (*)(PyGreenlet*)) \
|
|
||||||
_PyGreenlet_API[PyGreenlet_MAIN_NUM])
|
|
||||||
|
|
||||||
# define PyGreenlet_STARTED \
|
|
||||||
(*(int (*)(PyGreenlet*)) \
|
|
||||||
_PyGreenlet_API[PyGreenlet_STARTED_NUM])
|
|
||||||
|
|
||||||
# define PyGreenlet_ACTIVE \
|
|
||||||
(*(int (*)(PyGreenlet*)) \
|
|
||||||
_PyGreenlet_API[PyGreenlet_ACTIVE_NUM])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Macro that imports greenlet and initializes C API */
|
|
||||||
/* NOTE: This has actually moved to ``greenlet._greenlet._C_API``, but we
|
|
||||||
keep the older definition to be sure older code that might have a copy of
|
|
||||||
the header still works. */
|
|
||||||
# define PyGreenlet_Import() \
|
|
||||||
{ \
|
|
||||||
_PyGreenlet_API = (void**)PyCapsule_Import("greenlet._C_API", 0); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* GREENLET_MODULE */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif /* !Py_GREENLETOBJECT_H */
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
Copyright (c) 2013 Eric Lemoine
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
pip
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
Metadata-Version: 2.1
|
|
||||||
Name: GeoAlchemy2
|
|
||||||
Version: 0.15.2
|
|
||||||
Summary: Using SQLAlchemy with Spatial Databases
|
|
||||||
Home-page: https://geoalchemy-2.readthedocs.io/en/stable/
|
|
||||||
Author: Eric Lemoine
|
|
||||||
Author-email: eric.lemoine@gmail.com
|
|
||||||
License: MIT
|
|
||||||
Project-URL: Tracker, https://github.com/geoalchemy/geoalchemy2/issues
|
|
||||||
Project-URL: Source, https://github.com/geoalchemy/geoalchemy2
|
|
||||||
Keywords: geo,gis,sqlalchemy,orm
|
|
||||||
Classifier: Development Status :: 4 - Beta
|
|
||||||
Classifier: Environment :: Plugins
|
|
||||||
Classifier: Operating System :: OS Independent
|
|
||||||
Classifier: Programming Language :: Python
|
|
||||||
Classifier: Programming Language :: Python :: 3.7
|
|
||||||
Classifier: Programming Language :: Python :: 3.8
|
|
||||||
Classifier: Programming Language :: Python :: 3.9
|
|
||||||
Classifier: Programming Language :: Python :: 3.10
|
|
||||||
Classifier: Programming Language :: Python :: 3.11
|
|
||||||
Classifier: Programming Language :: Python :: 3.12
|
|
||||||
Classifier: Intended Audience :: Information Technology
|
|
||||||
Classifier: License :: OSI Approved :: MIT License
|
|
||||||
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
||||||
Requires-Python: >=3.7
|
|
||||||
License-File: COPYING.rst
|
|
||||||
Requires-Dist: SQLAlchemy >=1.4
|
|
||||||
Requires-Dist: packaging
|
|
||||||
Provides-Extra: shapely
|
|
||||||
Requires-Dist: Shapely >=1.7 ; extra == 'shapely'
|
|
||||||
|
|
||||||
============
|
|
||||||
GeoAlchemy 2
|
|
||||||
============
|
|
||||||
|
|
||||||
.. image:: https://github.com/geoalchemy/geoalchemy2/actions/workflows/test_and_publish.yml/badge.svg?branch=master
|
|
||||||
:target: https://github.com/geoalchemy/geoalchemy2/actions
|
|
||||||
|
|
||||||
.. image:: https://coveralls.io/repos/geoalchemy/geoalchemy2/badge.png?branch=master
|
|
||||||
:target: https://coveralls.io/r/geoalchemy/geoalchemy2
|
|
||||||
|
|
||||||
.. image:: https://readthedocs.org/projects/geoalchemy-2/badge/?version=latest
|
|
||||||
:target: https://geoalchemy-2.readthedocs.io/en/latest/?badge=latest
|
|
||||||
:alt: Documentation Status
|
|
||||||
|
|
||||||
.. image:: https://zenodo.org/badge/5638538.svg
|
|
||||||
:target: https://zenodo.org/doi/10.5281/zenodo.10808783
|
|
||||||
|
|
||||||
GeoAlchemy 2 is a Python toolkit for working with spatial databases. It is
|
|
||||||
based on the gorgeous `SQLAlchemy <http://www.sqlalchemy.org/>`_.
|
|
||||||
|
|
||||||
Documentation is on Read the Docs: https://geoalchemy-2.readthedocs.io/en/stable.
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
GeoAlchemy2-0.15.2.dist-info/COPYING.rst,sha256=-bQKftq9uMOROzF7oN65kYBBIJKxTmBuDoftp27IC3I,1056
|
|
||||||
GeoAlchemy2-0.15.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
|
||||||
GeoAlchemy2-0.15.2.dist-info/METADATA,sha256=7ti009u_zE-vAPIyGyfVcC-oZzloZ-TYOKOV7ZahmKo,2087
|
|
||||||
GeoAlchemy2-0.15.2.dist-info/RECORD,,
|
|
||||||
GeoAlchemy2-0.15.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
||||||
GeoAlchemy2-0.15.2.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
|
|
||||||
GeoAlchemy2-0.15.2.dist-info/top_level.txt,sha256=3kGUTcfBeXd61zFpof6-qiuw1peNF_HuZabgHQgrdis,12
|
|
||||||
geoalchemy2/__init__.py,sha256=Wb5f11AM_hYn56yrxOAOjCT3z76TCtseqjFo2hKsob4,1971
|
|
||||||
geoalchemy2/__pycache__/__init__.cpython-312.pyc,,
|
|
||||||
geoalchemy2/__pycache__/_functions.cpython-312.pyc,,
|
|
||||||
geoalchemy2/__pycache__/_functions_helpers.cpython-312.pyc,,
|
|
||||||
geoalchemy2/__pycache__/alembic_helpers.cpython-312.pyc,,
|
|
||||||
geoalchemy2/__pycache__/comparator.cpython-312.pyc,,
|
|
||||||
geoalchemy2/__pycache__/elements.cpython-312.pyc,,
|
|
||||||
geoalchemy2/__pycache__/exc.cpython-312.pyc,,
|
|
||||||
geoalchemy2/__pycache__/functions.cpython-312.pyc,,
|
|
||||||
geoalchemy2/__pycache__/shape.cpython-312.pyc,,
|
|
||||||
geoalchemy2/__pycache__/utils.cpython-312.pyc,,
|
|
||||||
geoalchemy2/_functions.py,sha256=e8v584Fx_fmh8XnJvkuYEXrcyPDiWV95Mu2yw6L-LHY,62863
|
|
||||||
geoalchemy2/_functions_helpers.py,sha256=hVM9DDTgf-oM27EZu6ycW1y2ENnSxUJixdINetWsu0E,2651
|
|
||||||
geoalchemy2/admin/__init__.py,sha256=s8L5C9pYC5dTxhIp9j-JzWeg9kEJevXUW8Pq4_L4aZ8,3984
|
|
||||||
geoalchemy2/admin/__pycache__/__init__.cpython-312.pyc,,
|
|
||||||
geoalchemy2/admin/dialects/__init__.py,sha256=XodzuBbWKkkSQzM5EL3I33azuE-y_go0nVOlmIyJ13g,367
|
|
||||||
geoalchemy2/admin/dialects/__pycache__/__init__.cpython-312.pyc,,
|
|
||||||
geoalchemy2/admin/dialects/__pycache__/common.cpython-312.pyc,,
|
|
||||||
geoalchemy2/admin/dialects/__pycache__/geopackage.cpython-312.pyc,,
|
|
||||||
geoalchemy2/admin/dialects/__pycache__/mysql.cpython-312.pyc,,
|
|
||||||
geoalchemy2/admin/dialects/__pycache__/postgresql.cpython-312.pyc,,
|
|
||||||
geoalchemy2/admin/dialects/__pycache__/sqlite.cpython-312.pyc,,
|
|
||||||
geoalchemy2/admin/dialects/common.py,sha256=8OkGa7T2Gxz2vDVnC9nva8Ma0YqBwGxHWfBJoZF1cNQ,2936
|
|
||||||
geoalchemy2/admin/dialects/geopackage.py,sha256=UaJignKtlo13oHxq92yescVJtXFEXkm4fy5WzR6sLT8,13469
|
|
||||||
geoalchemy2/admin/dialects/mysql.py,sha256=z2gmkTGav60_myDCFxO1yeezDKBcNcMxFvcpH-OqVKw,6867
|
|
||||||
geoalchemy2/admin/dialects/postgresql.py,sha256=VwB_h3TC8M5aQ6aKE3UYgxHfbEKav3eIHJeLx534Zzg,6191
|
|
||||||
geoalchemy2/admin/dialects/sqlite.py,sha256=UYQuNDDy-1-lsvYlqyKy01UtHgLF4iEN42fE5D-9QQk,13597
|
|
||||||
geoalchemy2/alembic_helpers.py,sha256=WYjKiVVyHtlB4DI22z-G0-x8NnG8othAINUwmxBCMcs,27885
|
|
||||||
geoalchemy2/comparator.py,sha256=WUDXn10doDlJVnYiWbVIAhhBu7N5AO9BI8sNf2mhpA4,8100
|
|
||||||
geoalchemy2/elements.py,sha256=5yd_7dUQGbrLvgYvo6A2YYAFwTvP4_BskIdBCB0DrlM,13002
|
|
||||||
geoalchemy2/exc.py,sha256=Nn9bRKB_35skWDMkEf4_Y2GL6gvguPVycPZcbOfa69g,226
|
|
||||||
geoalchemy2/functions.py,sha256=0he8hy_SAWpXAFPdfg32NMW5G0FaZP7yVl0jn0MRLBQ,10320
|
|
||||||
geoalchemy2/functions.pyi,sha256=rKCKdDSVTgeUQHItkOKqJSEuyKmVJ30bpjLpCPwMI5g,108636
|
|
||||||
geoalchemy2/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
||||||
geoalchemy2/shape.py,sha256=TZJIhCN4p4ZVwZMXidxYxTMeeyReAyoFzyYwspJRqSA,2792
|
|
||||||
geoalchemy2/types/__init__.py,sha256=dD2-E8rr1nXr_d4CqyiEvRjO1H-dDRQnzr5B1g3_an8,14186
|
|
||||||
geoalchemy2/types/__pycache__/__init__.cpython-312.pyc,,
|
|
||||||
geoalchemy2/types/dialects/__init__.py,sha256=sw__RqGAFVrUPGrICjsva9SPoYLBNfyAkBHmsJkT7k0,359
|
|
||||||
geoalchemy2/types/dialects/__pycache__/__init__.cpython-312.pyc,,
|
|
||||||
geoalchemy2/types/dialects/__pycache__/common.cpython-312.pyc,,
|
|
||||||
geoalchemy2/types/dialects/__pycache__/geopackage.cpython-312.pyc,,
|
|
||||||
geoalchemy2/types/dialects/__pycache__/mysql.cpython-312.pyc,,
|
|
||||||
geoalchemy2/types/dialects/__pycache__/postgresql.cpython-312.pyc,,
|
|
||||||
geoalchemy2/types/dialects/__pycache__/sqlite.cpython-312.pyc,,
|
|
||||||
geoalchemy2/types/dialects/common.py,sha256=gxKaRQhIODJhu_yBurlvFNAqGh3LfPNu_DcObEG1wlU,138
|
|
||||||
geoalchemy2/types/dialects/geopackage.py,sha256=nRmN_PnF-CWMEHkWhKVdsybnw3SvXZIBXAHIHXJLTqw,147
|
|
||||||
geoalchemy2/types/dialects/mysql.py,sha256=zMNi1920v0XlVaCJWSwtq0b0P5YQRn8y3X_rBxC5KEw,1790
|
|
||||||
geoalchemy2/types/dialects/postgresql.py,sha256=7NBKEbDJXMwX8Sgs6o_N2bAUHgjUcjbrdmYOA7sDiRw,1117
|
|
||||||
geoalchemy2/types/dialects/sqlite.py,sha256=B-yLzaQcqL_4dXoOPX9D9IXw2ZQlq-Tibv_kqUIBeb4,2104
|
|
||||||
geoalchemy2/utils.py,sha256=OYWYnT64tjp4DWhPdq3KIxHbVti932xPMtGGxajtu-I,488
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
Wheel-Version: 1.0
|
|
||||||
Generator: setuptools (70.3.0)
|
|
||||||
Root-Is-Purelib: true
|
|
||||||
Tag: py3-none-any
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
geoalchemy2
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
# PYTHON_ARGCOMPLETE_OK
|
|
||||||
"""
|
|
||||||
IPython: tools for interactive and parallel computing in Python.
|
|
||||||
|
|
||||||
https://ipython.org
|
|
||||||
"""
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Copyright (c) 2008-2011, IPython Development Team.
|
|
||||||
# Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
|
|
||||||
# Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
|
|
||||||
# Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
|
|
||||||
#
|
|
||||||
# Distributed under the terms of the Modified BSD License.
|
|
||||||
#
|
|
||||||
# The full license is in the file COPYING.txt, distributed with this software.
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Imports
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Setup everything
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Don't forget to also update setup.py when this changes!
|
|
||||||
if sys.version_info < (3, 10):
|
|
||||||
raise ImportError(
|
|
||||||
"""
|
|
||||||
IPython 8.19+ supports Python 3.10 and above, following SPEC0.
|
|
||||||
IPython 8.13+ supports Python 3.9 and above, following NEP 29.
|
|
||||||
IPython 8.0-8.12 supports Python 3.8 and above, following NEP 29.
|
|
||||||
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
|
|
||||||
Python 3.3 and 3.4 were supported up to IPython 6.x.
|
|
||||||
Python 3.5 was supported with IPython 7.0 to 7.9.
|
|
||||||
Python 3.6 was supported with IPython up to 7.16.
|
|
||||||
Python 3.7 was still supported with the 7.x branch.
|
|
||||||
|
|
||||||
See IPython `README.rst` file for more information:
|
|
||||||
|
|
||||||
https://github.com/ipython/ipython/blob/main/README.rst
|
|
||||||
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Setup the top level names
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
from .core.getipython import get_ipython
|
|
||||||
from .core import release
|
|
||||||
from .core.application import Application
|
|
||||||
from .terminal.embed import embed
|
|
||||||
|
|
||||||
from .core.interactiveshell import InteractiveShell
|
|
||||||
from .utils.sysinfo import sys_info
|
|
||||||
from .utils.frame import extract_module_locals
|
|
||||||
|
|
||||||
__all__ = ["start_ipython", "embed", "start_kernel", "embed_kernel"]
|
|
||||||
|
|
||||||
# Release data
|
|
||||||
__author__ = '%s <%s>' % (release.author, release.author_email)
|
|
||||||
__license__ = release.license
|
|
||||||
__version__ = release.version
|
|
||||||
version_info = release.version_info
|
|
||||||
# list of CVEs that should have been patched in this release.
|
|
||||||
# this is informational and should not be relied upon.
|
|
||||||
__patched_cves__ = {"CVE-2022-21699", "CVE-2023-24816"}
|
|
||||||
|
|
||||||
|
|
||||||
def embed_kernel(module=None, local_ns=None, **kwargs):
|
|
||||||
"""Embed and start an IPython kernel in a given scope.
|
|
||||||
|
|
||||||
If you don't want the kernel to initialize the namespace
|
|
||||||
from the scope of the surrounding function,
|
|
||||||
and/or you want to load full IPython configuration,
|
|
||||||
you probably want `IPython.start_kernel()` instead.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
module : types.ModuleType, optional
|
|
||||||
The module to load into IPython globals (default: caller)
|
|
||||||
local_ns : dict, optional
|
|
||||||
The namespace to load into IPython user namespace (default: caller)
|
|
||||||
**kwargs : various, optional
|
|
||||||
Further keyword args are relayed to the IPKernelApp constructor,
|
|
||||||
such as `config`, a traitlets :class:`Config` object (see :ref:`configure_start_ipython`),
|
|
||||||
allowing configuration of the kernel (see :ref:`kernel_options`). Will only have an effect
|
|
||||||
on the first embed_kernel call for a given process.
|
|
||||||
"""
|
|
||||||
|
|
||||||
(caller_module, caller_locals) = extract_module_locals(1)
|
|
||||||
if module is None:
|
|
||||||
module = caller_module
|
|
||||||
if local_ns is None:
|
|
||||||
local_ns = caller_locals
|
|
||||||
|
|
||||||
# Only import .zmq when we really need it
|
|
||||||
from ipykernel.embed import embed_kernel as real_embed_kernel
|
|
||||||
real_embed_kernel(module=module, local_ns=local_ns, **kwargs)
|
|
||||||
|
|
||||||
def start_ipython(argv=None, **kwargs):
|
|
||||||
"""Launch a normal IPython instance (as opposed to embedded)
|
|
||||||
|
|
||||||
`IPython.embed()` puts a shell in a particular calling scope,
|
|
||||||
such as a function or method for debugging purposes,
|
|
||||||
which is often not desirable.
|
|
||||||
|
|
||||||
`start_ipython()` does full, regular IPython initialization,
|
|
||||||
including loading startup files, configuration, etc.
|
|
||||||
much of which is skipped by `embed()`.
|
|
||||||
|
|
||||||
This is a public API method, and will survive implementation changes.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
argv : list or None, optional
|
|
||||||
If unspecified or None, IPython will parse command-line options from sys.argv.
|
|
||||||
To prevent any command-line parsing, pass an empty list: `argv=[]`.
|
|
||||||
user_ns : dict, optional
|
|
||||||
specify this dictionary to initialize the IPython user namespace with particular values.
|
|
||||||
**kwargs : various, optional
|
|
||||||
Any other kwargs will be passed to the Application constructor,
|
|
||||||
such as `config`, a traitlets :class:`Config` object (see :ref:`configure_start_ipython`),
|
|
||||||
allowing configuration of the instance (see :ref:`terminal_options`).
|
|
||||||
"""
|
|
||||||
from IPython.terminal.ipapp import launch_new_instance
|
|
||||||
return launch_new_instance(argv=argv, **kwargs)
|
|
||||||
|
|
||||||
def start_kernel(argv=None, **kwargs):
|
|
||||||
"""Launch a normal IPython kernel instance (as opposed to embedded)
|
|
||||||
|
|
||||||
`IPython.embed_kernel()` puts a shell in a particular calling scope,
|
|
||||||
such as a function or method for debugging purposes,
|
|
||||||
which is often not desirable.
|
|
||||||
|
|
||||||
`start_kernel()` does full, regular IPython initialization,
|
|
||||||
including loading startup files, configuration, etc.
|
|
||||||
much of which is skipped by `embed_kernel()`.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
argv : list or None, optional
|
|
||||||
If unspecified or None, IPython will parse command-line options from sys.argv.
|
|
||||||
To prevent any command-line parsing, pass an empty list: `argv=[]`.
|
|
||||||
user_ns : dict, optional
|
|
||||||
specify this dictionary to initialize the IPython user namespace with particular values.
|
|
||||||
**kwargs : various, optional
|
|
||||||
Any other kwargs will be passed to the Application constructor,
|
|
||||||
such as `config`, a traitlets :class:`Config` object (see :ref:`configure_start_ipython`),
|
|
||||||
allowing configuration of the kernel (see :ref:`kernel_options`).
|
|
||||||
"""
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
warnings.warn(
|
|
||||||
"start_kernel is deprecated since IPython 8.0, use from `ipykernel.kernelapp.launch_new_instance`",
|
|
||||||
DeprecationWarning,
|
|
||||||
stacklevel=2,
|
|
||||||
)
|
|
||||||
from ipykernel.kernelapp import launch_new_instance
|
|
||||||
return launch_new_instance(argv=argv, **kwargs)
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# PYTHON_ARGCOMPLETE_OK
|
|
||||||
# encoding: utf-8
|
|
||||||
"""Terminal-based IPython entry point.
|
|
||||||
"""
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Copyright (c) 2012, IPython Development Team.
|
|
||||||
#
|
|
||||||
# Distributed under the terms of the Modified BSD License.
|
|
||||||
#
|
|
||||||
# The full license is in the file COPYING.txt, distributed with this software.
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
from IPython import start_ipython
|
|
||||||
|
|
||||||
start_ipython()
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,87 +0,0 @@
|
|||||||
import builtins
|
|
||||||
import inspect
|
|
||||||
import os
|
|
||||||
import pathlib
|
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
import types
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
# Must register before it gets imported
|
|
||||||
pytest.register_assert_rewrite("IPython.testing.tools")
|
|
||||||
|
|
||||||
from .testing import tools
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_collection_modifyitems(items):
|
|
||||||
"""This function is automatically run by pytest passing all collected test
|
|
||||||
functions.
|
|
||||||
|
|
||||||
We use it to add asyncio marker to all async tests and assert we don't use
|
|
||||||
test functions that are async generators which wouldn't make sense.
|
|
||||||
"""
|
|
||||||
for item in items:
|
|
||||||
if inspect.iscoroutinefunction(item.obj):
|
|
||||||
item.add_marker("asyncio")
|
|
||||||
assert not inspect.isasyncgenfunction(item.obj)
|
|
||||||
|
|
||||||
|
|
||||||
def get_ipython():
|
|
||||||
from .terminal.interactiveshell import TerminalInteractiveShell
|
|
||||||
if TerminalInteractiveShell._instance:
|
|
||||||
return TerminalInteractiveShell.instance()
|
|
||||||
|
|
||||||
config = tools.default_config()
|
|
||||||
config.TerminalInteractiveShell.simple_prompt = True
|
|
||||||
|
|
||||||
# Create and initialize our test-friendly IPython instance.
|
|
||||||
shell = TerminalInteractiveShell.instance(config=config)
|
|
||||||
return shell
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session', autouse=True)
|
|
||||||
def work_path():
|
|
||||||
path = pathlib.Path("./tmp-ipython-pytest-profiledir")
|
|
||||||
os.environ["IPYTHONDIR"] = str(path.absolute())
|
|
||||||
if path.exists():
|
|
||||||
raise ValueError('IPython dir temporary path already exists ! Did previous test run exit successfully ?')
|
|
||||||
path.mkdir()
|
|
||||||
yield
|
|
||||||
shutil.rmtree(str(path.resolve()))
|
|
||||||
|
|
||||||
|
|
||||||
def nopage(strng, start=0, screen_lines=0, pager_cmd=None):
|
|
||||||
if isinstance(strng, dict):
|
|
||||||
strng = strng.get("text/plain", "")
|
|
||||||
print(strng)
|
|
||||||
|
|
||||||
|
|
||||||
def xsys(self, cmd):
|
|
||||||
"""Replace the default system call with a capturing one for doctest.
|
|
||||||
"""
|
|
||||||
# We use getoutput, but we need to strip it because pexpect captures
|
|
||||||
# the trailing newline differently from commands.getoutput
|
|
||||||
print(self.getoutput(cmd, split=False, depth=1).rstrip(), end="", file=sys.stdout)
|
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
|
|
||||||
# for things to work correctly we would need this as a session fixture;
|
|
||||||
# unfortunately this will fail on some test that get executed as _collection_
|
|
||||||
# time (before the fixture run), in particular parametrized test that contain
|
|
||||||
# yields. so for now execute at import time.
|
|
||||||
#@pytest.fixture(autouse=True, scope='session')
|
|
||||||
def inject():
|
|
||||||
|
|
||||||
builtins.get_ipython = get_ipython
|
|
||||||
builtins._ip = get_ipython()
|
|
||||||
builtins.ip = get_ipython()
|
|
||||||
builtins.ip.system = types.MethodType(xsys, ip)
|
|
||||||
builtins.ip.builtin_trap.activate()
|
|
||||||
from .core import page
|
|
||||||
|
|
||||||
page.pager_page = nopage
|
|
||||||
# yield
|
|
||||||
|
|
||||||
|
|
||||||
inject()
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
"""
|
|
||||||
Shim to maintain backwards compatibility with old IPython.consoleapp imports.
|
|
||||||
"""
|
|
||||||
# Copyright (c) IPython Development Team.
|
|
||||||
# Distributed under the terms of the Modified BSD License.
|
|
||||||
|
|
||||||
from warnings import warn
|
|
||||||
|
|
||||||
warn("The `IPython.consoleapp` package has been deprecated since IPython 4.0."
|
|
||||||
"You should import from jupyter_client.consoleapp instead.", stacklevel=2)
|
|
||||||
|
|
||||||
from jupyter_client.consoleapp import *
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,267 +0,0 @@
|
|||||||
# encoding: utf-8
|
|
||||||
"""
|
|
||||||
System command aliases.
|
|
||||||
|
|
||||||
Authors:
|
|
||||||
|
|
||||||
* Fernando Perez
|
|
||||||
* Brian Granger
|
|
||||||
"""
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Copyright (C) 2008-2011 The IPython Development Team
|
|
||||||
#
|
|
||||||
# Distributed under the terms of the BSD License.
|
|
||||||
#
|
|
||||||
# The full license is in the file COPYING.txt, distributed with this software.
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Imports
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from traitlets.config.configurable import Configurable
|
|
||||||
from .error import UsageError
|
|
||||||
|
|
||||||
from traitlets import List, Instance
|
|
||||||
from logging import error
|
|
||||||
|
|
||||||
import typing as t
|
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Utilities
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# This is used as the pattern for calls to split_user_input.
|
|
||||||
shell_line_split = re.compile(r'^(\s*)()(\S+)(.*$)')
|
|
||||||
|
|
||||||
def default_aliases() -> t.List[t.Tuple[str, str]]:
|
|
||||||
"""Return list of shell aliases to auto-define.
|
|
||||||
"""
|
|
||||||
# Note: the aliases defined here should be safe to use on a kernel
|
|
||||||
# regardless of what frontend it is attached to. Frontends that use a
|
|
||||||
# kernel in-process can define additional aliases that will only work in
|
|
||||||
# their case. For example, things like 'less' or 'clear' that manipulate
|
|
||||||
# the terminal should NOT be declared here, as they will only work if the
|
|
||||||
# kernel is running inside a true terminal, and not over the network.
|
|
||||||
|
|
||||||
if os.name == 'posix':
|
|
||||||
default_aliases = [('mkdir', 'mkdir'), ('rmdir', 'rmdir'),
|
|
||||||
('mv', 'mv'), ('rm', 'rm'), ('cp', 'cp'),
|
|
||||||
('cat', 'cat'),
|
|
||||||
]
|
|
||||||
# Useful set of ls aliases. The GNU and BSD options are a little
|
|
||||||
# different, so we make aliases that provide as similar as possible
|
|
||||||
# behavior in ipython, by passing the right flags for each platform
|
|
||||||
if sys.platform.startswith('linux'):
|
|
||||||
ls_aliases = [('ls', 'ls -F --color'),
|
|
||||||
# long ls
|
|
||||||
('ll', 'ls -F -o --color'),
|
|
||||||
# ls normal files only
|
|
||||||
('lf', 'ls -F -o --color %l | grep ^-'),
|
|
||||||
# ls symbolic links
|
|
||||||
('lk', 'ls -F -o --color %l | grep ^l'),
|
|
||||||
# directories or links to directories,
|
|
||||||
('ldir', 'ls -F -o --color %l | grep /$'),
|
|
||||||
# things which are executable
|
|
||||||
('lx', 'ls -F -o --color %l | grep ^-..x'),
|
|
||||||
]
|
|
||||||
elif sys.platform.startswith('openbsd') or sys.platform.startswith('netbsd'):
|
|
||||||
# OpenBSD, NetBSD. The ls implementation on these platforms do not support
|
|
||||||
# the -G switch and lack the ability to use colorized output.
|
|
||||||
ls_aliases = [('ls', 'ls -F'),
|
|
||||||
# long ls
|
|
||||||
('ll', 'ls -F -l'),
|
|
||||||
# ls normal files only
|
|
||||||
('lf', 'ls -F -l %l | grep ^-'),
|
|
||||||
# ls symbolic links
|
|
||||||
('lk', 'ls -F -l %l | grep ^l'),
|
|
||||||
# directories or links to directories,
|
|
||||||
('ldir', 'ls -F -l %l | grep /$'),
|
|
||||||
# things which are executable
|
|
||||||
('lx', 'ls -F -l %l | grep ^-..x'),
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
# BSD, OSX, etc.
|
|
||||||
ls_aliases = [('ls', 'ls -F -G'),
|
|
||||||
# long ls
|
|
||||||
('ll', 'ls -F -l -G'),
|
|
||||||
# ls normal files only
|
|
||||||
('lf', 'ls -F -l -G %l | grep ^-'),
|
|
||||||
# ls symbolic links
|
|
||||||
('lk', 'ls -F -l -G %l | grep ^l'),
|
|
||||||
# directories or links to directories,
|
|
||||||
('ldir', 'ls -F -G -l %l | grep /$'),
|
|
||||||
# things which are executable
|
|
||||||
('lx', 'ls -F -l -G %l | grep ^-..x'),
|
|
||||||
]
|
|
||||||
default_aliases = default_aliases + ls_aliases
|
|
||||||
elif os.name in ['nt', 'dos']:
|
|
||||||
default_aliases = [('ls', 'dir /on'),
|
|
||||||
('ddir', 'dir /ad /on'), ('ldir', 'dir /ad /on'),
|
|
||||||
('mkdir', 'mkdir'), ('rmdir', 'rmdir'),
|
|
||||||
('echo', 'echo'), ('ren', 'ren'), ('copy', 'copy'),
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
default_aliases = []
|
|
||||||
|
|
||||||
return default_aliases
|
|
||||||
|
|
||||||
|
|
||||||
class AliasError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidAliasError(AliasError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class Alias(object):
|
|
||||||
"""Callable object storing the details of one alias.
|
|
||||||
|
|
||||||
Instances are registered as magic functions to allow use of aliases.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Prepare blacklist
|
|
||||||
blacklist = {'cd','popd','pushd','dhist','alias','unalias'}
|
|
||||||
|
|
||||||
def __init__(self, shell, name, cmd):
|
|
||||||
self.shell = shell
|
|
||||||
self.name = name
|
|
||||||
self.cmd = cmd
|
|
||||||
self.__doc__ = "Alias for `!{}`".format(cmd)
|
|
||||||
self.nargs = self.validate()
|
|
||||||
|
|
||||||
def validate(self):
|
|
||||||
"""Validate the alias, and return the number of arguments."""
|
|
||||||
if self.name in self.blacklist:
|
|
||||||
raise InvalidAliasError("The name %s can't be aliased "
|
|
||||||
"because it is a keyword or builtin." % self.name)
|
|
||||||
try:
|
|
||||||
caller = self.shell.magics_manager.magics['line'][self.name]
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if not isinstance(caller, Alias):
|
|
||||||
raise InvalidAliasError("The name %s can't be aliased "
|
|
||||||
"because it is another magic command." % self.name)
|
|
||||||
|
|
||||||
if not (isinstance(self.cmd, str)):
|
|
||||||
raise InvalidAliasError("An alias command must be a string, "
|
|
||||||
"got: %r" % self.cmd)
|
|
||||||
|
|
||||||
nargs = self.cmd.count('%s') - self.cmd.count('%%s')
|
|
||||||
|
|
||||||
if (nargs > 0) and (self.cmd.find('%l') >= 0):
|
|
||||||
raise InvalidAliasError('The %s and %l specifiers are mutually '
|
|
||||||
'exclusive in alias definitions.')
|
|
||||||
|
|
||||||
return nargs
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return "<alias {} for {!r}>".format(self.name, self.cmd)
|
|
||||||
|
|
||||||
def __call__(self, rest=''):
|
|
||||||
cmd = self.cmd
|
|
||||||
nargs = self.nargs
|
|
||||||
# Expand the %l special to be the user's input line
|
|
||||||
if cmd.find('%l') >= 0:
|
|
||||||
cmd = cmd.replace('%l', rest)
|
|
||||||
rest = ''
|
|
||||||
|
|
||||||
if nargs==0:
|
|
||||||
if cmd.find('%%s') >= 1:
|
|
||||||
cmd = cmd.replace('%%s', '%s')
|
|
||||||
# Simple, argument-less aliases
|
|
||||||
cmd = '%s %s' % (cmd, rest)
|
|
||||||
else:
|
|
||||||
# Handle aliases with positional arguments
|
|
||||||
args = rest.split(None, nargs)
|
|
||||||
if len(args) < nargs:
|
|
||||||
raise UsageError('Alias <%s> requires %s arguments, %s given.' %
|
|
||||||
(self.name, nargs, len(args)))
|
|
||||||
cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
|
|
||||||
|
|
||||||
self.shell.system(cmd)
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Main AliasManager class
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class AliasManager(Configurable):
|
|
||||||
default_aliases: List = List(default_aliases()).tag(config=True)
|
|
||||||
user_aliases: List = List(default_value=[]).tag(config=True)
|
|
||||||
shell = Instance(
|
|
||||||
"IPython.core.interactiveshell.InteractiveShellABC", allow_none=True
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, shell=None, **kwargs):
|
|
||||||
super(AliasManager, self).__init__(shell=shell, **kwargs)
|
|
||||||
# For convenient access
|
|
||||||
if self.shell is not None:
|
|
||||||
self.linemagics = self.shell.magics_manager.magics["line"]
|
|
||||||
self.init_aliases()
|
|
||||||
|
|
||||||
def init_aliases(self):
|
|
||||||
# Load default & user aliases
|
|
||||||
for name, cmd in self.default_aliases + self.user_aliases:
|
|
||||||
if (
|
|
||||||
cmd.startswith("ls ")
|
|
||||||
and self.shell is not None
|
|
||||||
and self.shell.colors == "NoColor"
|
|
||||||
):
|
|
||||||
cmd = cmd.replace(" --color", "")
|
|
||||||
self.soft_define_alias(name, cmd)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def aliases(self):
|
|
||||||
return [(n, func.cmd) for (n, func) in self.linemagics.items()
|
|
||||||
if isinstance(func, Alias)]
|
|
||||||
|
|
||||||
def soft_define_alias(self, name, cmd):
|
|
||||||
"""Define an alias, but don't raise on an AliasError."""
|
|
||||||
try:
|
|
||||||
self.define_alias(name, cmd)
|
|
||||||
except AliasError as e:
|
|
||||||
error("Invalid alias: %s" % e)
|
|
||||||
|
|
||||||
def define_alias(self, name, cmd):
|
|
||||||
"""Define a new alias after validating it.
|
|
||||||
|
|
||||||
This will raise an :exc:`AliasError` if there are validation
|
|
||||||
problems.
|
|
||||||
"""
|
|
||||||
caller = Alias(shell=self.shell, name=name, cmd=cmd)
|
|
||||||
self.shell.magics_manager.register_function(caller, magic_kind='line',
|
|
||||||
magic_name=name)
|
|
||||||
|
|
||||||
def get_alias(self, name):
|
|
||||||
"""Return an alias, or None if no alias by that name exists."""
|
|
||||||
aname = self.linemagics.get(name, None)
|
|
||||||
return aname if isinstance(aname, Alias) else None
|
|
||||||
|
|
||||||
def is_alias(self, name):
|
|
||||||
"""Return whether or not a given name has been defined as an alias"""
|
|
||||||
return self.get_alias(name) is not None
|
|
||||||
|
|
||||||
def undefine_alias(self, name):
|
|
||||||
if self.is_alias(name):
|
|
||||||
del self.linemagics[name]
|
|
||||||
else:
|
|
||||||
raise ValueError('%s is not an alias' % name)
|
|
||||||
|
|
||||||
def clear_aliases(self):
|
|
||||||
for name, _ in self.aliases:
|
|
||||||
self.undefine_alias(name)
|
|
||||||
|
|
||||||
def retrieve_alias(self, name):
|
|
||||||
"""Retrieve the command to which an alias expands."""
|
|
||||||
caller = self.get_alias(name)
|
|
||||||
if caller:
|
|
||||||
return caller.cmd
|
|
||||||
else:
|
|
||||||
raise ValueError('%s is not an alias' % name)
|
|
||||||
@@ -1,492 +0,0 @@
|
|||||||
# encoding: utf-8
|
|
||||||
"""
|
|
||||||
An application for IPython.
|
|
||||||
|
|
||||||
All top-level applications should use the classes in this module for
|
|
||||||
handling configuration and creating configurables.
|
|
||||||
|
|
||||||
The job of an :class:`Application` is to create the master configuration
|
|
||||||
object and then create the configurable objects, passing the config to them.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Copyright (c) IPython Development Team.
|
|
||||||
# Distributed under the terms of the Modified BSD License.
|
|
||||||
|
|
||||||
import atexit
|
|
||||||
from copy import deepcopy
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from traitlets.config.application import Application, catch_config_error
|
|
||||||
from traitlets.config.loader import ConfigFileNotFound, PyFileConfigLoader
|
|
||||||
from IPython.core import release, crashhandler
|
|
||||||
from IPython.core.profiledir import ProfileDir, ProfileDirError
|
|
||||||
from IPython.paths import get_ipython_dir, get_ipython_package_dir
|
|
||||||
from IPython.utils.path import ensure_dir_exists
|
|
||||||
from traitlets import (
|
|
||||||
List, Unicode, Type, Bool, Set, Instance, Undefined,
|
|
||||||
default, observe,
|
|
||||||
)
|
|
||||||
|
|
||||||
if os.name == "nt":
|
|
||||||
programdata = os.environ.get("PROGRAMDATA", None)
|
|
||||||
if programdata is not None:
|
|
||||||
SYSTEM_CONFIG_DIRS = [str(Path(programdata) / "ipython")]
|
|
||||||
else: # PROGRAMDATA is not defined by default on XP.
|
|
||||||
SYSTEM_CONFIG_DIRS = []
|
|
||||||
else:
|
|
||||||
SYSTEM_CONFIG_DIRS = [
|
|
||||||
"/usr/local/etc/ipython",
|
|
||||||
"/etc/ipython",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
ENV_CONFIG_DIRS = []
|
|
||||||
_env_config_dir = os.path.join(sys.prefix, 'etc', 'ipython')
|
|
||||||
if _env_config_dir not in SYSTEM_CONFIG_DIRS:
|
|
||||||
# only add ENV_CONFIG if sys.prefix is not already included
|
|
||||||
ENV_CONFIG_DIRS.append(_env_config_dir)
|
|
||||||
|
|
||||||
|
|
||||||
_envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS')
|
|
||||||
if _envvar in {None, ''}:
|
|
||||||
IPYTHON_SUPPRESS_CONFIG_ERRORS = None
|
|
||||||
else:
|
|
||||||
if _envvar.lower() in {'1','true'}:
|
|
||||||
IPYTHON_SUPPRESS_CONFIG_ERRORS = True
|
|
||||||
elif _envvar.lower() in {'0','false'} :
|
|
||||||
IPYTHON_SUPPRESS_CONFIG_ERRORS = False
|
|
||||||
else:
|
|
||||||
sys.exit("Unsupported value for environment variable: 'IPYTHON_SUPPRESS_CONFIG_ERRORS' is set to '%s' which is none of {'0', '1', 'false', 'true', ''}."% _envvar )
|
|
||||||
|
|
||||||
# aliases and flags
|
|
||||||
|
|
||||||
base_aliases = {}
|
|
||||||
if isinstance(Application.aliases, dict):
|
|
||||||
# traitlets 5
|
|
||||||
base_aliases.update(Application.aliases)
|
|
||||||
base_aliases.update(
|
|
||||||
{
|
|
||||||
"profile-dir": "ProfileDir.location",
|
|
||||||
"profile": "BaseIPythonApplication.profile",
|
|
||||||
"ipython-dir": "BaseIPythonApplication.ipython_dir",
|
|
||||||
"log-level": "Application.log_level",
|
|
||||||
"config": "BaseIPythonApplication.extra_config_file",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
base_flags = dict()
|
|
||||||
if isinstance(Application.flags, dict):
|
|
||||||
# traitlets 5
|
|
||||||
base_flags.update(Application.flags)
|
|
||||||
base_flags.update(
|
|
||||||
dict(
|
|
||||||
debug=(
|
|
||||||
{"Application": {"log_level": logging.DEBUG}},
|
|
||||||
"set log level to logging.DEBUG (maximize logging output)",
|
|
||||||
),
|
|
||||||
quiet=(
|
|
||||||
{"Application": {"log_level": logging.CRITICAL}},
|
|
||||||
"set log level to logging.CRITICAL (minimize logging output)",
|
|
||||||
),
|
|
||||||
init=(
|
|
||||||
{
|
|
||||||
"BaseIPythonApplication": {
|
|
||||||
"copy_config_files": True,
|
|
||||||
"auto_create": True,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"""Initialize profile with default config files. This is equivalent
|
|
||||||
to running `ipython profile create <profile>` prior to startup.
|
|
||||||
""",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileAwareConfigLoader(PyFileConfigLoader):
|
|
||||||
"""A Python file config loader that is aware of IPython profiles."""
|
|
||||||
def load_subconfig(self, fname, path=None, profile=None):
|
|
||||||
if profile is not None:
|
|
||||||
try:
|
|
||||||
profile_dir = ProfileDir.find_profile_dir_by_name(
|
|
||||||
get_ipython_dir(),
|
|
||||||
profile,
|
|
||||||
)
|
|
||||||
except ProfileDirError:
|
|
||||||
return
|
|
||||||
path = profile_dir.location
|
|
||||||
return super(ProfileAwareConfigLoader, self).load_subconfig(fname, path=path)
|
|
||||||
|
|
||||||
class BaseIPythonApplication(Application):
|
|
||||||
name = "ipython"
|
|
||||||
description = "IPython: an enhanced interactive Python shell."
|
|
||||||
version = Unicode(release.version)
|
|
||||||
|
|
||||||
aliases = base_aliases
|
|
||||||
flags = base_flags
|
|
||||||
classes = List([ProfileDir])
|
|
||||||
|
|
||||||
# enable `load_subconfig('cfg.py', profile='name')`
|
|
||||||
python_config_loader_class = ProfileAwareConfigLoader
|
|
||||||
|
|
||||||
# Track whether the config_file has changed,
|
|
||||||
# because some logic happens only if we aren't using the default.
|
|
||||||
config_file_specified = Set()
|
|
||||||
|
|
||||||
config_file_name = Unicode()
|
|
||||||
@default('config_file_name')
|
|
||||||
def _config_file_name_default(self):
|
|
||||||
return self.name.replace('-','_') + u'_config.py'
|
|
||||||
@observe('config_file_name')
|
|
||||||
def _config_file_name_changed(self, change):
|
|
||||||
if change['new'] != change['old']:
|
|
||||||
self.config_file_specified.add(change['new'])
|
|
||||||
|
|
||||||
# The directory that contains IPython's builtin profiles.
|
|
||||||
builtin_profile_dir = Unicode(
|
|
||||||
os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default')
|
|
||||||
)
|
|
||||||
|
|
||||||
config_file_paths = List(Unicode())
|
|
||||||
@default('config_file_paths')
|
|
||||||
def _config_file_paths_default(self):
|
|
||||||
return []
|
|
||||||
|
|
||||||
extra_config_file = Unicode(
|
|
||||||
help="""Path to an extra config file to load.
|
|
||||||
|
|
||||||
If specified, load this config file in addition to any other IPython config.
|
|
||||||
""").tag(config=True)
|
|
||||||
@observe('extra_config_file')
|
|
||||||
def _extra_config_file_changed(self, change):
|
|
||||||
old = change['old']
|
|
||||||
new = change['new']
|
|
||||||
try:
|
|
||||||
self.config_files.remove(old)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
self.config_file_specified.add(new)
|
|
||||||
self.config_files.append(new)
|
|
||||||
|
|
||||||
profile = Unicode(u'default',
|
|
||||||
help="""The IPython profile to use."""
|
|
||||||
).tag(config=True)
|
|
||||||
|
|
||||||
@observe('profile')
|
|
||||||
def _profile_changed(self, change):
|
|
||||||
self.builtin_profile_dir = os.path.join(
|
|
||||||
get_ipython_package_dir(), u'config', u'profile', change['new']
|
|
||||||
)
|
|
||||||
|
|
||||||
add_ipython_dir_to_sys_path = Bool(
|
|
||||||
False,
|
|
||||||
"""Should the IPython profile directory be added to sys path ?
|
|
||||||
|
|
||||||
This option was non-existing before IPython 8.0, and ipython_dir was added to
|
|
||||||
sys path to allow import of extensions present there. This was historical
|
|
||||||
baggage from when pip did not exist. This now default to false,
|
|
||||||
but can be set to true for legacy reasons.
|
|
||||||
""",
|
|
||||||
).tag(config=True)
|
|
||||||
|
|
||||||
ipython_dir = Unicode(
|
|
||||||
help="""
|
|
||||||
The name of the IPython directory. This directory is used for logging
|
|
||||||
configuration (through profiles), history storage, etc. The default
|
|
||||||
is usually $HOME/.ipython. This option can also be specified through
|
|
||||||
the environment variable IPYTHONDIR.
|
|
||||||
"""
|
|
||||||
).tag(config=True)
|
|
||||||
@default('ipython_dir')
|
|
||||||
def _ipython_dir_default(self):
|
|
||||||
d = get_ipython_dir()
|
|
||||||
self._ipython_dir_changed({
|
|
||||||
'name': 'ipython_dir',
|
|
||||||
'old': d,
|
|
||||||
'new': d,
|
|
||||||
})
|
|
||||||
return d
|
|
||||||
|
|
||||||
_in_init_profile_dir = False
|
|
||||||
|
|
||||||
profile_dir = Instance(ProfileDir, allow_none=True)
|
|
||||||
|
|
||||||
@default('profile_dir')
|
|
||||||
def _profile_dir_default(self):
|
|
||||||
# avoid recursion
|
|
||||||
if self._in_init_profile_dir:
|
|
||||||
return
|
|
||||||
# profile_dir requested early, force initialization
|
|
||||||
self.init_profile_dir()
|
|
||||||
return self.profile_dir
|
|
||||||
|
|
||||||
overwrite = Bool(False,
|
|
||||||
help="""Whether to overwrite existing config files when copying"""
|
|
||||||
).tag(config=True)
|
|
||||||
|
|
||||||
auto_create = Bool(False,
|
|
||||||
help="""Whether to create profile dir if it doesn't exist"""
|
|
||||||
).tag(config=True)
|
|
||||||
|
|
||||||
config_files = List(Unicode())
|
|
||||||
|
|
||||||
@default('config_files')
|
|
||||||
def _config_files_default(self):
|
|
||||||
return [self.config_file_name]
|
|
||||||
|
|
||||||
copy_config_files = Bool(False,
|
|
||||||
help="""Whether to install the default config files into the profile dir.
|
|
||||||
If a new profile is being created, and IPython contains config files for that
|
|
||||||
profile, then they will be staged into the new directory. Otherwise,
|
|
||||||
default config files will be automatically generated.
|
|
||||||
""").tag(config=True)
|
|
||||||
|
|
||||||
verbose_crash = Bool(False,
|
|
||||||
help="""Create a massive crash report when IPython encounters what may be an
|
|
||||||
internal error. The default is to append a short message to the
|
|
||||||
usual traceback""").tag(config=True)
|
|
||||||
|
|
||||||
# The class to use as the crash handler.
|
|
||||||
crash_handler_class = Type(crashhandler.CrashHandler)
|
|
||||||
|
|
||||||
@catch_config_error
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super(BaseIPythonApplication, self).__init__(**kwargs)
|
|
||||||
# ensure current working directory exists
|
|
||||||
try:
|
|
||||||
os.getcwd()
|
|
||||||
except:
|
|
||||||
# exit if cwd doesn't exist
|
|
||||||
self.log.error("Current working directory doesn't exist.")
|
|
||||||
self.exit(1)
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
# Various stages of Application creation
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
def init_crash_handler(self):
|
|
||||||
"""Create a crash handler, typically setting sys.excepthook to it."""
|
|
||||||
self.crash_handler = self.crash_handler_class(self)
|
|
||||||
sys.excepthook = self.excepthook
|
|
||||||
def unset_crashhandler():
|
|
||||||
sys.excepthook = sys.__excepthook__
|
|
||||||
atexit.register(unset_crashhandler)
|
|
||||||
|
|
||||||
def excepthook(self, etype, evalue, tb):
|
|
||||||
"""this is sys.excepthook after init_crashhandler
|
|
||||||
|
|
||||||
set self.verbose_crash=True to use our full crashhandler, instead of
|
|
||||||
a regular traceback with a short message (crash_handler_lite)
|
|
||||||
"""
|
|
||||||
|
|
||||||
if self.verbose_crash:
|
|
||||||
return self.crash_handler(etype, evalue, tb)
|
|
||||||
else:
|
|
||||||
return crashhandler.crash_handler_lite(etype, evalue, tb)
|
|
||||||
|
|
||||||
@observe('ipython_dir')
|
|
||||||
def _ipython_dir_changed(self, change):
|
|
||||||
old = change['old']
|
|
||||||
new = change['new']
|
|
||||||
if old is not Undefined:
|
|
||||||
str_old = os.path.abspath(old)
|
|
||||||
if str_old in sys.path:
|
|
||||||
sys.path.remove(str_old)
|
|
||||||
if self.add_ipython_dir_to_sys_path:
|
|
||||||
str_path = os.path.abspath(new)
|
|
||||||
sys.path.append(str_path)
|
|
||||||
ensure_dir_exists(new)
|
|
||||||
readme = os.path.join(new, "README")
|
|
||||||
readme_src = os.path.join(
|
|
||||||
get_ipython_package_dir(), "config", "profile", "README"
|
|
||||||
)
|
|
||||||
if not os.path.exists(readme) and os.path.exists(readme_src):
|
|
||||||
shutil.copy(readme_src, readme)
|
|
||||||
for d in ("extensions", "nbextensions"):
|
|
||||||
path = os.path.join(new, d)
|
|
||||||
try:
|
|
||||||
ensure_dir_exists(path)
|
|
||||||
except OSError as e:
|
|
||||||
# this will not be EEXIST
|
|
||||||
self.log.error("couldn't create path %s: %s", path, e)
|
|
||||||
self.log.debug("IPYTHONDIR set to: %s", new)
|
|
||||||
|
|
||||||
def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS):
|
|
||||||
"""Load the config file.
|
|
||||||
|
|
||||||
By default, errors in loading config are handled, and a warning
|
|
||||||
printed on screen. For testing, the suppress_errors option is set
|
|
||||||
to False, so errors will make tests fail.
|
|
||||||
|
|
||||||
`suppress_errors` default value is to be `None` in which case the
|
|
||||||
behavior default to the one of `traitlets.Application`.
|
|
||||||
|
|
||||||
The default value can be set :
|
|
||||||
- to `False` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '0', or 'false' (case insensitive).
|
|
||||||
- to `True` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '1' or 'true' (case insensitive).
|
|
||||||
- to `None` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '' (empty string) or leaving it unset.
|
|
||||||
|
|
||||||
Any other value are invalid, and will make IPython exit with a non-zero return code.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
self.log.debug("Searching path %s for config files", self.config_file_paths)
|
|
||||||
base_config = 'ipython_config.py'
|
|
||||||
self.log.debug("Attempting to load config file: %s" %
|
|
||||||
base_config)
|
|
||||||
try:
|
|
||||||
if suppress_errors is not None:
|
|
||||||
old_value = Application.raise_config_file_errors
|
|
||||||
Application.raise_config_file_errors = not suppress_errors;
|
|
||||||
Application.load_config_file(
|
|
||||||
self,
|
|
||||||
base_config,
|
|
||||||
path=self.config_file_paths
|
|
||||||
)
|
|
||||||
except ConfigFileNotFound:
|
|
||||||
# ignore errors loading parent
|
|
||||||
self.log.debug("Config file %s not found", base_config)
|
|
||||||
pass
|
|
||||||
if suppress_errors is not None:
|
|
||||||
Application.raise_config_file_errors = old_value
|
|
||||||
|
|
||||||
for config_file_name in self.config_files:
|
|
||||||
if not config_file_name or config_file_name == base_config:
|
|
||||||
continue
|
|
||||||
self.log.debug("Attempting to load config file: %s" %
|
|
||||||
self.config_file_name)
|
|
||||||
try:
|
|
||||||
Application.load_config_file(
|
|
||||||
self,
|
|
||||||
config_file_name,
|
|
||||||
path=self.config_file_paths
|
|
||||||
)
|
|
||||||
except ConfigFileNotFound:
|
|
||||||
# Only warn if the default config file was NOT being used.
|
|
||||||
if config_file_name in self.config_file_specified:
|
|
||||||
msg = self.log.warning
|
|
||||||
else:
|
|
||||||
msg = self.log.debug
|
|
||||||
msg("Config file not found, skipping: %s", config_file_name)
|
|
||||||
except Exception:
|
|
||||||
# For testing purposes.
|
|
||||||
if not suppress_errors:
|
|
||||||
raise
|
|
||||||
self.log.warning("Error loading config file: %s" %
|
|
||||||
self.config_file_name, exc_info=True)
|
|
||||||
|
|
||||||
def init_profile_dir(self):
|
|
||||||
"""initialize the profile dir"""
|
|
||||||
self._in_init_profile_dir = True
|
|
||||||
if self.profile_dir is not None:
|
|
||||||
# already ran
|
|
||||||
return
|
|
||||||
if 'ProfileDir.location' not in self.config:
|
|
||||||
# location not specified, find by profile name
|
|
||||||
try:
|
|
||||||
p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
|
|
||||||
except ProfileDirError:
|
|
||||||
# not found, maybe create it (always create default profile)
|
|
||||||
if self.auto_create or self.profile == 'default':
|
|
||||||
try:
|
|
||||||
p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
|
|
||||||
except ProfileDirError:
|
|
||||||
self.log.fatal("Could not create profile: %r"%self.profile)
|
|
||||||
self.exit(1)
|
|
||||||
else:
|
|
||||||
self.log.info("Created profile dir: %r"%p.location)
|
|
||||||
else:
|
|
||||||
self.log.fatal("Profile %r not found."%self.profile)
|
|
||||||
self.exit(1)
|
|
||||||
else:
|
|
||||||
self.log.debug("Using existing profile dir: %r", p.location)
|
|
||||||
else:
|
|
||||||
location = self.config.ProfileDir.location
|
|
||||||
# location is fully specified
|
|
||||||
try:
|
|
||||||
p = ProfileDir.find_profile_dir(location, self.config)
|
|
||||||
except ProfileDirError:
|
|
||||||
# not found, maybe create it
|
|
||||||
if self.auto_create:
|
|
||||||
try:
|
|
||||||
p = ProfileDir.create_profile_dir(location, self.config)
|
|
||||||
except ProfileDirError:
|
|
||||||
self.log.fatal("Could not create profile directory: %r"%location)
|
|
||||||
self.exit(1)
|
|
||||||
else:
|
|
||||||
self.log.debug("Creating new profile dir: %r"%location)
|
|
||||||
else:
|
|
||||||
self.log.fatal("Profile directory %r not found."%location)
|
|
||||||
self.exit(1)
|
|
||||||
else:
|
|
||||||
self.log.debug("Using existing profile dir: %r", p.location)
|
|
||||||
# if profile_dir is specified explicitly, set profile name
|
|
||||||
dir_name = os.path.basename(p.location)
|
|
||||||
if dir_name.startswith('profile_'):
|
|
||||||
self.profile = dir_name[8:]
|
|
||||||
|
|
||||||
self.profile_dir = p
|
|
||||||
self.config_file_paths.append(p.location)
|
|
||||||
self._in_init_profile_dir = False
|
|
||||||
|
|
||||||
def init_config_files(self):
|
|
||||||
"""[optionally] copy default config files into profile dir."""
|
|
||||||
self.config_file_paths.extend(ENV_CONFIG_DIRS)
|
|
||||||
self.config_file_paths.extend(SYSTEM_CONFIG_DIRS)
|
|
||||||
# copy config files
|
|
||||||
path = Path(self.builtin_profile_dir)
|
|
||||||
if self.copy_config_files:
|
|
||||||
src = self.profile
|
|
||||||
|
|
||||||
cfg = self.config_file_name
|
|
||||||
if path and (path / cfg).exists():
|
|
||||||
self.log.warning(
|
|
||||||
"Staging %r from %s into %r [overwrite=%s]"
|
|
||||||
% (cfg, src, self.profile_dir.location, self.overwrite)
|
|
||||||
)
|
|
||||||
self.profile_dir.copy_config_file(cfg, path=path, overwrite=self.overwrite)
|
|
||||||
else:
|
|
||||||
self.stage_default_config_file()
|
|
||||||
else:
|
|
||||||
# Still stage *bundled* config files, but not generated ones
|
|
||||||
# This is necessary for `ipython profile=sympy` to load the profile
|
|
||||||
# on the first go
|
|
||||||
files = path.glob("*.py")
|
|
||||||
for fullpath in files:
|
|
||||||
cfg = fullpath.name
|
|
||||||
if self.profile_dir.copy_config_file(cfg, path=path, overwrite=False):
|
|
||||||
# file was copied
|
|
||||||
self.log.warning("Staging bundled %s from %s into %r"%(
|
|
||||||
cfg, self.profile, self.profile_dir.location)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def stage_default_config_file(self):
|
|
||||||
"""auto generate default config file, and stage it into the profile."""
|
|
||||||
s = self.generate_config_file()
|
|
||||||
config_file = Path(self.profile_dir.location) / self.config_file_name
|
|
||||||
if self.overwrite or not config_file.exists():
|
|
||||||
self.log.warning("Generating default config file: %r", (config_file))
|
|
||||||
config_file.write_text(s, encoding="utf-8")
|
|
||||||
|
|
||||||
@catch_config_error
|
|
||||||
def initialize(self, argv=None):
|
|
||||||
# don't hook up crash handler before parsing command-line
|
|
||||||
self.parse_command_line(argv)
|
|
||||||
self.init_crash_handler()
|
|
||||||
if self.subapp is not None:
|
|
||||||
# stop here if subapp is taking over
|
|
||||||
return
|
|
||||||
# save a copy of CLI config to re-load after config files
|
|
||||||
# so that it has highest priority
|
|
||||||
cl_config = deepcopy(self.config)
|
|
||||||
self.init_profile_dir()
|
|
||||||
self.init_config_files()
|
|
||||||
self.load_config_file()
|
|
||||||
# enforce cl-opts override configfile opts:
|
|
||||||
self.update_config(cl_config)
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
"""
|
|
||||||
Async helper function that are invalid syntax on Python 3.5 and below.
|
|
||||||
|
|
||||||
This code is best effort, and may have edge cases not behaving as expected. In
|
|
||||||
particular it contain a number of heuristics to detect whether code is
|
|
||||||
effectively async and need to run in an event loop or not.
|
|
||||||
|
|
||||||
Some constructs (like top-level `return`, or `yield`) are taken care of
|
|
||||||
explicitly to actually raise a SyntaxError and stay as close as possible to
|
|
||||||
Python semantics.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import ast
|
|
||||||
import asyncio
|
|
||||||
import inspect
|
|
||||||
from functools import wraps
|
|
||||||
|
|
||||||
_asyncio_event_loop = None
|
|
||||||
|
|
||||||
|
|
||||||
def get_asyncio_loop():
|
|
||||||
"""asyncio has deprecated get_event_loop
|
|
||||||
|
|
||||||
Replicate it here, with our desired semantics:
|
|
||||||
|
|
||||||
- always returns a valid, not-closed loop
|
|
||||||
- not thread-local like asyncio's,
|
|
||||||
because we only want one loop for IPython
|
|
||||||
- if called from inside a coroutine (e.g. in ipykernel),
|
|
||||||
return the running loop
|
|
||||||
|
|
||||||
.. versionadded:: 8.0
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
return asyncio.get_running_loop()
|
|
||||||
except RuntimeError:
|
|
||||||
# not inside a coroutine,
|
|
||||||
# track our own global
|
|
||||||
pass
|
|
||||||
|
|
||||||
# not thread-local like asyncio's,
|
|
||||||
# because we only track one event loop to run for IPython itself,
|
|
||||||
# always in the main thread.
|
|
||||||
global _asyncio_event_loop
|
|
||||||
if _asyncio_event_loop is None or _asyncio_event_loop.is_closed():
|
|
||||||
_asyncio_event_loop = asyncio.new_event_loop()
|
|
||||||
return _asyncio_event_loop
|
|
||||||
|
|
||||||
|
|
||||||
class _AsyncIORunner:
|
|
||||||
def __call__(self, coro):
|
|
||||||
"""
|
|
||||||
Handler for asyncio autoawait
|
|
||||||
"""
|
|
||||||
return get_asyncio_loop().run_until_complete(coro)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "asyncio"
|
|
||||||
|
|
||||||
|
|
||||||
_asyncio_runner = _AsyncIORunner()
|
|
||||||
|
|
||||||
|
|
||||||
class _AsyncIOProxy:
|
|
||||||
"""Proxy-object for an asyncio
|
|
||||||
|
|
||||||
Any coroutine methods will be wrapped in event_loop.run_
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, obj, event_loop):
|
|
||||||
self._obj = obj
|
|
||||||
self._event_loop = event_loop
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return f"<_AsyncIOProxy({self._obj!r})>"
|
|
||||||
|
|
||||||
def __getattr__(self, key):
|
|
||||||
attr = getattr(self._obj, key)
|
|
||||||
if inspect.iscoroutinefunction(attr):
|
|
||||||
# if it's a coroutine method,
|
|
||||||
# return a threadsafe wrapper onto the _current_ asyncio loop
|
|
||||||
@wraps(attr)
|
|
||||||
def _wrapped(*args, **kwargs):
|
|
||||||
concurrent_future = asyncio.run_coroutine_threadsafe(
|
|
||||||
attr(*args, **kwargs), self._event_loop
|
|
||||||
)
|
|
||||||
return asyncio.wrap_future(concurrent_future)
|
|
||||||
|
|
||||||
return _wrapped
|
|
||||||
else:
|
|
||||||
return attr
|
|
||||||
|
|
||||||
def __dir__(self):
|
|
||||||
return dir(self._obj)
|
|
||||||
|
|
||||||
|
|
||||||
def _curio_runner(coroutine):
|
|
||||||
"""
|
|
||||||
handler for curio autoawait
|
|
||||||
"""
|
|
||||||
import curio
|
|
||||||
|
|
||||||
return curio.run(coroutine)
|
|
||||||
|
|
||||||
|
|
||||||
def _trio_runner(async_fn):
|
|
||||||
import trio
|
|
||||||
|
|
||||||
async def loc(coro):
|
|
||||||
"""
|
|
||||||
We need the dummy no-op async def to protect from
|
|
||||||
trio's internal. See https://github.com/python-trio/trio/issues/89
|
|
||||||
"""
|
|
||||||
return await coro
|
|
||||||
|
|
||||||
return trio.run(loc, async_fn)
|
|
||||||
|
|
||||||
|
|
||||||
def _pseudo_sync_runner(coro):
|
|
||||||
"""
|
|
||||||
A runner that does not really allow async execution, and just advance the coroutine.
|
|
||||||
|
|
||||||
See discussion in https://github.com/python-trio/trio/issues/608,
|
|
||||||
|
|
||||||
Credit to Nathaniel Smith
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
coro.send(None)
|
|
||||||
except StopIteration as exc:
|
|
||||||
return exc.value
|
|
||||||
else:
|
|
||||||
# TODO: do not raise but return an execution result with the right info.
|
|
||||||
raise RuntimeError(
|
|
||||||
"{coro_name!r} needs a real async loop".format(coro_name=coro.__name__)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _should_be_async(cell: str) -> bool:
|
|
||||||
"""Detect if a block of code need to be wrapped in an `async def`
|
|
||||||
|
|
||||||
Attempt to parse the block of code, it it compile we're fine.
|
|
||||||
Otherwise we wrap if and try to compile.
|
|
||||||
|
|
||||||
If it works, assume it should be async. Otherwise Return False.
|
|
||||||
|
|
||||||
Not handled yet: If the block of code has a return statement as the top
|
|
||||||
level, it will be seen as async. This is a know limitation.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
code = compile(
|
|
||||||
cell, "<>", "exec", flags=getattr(ast, "PyCF_ALLOW_TOP_LEVEL_AWAIT", 0x0)
|
|
||||||
)
|
|
||||||
return inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE
|
|
||||||
except (SyntaxError, MemoryError):
|
|
||||||
return False
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user