Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive when checking for inconsistent setup script path on Windows #1519

Closed
uranusjr opened this issue Oct 23, 2018 · 8 comments · Fixed by #1521
Closed

False positive when checking for inconsistent setup script path on Windows #1519

uranusjr opened this issue Oct 23, 2018 · 8 comments · Fixed by #1521
Labels

Comments

@uranusjr
Copy link
Member

> python setup.py develop
running develop
Checking .pth file support in C:\project\venv\Lib\site-packages\
C:\project\venv\Scripts\pythonw.exe -E -c pass
TEST PASSED: C:\project\venv\Lib\site-packages\ appears to support .pth files
error: ("Can't get a consistent path to setup script from installation directory", 'c:\\project\\', 'c:\\project')

I am not sure what exactly is the cause (I did not have this problem previously, but suddenly sees it when coming back to work on an old project), but it seems to come from a quirk of realpath():

>>> import os
>>> os.path.realpath('.')
'C:\\Users\\uranusjr\\'
>>> os.path.realpath('../')
'C:\\Users\\'
>>> os.path.realpath('..')
'C:\\Users'
@pganssle pganssle added Needs Triage Issues that need to be evaluated for severity and status. Needs Repro Issues that need a reproducible example. and removed Needs Triage Issues that need to be evaluated for severity and status. labels Oct 23, 2018
@pganssle
Copy link
Member

@uranusjr Can you provide a minimal reproducing example for this? It seems that the error is being raised from here, based on the error message, but without a failing test or a minimal reproducing example, it's hard to tell how to fix it.

@uranusjr
Copy link
Member Author

Of course!

> mkdir project
> cd project
> mkdir src
> [create setup.py]
from setuptools import find_packages, setup

setup(
    name='project',
    version='0.0.0',
    package_dir={'': 'src'},
    packages=find_packages('src'),
)
> python setup.py develop
running develop
Checking .pth file support in C:\Users\uranusjr\Documents\playground\project\.venv\Lib\site-packages\
C:\Users\uranusjr\Documents\playground\project\.venv\Scripts\pythonw.exe -E -c pass
TEST PASSED: C:\Users\uranusjr\Documents\playground\project\.venv\Lib\site-packages\ appears to support .pth files
error: ("Can't get a consistent path to setup script from installation directory", 'c:\\users\\uranusjr\\documents\\playground\\project\\', 'c:\\users\\uranusjr\\documents\\playground\\project')

@uranusjr
Copy link
Member Author

I did some digging and it seems the most straightforward fix is to call an additional os.path.normpath in normalize_path to normalise the trailing slash:

def normalize_path(filename):
    """Normalize a file/dir name for comparison purposes"""
    return os.path.normcase(os.path.normpath(os.path.realpath(filename)))

This seems reasonable based on the function’s docstring, but I am not sure how accurate it is, and whether the change would have more implications.

@pganssle pganssle added bug help wanted good first issue Needs Implementation Issues that are ready to be implemented. and removed Needs Repro Issues that need a reproducible example. labels Oct 23, 2018
@pganssle
Copy link
Member

I think based on the file's docstring, it makes sense to add the additional normpath call in there, since these should compare equal. For example, pathlib has them compare equal:

>>> pathlib.Path("path/to/file") == pathlib.Path("path/to/file/")
True

@davidism
Copy link

davidism commented Oct 24, 2018

I can reproduce this. Have been working to move ItsDangerous and MarkupSafe to a src directory structure, and became unable to do pip install -e . for them on Windows. It works fine on Linux. Tox has no problem building an sdist and installing them in its testing envs on either platform.

jaraco pushed a commit that referenced this issue Oct 25, 2018
@zmwangx
Copy link

zmwangx commented Nov 3, 2018

Just experienced this myself when I upgraded to Python 3.7.1. This is due to a regression in ntpath.abspath in 3.7.1 — bpo-31047, and addressed in GH-10082, which has already landed. But the damage is done. Seeing that this is a Python regression, I'm not sure what's the best resolution either.

@pganssle
Copy link
Member

pganssle commented Nov 3, 2018

@zmwangx I think we're just waiting on a final approval on PR #1521, then the issue can be resolved.

@zmwangx
Copy link

zmwangx commented Nov 3, 2018

Oh I missed the PR. Thanks for the pointer.

danielwe added a commit to mabuchilab/QNET that referenced this issue Nov 7, 2018
Editable installation can be unreliable, as evidenced by
pypa/setuptools#1519, which caused Windows
tests to fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants