MCPcopy Create free account
hub / github.com/microsoft/debugpy / get_root

Function get_root

versioneer.py:298–334  ·  view source on GitHub ↗

Get the project root directory. We require that all commands are run from the project root, i.e. the directory that contains setup.py, setup.cfg, and versioneer.py .

()

Source from the content-addressed store, hash-verified

296
297
298def get_root():
299 """Get the project root directory.
300
301 We require that all commands are run from the project root, i.e. the
302 directory that contains setup.py, setup.cfg, and versioneer.py .
303 """
304 root = os.path.realpath(os.path.abspath(os.getcwd()))
305 setup_py = os.path.join(root, "setup.py")
306 versioneer_py = os.path.join(root, "versioneer.py")
307 if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):
308 # allow 'python path/to/setup.py COMMAND'
309 root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0])))
310 setup_py = os.path.join(root, "setup.py")
311 versioneer_py = os.path.join(root, "versioneer.py")
312 if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):
313 err = ("Versioneer was unable to run the project root directory. "
314 "Versioneer requires setup.py to be executed from "
315 "its immediate directory (like 'python setup.py COMMAND'), "
316 "or in a way that lets it use sys.argv[0] to find the root "
317 "(like 'python path/to/setup.py COMMAND').")
318 raise VersioneerBadRootError(err)
319 try:
320 # Certain runtime workflows (setup.py install/develop in a setuptools
321 # tree) execute all dependencies in a single python process, so
322 # "versioneer" may be imported multiple times, and python's shared
323 # module-import table will cache the first one. So we can't use
324 # os.path.dirname(__file__), as that will find whichever
325 # versioneer.py was first imported, even in later projects.
326 my_path = os.path.realpath(os.path.abspath(__file__))
327 me_dir = os.path.normcase(os.path.splitext(my_path)[0])
328 vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0])
329 if me_dir != vsr_dir:
330 print("Warning: build in %s is using versioneer.py from %s"
331 % (os.path.dirname(my_path), versioneer_py))
332 except NameError:
333 pass
334 return root
335
336
337def get_config_from_root(root):

Callers 8

get_versionsFunction · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
find_sourcesMethod · 0.85
make_release_treeMethod · 0.85
do_setupFunction · 0.85

Calls 2

joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…