File: setup.py

package info (click to toggle)
pydevd 3.3.0%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 13,892 kB
  • sloc: python: 77,508; cpp: 1,869; sh: 368; makefile: 50; ansic: 4
file content (194 lines) | stat: -rw-r--r-- 6,697 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
r"""
Full setup, used to distribute the debugger backend to PyPi.

Note that this is mostly so that users can do:

pip install pydevd

in a machine for doing remote-debugging, as a local installation with the IDE should have
everything already distributed.

Reference on wheels:
https://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/
http://lucumr.pocoo.org/2014/1/27/python-on-wheels/

Another (no wheels): https://jamie.curle.io/blog/my-first-experience-adding-package-pypi/

See:

build_tools\pydevd_release_process.txt

for release process.
"""

from setuptools import Extension, setup
from setuptools.dist import Distribution
import os


class BinaryDistribution(Distribution):
    def is_pure(self):
        return False

import pydevd

version = pydevd.__version__

with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "README.md"), "r", encoding="utf-8") as stream:
    long_description = stream.read()

args = dict(
    name="pydevd",
    version=version,
    description="PyDev.Debugger (used in PyDev, PyCharm and VSCode Python)",
    long_description_content_type="text/markdown",
    long_description=long_description,
    author="Fabio Zadrozny and others",
    url="https://github.com/fabioz/PyDev.Debugger/",
    license="EPL",
    packages=[
        "_pydev_bundle",
        "_pydev_bundle.fsnotify",
        "_pydev_runfiles",
        "_pydevd_bundle",
        "_pydevd_bundle._debug_adapter",
        "_pydevd_bundle.pydevd_concurrency_analyser",
        "_pydevd_frame_eval",
        "_pydevd_sys_monitoring",
        "_pydevd_frame_eval.vendored",
        "_pydevd_frame_eval.vendored.bytecode",
        "pydev_ipython",
        # 'pydev_sitecustomize', -- Not actually a package (not added)
        "pydevd_attach_to_process",
        "pydevd_attach_to_process.common",
        "pydevd_attach_to_process.linux_and_mac",
        "pydevd_attach_to_process.windows",
        "pydevd_attach_to_process.winappdbg",
        "pydevd_attach_to_process.winappdbg.win32",
        "pydevd_plugins",
        "pydevd_plugins.extensions",
        "pydevd_plugins.extensions.types",
    ],
    py_modules=[
        # 'interpreterInfo', -- Not needed for debugger
        # 'pycompletionserver', -- Not needed for debugger
        "pydev_app_engine_debug_startup",
        # 'pydev_coverage', -- Not needed for debugger
        # 'pydev_pysrc', -- Not needed for debugger
        "pydev_run_in_console",
        "pydevconsole",
        "pydevd_file_utils",
        "pydevd",
        "pydevd_tracing",
        # 'runfiles', -- Not needed for debugger
        "setup_pydevd_cython",  # Distributed to clients. See: https://github.com/fabioz/PyDev.Debugger/issues/102
        # 'setup', -- Should not be included as a module
    ],
    classifiers=[
        "Development Status :: 6 - Mature",
        "Environment :: Console",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: Eclipse Public License 1.0 (EPL-1.0)",
        "Operating System :: MacOS :: MacOS X",
        "Operating System :: Microsoft :: Windows",
        "Operating System :: POSIX",
        "Programming Language :: Python",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Programming Language :: Python :: 3.12",
        "Topic :: Software Development :: Debuggers",
    ],
    entry_points={
        "console_scripts": [
            "pydevd = pydevd:main",
        ],
    },
    keywords=["pydev", "pydevd", "pydev.debugger"],
    include_package_data=True,
    zip_safe=False,
)

import sys

try:
    extra_compile_args = []
    extra_link_args = []

    if "linux" in sys.platform:
        # Enabling -flto brings executable from 4MB to 0.56MB and -Os to 0.41MB
        # Profiling shows an execution around 3-5% slower with -Os vs -O3,
        # so, kept only -flto.
        extra_compile_args = ["-flto"]
        extra_link_args = extra_compile_args[:]

        # Note: also experimented with profile-guided optimization. The executable
        # size became a bit smaller (from 0.56MB to 0.5MB) but this would add an
        # extra step to run the debugger to obtain the optimizations
        # so, skipped it for now (note: the actual benchmarks time was in the
        # margin of a 0-1% improvement, which is probably not worth it for
        # speed increments).
        # extra_compile_args = ["-flto", "-fprofile-generate"]
        # ... Run benchmarks ...
        # extra_compile_args = ["-flto", "-fprofile-use", "-fprofile-correction"]
    elif "win32" in sys.platform:
        pass
        # uncomment to generate pdbs for visual studio.
        # extra_compile_args=["-Zi", "/Od"]
        # extra_link_args=["-debug"]

    kwargs = {}
    if extra_link_args:
        kwargs["extra_link_args"] = extra_link_args
    if extra_compile_args:
        kwargs["extra_compile_args"] = extra_compile_args

    ext_modules = [
        # In this setup, don't even try to compile with cython, just go with the .c file which should've
        # been properly generated from a tested version.
        Extension(
            "_pydevd_bundle.pydevd_cython",
            [
                "_pydevd_bundle/pydevd_cython.c",
            ],
            define_macros=[("Py_BUILD_CORE_MODULE", "1")],
            **kwargs,
        )
    ]

    py_version = sys.version_info[:2]
    if (3, 6) <= py_version <= (3, 10):
        ext_modules.append(
            Extension(
                "_pydevd_frame_eval.pydevd_frame_evaluator",
                [
                    "_pydevd_frame_eval/pydevd_frame_evaluator.c",
                ],
                define_macros=[("Py_BUILD_CORE_MODULE", "1")],
                **kwargs,
            )
        )

    # Note: 3.11 does not have frame eval implemented (nor sys.monitoring)

    if py_version >= (3, 12):
        ext_modules.append(
            Extension(
                "_pydevd_sys_monitoring._pydevd_sys_monitoring_cython",
                [
                    "_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.c",
                ],
                define_macros=[("Py_BUILD_CORE_MODULE", "1")],
                **kwargs,
            )
        )

    args_with_binaries = args.copy()
    args_with_binaries.update(dict(distclass=BinaryDistribution, ext_modules=ext_modules))
    setup(**args_with_binaries)
except:
    # Compile failed: just setup without compiling cython deps.
    setup(**args)
    sys.stdout.write("Plain-python version of pydevd installed (cython speedups not available).\n")