pypa / pypa/setuptools

[BUG] Path to setup script not properly normalised during develop install for packages on network drive

Open
#2,804 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Needs Triage
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

setuptools version

setuptools 58.1.0

Python version

Python 3.9.7

OS

Windows 10 20H2

Additional environment information

No response

Description

I have a virtual environment (with Python 3.9.7, pip 21.2.4 on Windows 10 2020H2) on my C drive, which I use for a python project on a network drive, U, I cannot install the virtualenv on the network drive (there's a permission error I can't fix) and work policy prevents me moving the project to my C drive.

When I try to install the package with pip install --editable .\\package_name (or with the absolute path), the path normalisation fails and I get the following error (paths slightly altered for security reasons):

error: ("Can't get a consistent path to setup script from installation directory", 'u:\\project_name\\package_name', 'u:\\project_name\\package_name\\.')

These paths differ only by the trailing dot and so should be considered equivalent, but normalisation has failed to make them the same.

The issue also occurs if I attempt to install the package not in any virtualenv but using the globally-accessible python interpreter, but not if I copy the package to the C drive before attempting the install. Therefore, it appears to be caused by having the python executable on a different drive to the package which is being installed.

Expected behavior

I expected that attempting to install the package in develop mode would work despite the python interpreter being on my local C drive and the package being on a network drive.

How to Reproduce
  1. Create a python package on a network drive, in the format recommended by the python packaging tutorial, with a pyproject.toml and setup.cfg file.
  2. Attempt to install it using pip install -e ./path/to/package using a python/pip installed on a local drive
  3. Observe a path normalisation error.
Output
U:\project_name > ls .\package_name
    Directory: U:\project_name\package_name

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        29/09/2021     11:44                   src
-a----        21/09/2021     15:58            110 pyproject.toml
-a----        21/09/2021     16:36            628 setup.cfg

U:\project_name > pip install -e .\\package_name
Obtaining file:///U:/project_name/package_name
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: pyserial==3.5 in c:\users\armw\virtualenvs\project_name\lib\site-packages (from package_name==0.0.1) (3.5)
Installing collected packages: package_name
  Running setup.py develop for package_name
    ERROR: Command errored out with exit status 1:
s\\package_name\\setup.py'"'"'; __file__='"'"'U:\\project_name\\package_name\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: U:\project_name\package_name\
    Complete output (2 lines):
    running develop
    error: ("Can't get a consistent path to setup script from installation directory", 'u:\\project_name\\package_name', 'u:\\project_name\\package_name\\.')
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\ARMW\VirtualEnvs\project_name\Scripts\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'U:\\project_name\\package_name\\setup.py'"'"'; __file__='"'"'U:\\project_name\\package_name\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.
Code of Conduct
  • I agree to follow the PSF Code of Conduct

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the develop install using the reported pyproject.toml, setup.cfg, and setup.py layout on a Windows network drive with Python on C:. Start from the setup.py develop path-normalization failure and compare the paths with and without the trailing dot. Done means the editable install succeeds for the network-drive case without regressing the local-drive case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.