Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,23 @@ def get_root() -> str:
"""
root = os.path.realpath(os.path.abspath(os.getcwd()))
setup_py = os.path.join(root, "setup.py")
pyproject_toml = os.path.join(root, "pyproject.toml")
versioneer_py = os.path.join(root, "versioneer.py")
if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):
if not (
os.path.exists(setup_py)
or os.path.exists(pyproject_toml)
or os.path.exists(versioneer_py)
):
# allow 'python path/to/setup.py COMMAND'
root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0])))
setup_py = os.path.join(root, "setup.py")
pyproject_toml = os.path.join(root, "pyproject.toml")
Comment on lines 64 to +67
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't necessarily think doing the path translation is necessary here, but happy to keep it for consistency. (I actually suspect we should rewrite some of this logic a bit, since it defaults to cwd() rather than the actual target of the package.)

versioneer_py = os.path.join(root, "versioneer.py")
if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):
if not (
os.path.exists(setup_py)
or os.path.exists(pyproject_toml)
or os.path.exists(versioneer_py)
):
err = ("Versioneer was unable to run the project root directory. "
"Versioneer requires setup.py to be executed from "
"its immediate directory (like 'python setup.py COMMAND'), "
Expand Down