mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Reformat product code.
This commit is contained in:
parent
89be0d1fce
commit
03c75833d4
11 changed files with 86 additions and 64 deletions
|
|
@ -8,11 +8,8 @@ build-backend = "setuptools.build_meta"
|
|||
# The only exclusions that should remain in the end are _vendored and versioneer.
|
||||
exclude = '''
|
||||
( __pycache__
|
||||
| ^/setup.py
|
||||
| ^/versioneer.py
|
||||
| ^/src/ptvsd/_vendored
|
||||
| ^/src/ptvsd/_version.py
|
||||
| ^/src/ptvsd/common
|
||||
| ^/src/ptvsd/server
|
||||
)
|
||||
'''
|
||||
|
|
|
|||
102
setup.py
102
setup.py
|
|
@ -11,45 +11,50 @@ import sys
|
|||
|
||||
|
||||
pure = None
|
||||
if '--pure' in sys.argv:
|
||||
if "--pure" in sys.argv:
|
||||
pure = True
|
||||
sys.argv.remove('--pure')
|
||||
elif '--universal' in sys.argv:
|
||||
sys.argv.remove("--pure")
|
||||
elif "--universal" in sys.argv:
|
||||
pure = True
|
||||
elif '--abi' in sys.argv:
|
||||
elif "--abi" in sys.argv:
|
||||
pure = False
|
||||
sys.argv.remove('--abi')
|
||||
sys.argv.remove("--abi")
|
||||
|
||||
|
||||
from setuptools import setup # noqa
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import versioneer # noqa
|
||||
|
||||
del sys.path[0]
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'src'))
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "src"))
|
||||
import ptvsd
|
||||
import ptvsd._vendored
|
||||
|
||||
del sys.path[0]
|
||||
|
||||
|
||||
PYDEVD_ROOT = ptvsd._vendored.project_root('pydevd')
|
||||
PYDEVD_ROOT = ptvsd._vendored.project_root("pydevd")
|
||||
PTVSD_ROOT = os.path.dirname(os.path.abspath(ptvsd.__file__))
|
||||
|
||||
|
||||
def get_buildplatform():
|
||||
if '-p' in sys.argv:
|
||||
return sys.argv[sys.argv.index('-p') + 1]
|
||||
if "-p" in sys.argv:
|
||||
return sys.argv[sys.argv.index("-p") + 1]
|
||||
return None
|
||||
|
||||
|
||||
def cython_build():
|
||||
print('Compiling extension modules (set SKIP_CYTHON_BUILD=1 to omit)')
|
||||
subprocess.call([
|
||||
sys.executable,
|
||||
os.path.join(PYDEVD_ROOT, 'setup_cython.py'),
|
||||
'build_ext',
|
||||
'-i',
|
||||
])
|
||||
print("Compiling extension modules (set SKIP_CYTHON_BUILD=1 to omit)")
|
||||
subprocess.call(
|
||||
[
|
||||
sys.executable,
|
||||
os.path.join(PYDEVD_ROOT, "setup_cython.py"),
|
||||
"build_ext",
|
||||
"-i",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def iter_vendored_files():
|
||||
|
|
@ -61,7 +66,7 @@ def iter_vendored_files():
|
|||
yield filename
|
||||
|
||||
|
||||
with open('DESCRIPTION.md', 'r') as fh:
|
||||
with open("DESCRIPTION.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
|
||||
|
|
@ -73,56 +78,57 @@ try:
|
|||
_bdist_wheel.finalize_options(self)
|
||||
self.root_is_pure = pure
|
||||
|
||||
|
||||
except ImportError:
|
||||
bdist_wheel = None
|
||||
|
||||
if __name__ == '__main__':
|
||||
if not os.getenv('SKIP_CYTHON_BUILD'):
|
||||
if __name__ == "__main__":
|
||||
if not os.getenv("SKIP_CYTHON_BUILD"):
|
||||
cython_build()
|
||||
|
||||
cmds = versioneer.get_cmdclass()
|
||||
cmds['bdist_wheel'] = bdist_wheel
|
||||
cmds["bdist_wheel"] = bdist_wheel
|
||||
|
||||
extras = {}
|
||||
platforms = get_buildplatform()
|
||||
if platforms is not None:
|
||||
extras['platforms'] = platforms
|
||||
extras["platforms"] = platforms
|
||||
|
||||
setup(
|
||||
name='ptvsd',
|
||||
name="ptvsd",
|
||||
version=versioneer.get_version(),
|
||||
description='Remote debugging server for Python support in Visual Studio and Visual Studio Code', # noqa
|
||||
description="Remote debugging server for Python support in Visual Studio and Visual Studio Code", # noqa
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
license='MIT',
|
||||
author='Microsoft Corporation',
|
||||
author_email='ptvshelp@microsoft.com',
|
||||
url='https://aka.ms/ptvs',
|
||||
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
|
||||
long_description_content_type="text/markdown",
|
||||
license="MIT",
|
||||
author="Microsoft Corporation",
|
||||
author_email="ptvshelp@microsoft.com",
|
||||
url="https://aka.ms/ptvs",
|
||||
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Topic :: Software Development :: Debuggers',
|
||||
'Operating System :: OS Independent',
|
||||
'License :: OSI Approved :: Eclipse Public License 2.0 (EPL-2.0)',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3.4",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Topic :: Software Development :: Debuggers",
|
||||
"Operating System :: OS Independent",
|
||||
"License :: OSI Approved :: Eclipse Public License 2.0 (EPL-2.0)",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
],
|
||||
package_dir={'': 'src'},
|
||||
package_dir={"": "src"},
|
||||
packages=[
|
||||
'ptvsd',
|
||||
'ptvsd.adapter',
|
||||
'ptvsd.common',
|
||||
'ptvsd.launcher',
|
||||
'ptvsd.server',
|
||||
'ptvsd._vendored',
|
||||
"ptvsd",
|
||||
"ptvsd.adapter",
|
||||
"ptvsd.common",
|
||||
"ptvsd.launcher",
|
||||
"ptvsd.server",
|
||||
"ptvsd._vendored",
|
||||
],
|
||||
package_data={
|
||||
'ptvsd': ['ThirdPartyNotices.txt'],
|
||||
'ptvsd._vendored': list(iter_vendored_files()),
|
||||
"ptvsd": ["ThirdPartyNotices.txt"],
|
||||
"ptvsd._vendored": list(iter_vendored_files()),
|
||||
},
|
||||
cmdclass=cmds,
|
||||
**extras
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ def wait_for_attach():
|
|||
"""
|
||||
|
||||
from ptvsd.server import api
|
||||
|
||||
return api.wait_for_attach()
|
||||
|
||||
|
||||
|
|
@ -75,6 +76,7 @@ def enable_attach(address, log_dir=None, multiprocess=True):
|
|||
"""
|
||||
|
||||
from ptvsd.server import api
|
||||
|
||||
return api.enable_attach(address, log_dir)
|
||||
|
||||
|
||||
|
|
@ -102,6 +104,7 @@ def attach(address, log_dir=None, multiprocess=True):
|
|||
"""
|
||||
|
||||
from ptvsd.server import api
|
||||
|
||||
return api.attach(address, log_dir)
|
||||
|
||||
|
||||
|
|
@ -110,6 +113,7 @@ def is_attached():
|
|||
"""
|
||||
|
||||
from ptvsd.server import api
|
||||
|
||||
return api.is_attached()
|
||||
|
||||
|
||||
|
|
@ -119,6 +123,7 @@ def break_into_debugger():
|
|||
"""
|
||||
|
||||
from ptvsd.server import api
|
||||
|
||||
return api.break_into_debugger()
|
||||
|
||||
|
||||
|
|
@ -131,6 +136,7 @@ def debug_this_thread():
|
|||
"""
|
||||
|
||||
from ptvsd.server import api
|
||||
|
||||
return api.debug_this_thread()
|
||||
|
||||
|
||||
|
|
@ -152,6 +158,7 @@ def tracing(should_trace=None):
|
|||
Whether to enable or disable tracing.
|
||||
"""
|
||||
from ptvsd.server import api
|
||||
|
||||
return api.tracing(should_trace)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ if __name__ == "__main__":
|
|||
# Do not use dirname() to walk up - this can be a relative path, e.g. ".".
|
||||
sys.path[0] = sys.path[0] + "/../"
|
||||
import ptvsd # noqa
|
||||
|
||||
del sys.path[0]
|
||||
|
||||
from ptvsd.server import cli
|
||||
|
||||
cli.main()
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ def _parse_argv(argv):
|
|||
type=int,
|
||||
default=None,
|
||||
metavar="PORT",
|
||||
help=argparse.SUPPRESS
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
|
|
|
|||
|
|
@ -82,7 +82,9 @@ class Component(util.Observable):
|
|||
except messaging.MessageHandlingError as exc:
|
||||
exc.propagate(message)
|
||||
except messaging.JsonIOError as exc:
|
||||
raise message.cant_handle("{0} disconnected unexpectedly", exc.stream.name, silent=True)
|
||||
raise message.cant_handle(
|
||||
"{0} disconnected unexpectedly", exc.stream.name, silent=True
|
||||
)
|
||||
|
||||
return lock_and_handle
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import socket
|
|||
def create_server(host, port, timeout=None):
|
||||
"""Return a local server socket listening on the given port."""
|
||||
if host is None:
|
||||
host = 'localhost'
|
||||
host = "127.0.0.1"
|
||||
try:
|
||||
server = _new_sock()
|
||||
server.bind((host, port))
|
||||
|
|
@ -31,7 +31,7 @@ def create_client():
|
|||
|
||||
def _new_sock():
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
|
||||
if platform.system() == 'Windows':
|
||||
if platform.system() == "Windows":
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1)
|
||||
else:
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
|
||||
# "force_pydevd" must be imported first to ensure (via side effects)
|
||||
# that the ptvsd-vendored copy of pydevd gets used.
|
||||
import ptvsd._vendored.force_pydevd # noqa
|
||||
import ptvsd._vendored.force_pydevd # noqa
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ def enable_attach(dont_trace_start_patterns, dont_trace_end_patterns):
|
|||
# so never wait on the adapter process
|
||||
process = subprocess.Popen(adapter_args, bufsize=0)
|
||||
# Ensure that we ignore the adapter process when terminating the
|
||||
# debugger.
|
||||
# debugger.
|
||||
pydevd.add_dont_terminate_child_pid(process.pid)
|
||||
|
||||
server_opts.port = port_queue.get(True, _QUEUE_TIMEOUT)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ _ptvsd_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
|||
def attach(host, port, client, log_dir=None):
|
||||
try:
|
||||
import sys
|
||||
if 'threading' not in sys.modules:
|
||||
|
||||
if "threading" not in sys.modules:
|
||||
try:
|
||||
|
||||
def on_warn(msg):
|
||||
|
|
@ -28,22 +29,26 @@ def attach(host, port, client, log_dir=None):
|
|||
|
||||
pydevd_attach_to_process_path = os.path.join(
|
||||
_ptvsd_dir,
|
||||
'ptvsd',
|
||||
'_vendored',
|
||||
'pydevd',
|
||||
'pydevd_attach_to_process')
|
||||
"ptvsd",
|
||||
"_vendored",
|
||||
"pydevd",
|
||||
"pydevd_attach_to_process",
|
||||
)
|
||||
assert os.path.exists(pydevd_attach_to_process_path)
|
||||
sys.path.insert(0, pydevd_attach_to_process_path)
|
||||
|
||||
# NOTE: that it's not a part of the pydevd PYTHONPATH
|
||||
import attach_script
|
||||
|
||||
attach_script.fix_main_thread_id(
|
||||
on_warn=on_warn, on_exception=on_exception, on_critical=on_critical)
|
||||
on_warn=on_warn, on_exception=on_exception, on_critical=on_critical
|
||||
)
|
||||
|
||||
# NOTE: At this point it should be safe to remove this.
|
||||
sys.path.remove(pydevd_attach_to_process_path)
|
||||
except:
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
raise
|
||||
|
||||
|
|
@ -57,6 +62,7 @@ def attach(host, port, client, log_dir=None):
|
|||
|
||||
from ptvsd.common import options as common_opts
|
||||
from ptvsd.server import options
|
||||
|
||||
if log_dir is not None:
|
||||
common_opts.log_dir = log_dir
|
||||
options.client = client
|
||||
|
|
@ -69,9 +75,11 @@ def attach(host, port, client, log_dir=None):
|
|||
ptvsd.enable_attach((options.host, options.port))
|
||||
|
||||
from ptvsd.common import log
|
||||
|
||||
log.info("Debugger successfully injected")
|
||||
|
||||
except:
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
raise log.exception()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ If target_kind is 'code', then target is the code to run.
|
|||
If target_kind is 'pid', then target is the process ID to attach to.
|
||||
"""
|
||||
|
||||
host = '127.0.0.1'
|
||||
host = "127.0.0.1"
|
||||
"""Name or IP address of the network interface used by ptvsd.server. If runing in server
|
||||
mode, this is the interface on which it listens for incoming connections. If running
|
||||
in client mode, this is the interface to which it connects.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue