MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / get_root

Function get_root

versioneer.py:298–335  ·  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 = (
314 "Versioneer was unable to run the project root directory. "
315 "Versioneer requires setup.py to be executed from "
316 "its immediate directory (like 'python setup.py COMMAND'), "
317 "or in a way that lets it use sys.argv[0] to find the root "
318 "(like 'python path/to/setup.py COMMAND')."
319 )
320 raise VersioneerBadRootError(err)
321 try:
322 # Certain runtime workflows (setup.py install/develop in a setuptools
323 # tree) execute all dependencies in a single python process, so
324 # "versioneer" may be imported multiple times, and python's shared
325 # module-import table will cache the first one. So we can't use
326 # os.path.dirname(__file__), as that will find whichever
327 # versioneer.py was first imported, even in later projects.
328 my_path = os.path.realpath(os.path.abspath(__file__))
329 me_dir = os.path.normcase(os.path.splitext(my_path)[0])
330 vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0])
331 if me_dir != vsr_dir:
332 print("Warning: build in %s is using versioneer.py from %s" % (os.path.dirname(my_path), versioneer_py))
333 except NameError:
334 pass
335 return root
336
337
338def 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 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…