-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Needs TriageIssues that need to be evaluated for severity and status.Issues that need to be evaluated for severity and status.bug
Description
setuptools version
setuptools==68.0.0
Python version
Python 3.10.12
OS
macOS
Additional environment information
I believe this is only a problem on macOS because of its case-preserving but case-insensitive filesytem. I'm not too familiar with filesystems but it may be a problem on others. See also PEP 235 - Import on Case-Insensitive Platforms.
I think this also depends on exactly how it is installed, but I'm not familiar with what determines which editable installation method is used.
Description
I have a project with the following structure:
├── pyproject.toml
├── setup.cfg
└── setuptools_editable_case_insensitive
├── __init__.py
└── module_1.py
When the package is installed as editable, I am able to import module_1
with arbitrary case:
>>> from setuptools_editable_case_insensitive import module_1
>>> from setuptools_editable_case_insensitive import MODULE_1
>>> import setuptools_editable_case_insensitive.Module_1
Expected behavior
I expected to get an ImportError
when importing a module with incorrect case, as is the behavior when installed normally:
>>> from setuptools_editable_case_insensitive import Module_1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Module_1' from 'setuptools_editable_case_insensitive' (/Users/aandersoniii/src/setuptools-example/setuptools_editable_case_insensitive/__init__.py)
How to Reproduce
- Clone this simplified example:
git clone [email protected]:aganders3/setuptools-editable-case-insensitive.git
- Create a virtual environment:
cd setuptools-editable-case-insensitive && python3.10 -m venv venv && source venv/bin/activate
- Install the project as editable:
pip install -e .
- Run the test script:
python test_imports.py
- Note
module_1
is successfully imported with arbitrary case
Output
❯ git clone [email protected]:aganders3/setuptools-editable-case-insensitive.git
Cloning into 'setuptools-editable-case-insensitive'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 7 (delta 0), reused 7 (delta 0), pack-reused 0
Receiving objects: 100% (7/7), done.
❯ cd setuptools-editable-case-insensitive && python3.10 -m venv venv && source venv/bin/activate
❯ pip install -e .
Obtaining file:///Users/aandersoniii/src/setuptools-editable-case-insensitive
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Installing backend dependencies ... done
Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: setuptools-editable-case-insensitive
Building editable for setuptools-editable-case-insensitive (pyproject.toml) ... done
Created wheel for setuptools-editable-case-insensitive: filename=setuptools_editable_case_insensitive-0.0.0-0.editable-py3-none-any.whl size=2787 sha256=580be31a2260f44e9e877f905ac5875526d31d0f46a433eb72b9103b55f7cb31
Stored in directory: /private/var/folders/dd/w2cggkp91dq_xn53d6fphp8c0000gq/T/pip-ephem-wheel-cache-ik0hfo9g/wheels/a7/9d/6e/26a7dd6200d0678dcfb12a1d9447413c2a95d67d6a00fefc74
Successfully built setuptools-editable-case-insensitive
Installing collected packages: setuptools-editable-case-insensitive
Successfully installed setuptools-editable-case-insensitive-0.0.0
❯ python test_imports.py
Hello from setuptools_editable_case_insensitive.module_1!
Hooray, I was imported with the correct name!
__name__='setuptools_editable_case_insensitive.module_1'
__file__='/Users/aandersoniii/src/setuptools-editable-case-insensitive/setuptools_editable_case_insensitive/module_1.py'
Hello from setuptools_editable_case_insensitive.Module_1!
Oh no, I was imported with the wrong name!
__name__='setuptools_editable_case_insensitive.Module_1'
__file__='/Users/aandersoniii/src/setuptools-editable-case-insensitive/setuptools_editable_case_insensitive/Module_1.py'
Metadata
Metadata
Assignees
Labels
Needs TriageIssues that need to be evaluated for severity and status.Issues that need to be evaluated for severity and status.bug