-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Editable installs are broken after __editable__
and __path_hook__
changes
#3548
Comments
This is likely because setuptools released a new mechanism for implementing editable installs, as part of their PEP600 support. The pdoc3 project is probably not yet aware of the new mechanism, and will need updating. There isn’t really anything for pip to do here, so I’m closing this issue. If it turns out that there is a pip problem here, feel free to reopen it. |
@pfmoore This is likely going to create a lot of havoc. Editable install is how people operate in Python community. And if all of a sudden, entire tooling around editable install is going to break, then likely we must be planning better around it. My 2 cents. May be, instead of enforcing the new mechanism as default, this could have been an opt in to start with. Instead of fighting this out, we decided to simply pin setuptools |
Please reach out to the setuptools maintainers. While various Python packaging tools do interoperate, the behaviour changes you’re seeing come from setuptools. The maintainers of pip don’t control / maintain setuptools, which is where I recommend you reach out. |
I can actually transfer the issue, so… here you go. :) |
Setuptools 64.0.0 introduced change that broke paths of editable cli packages. This change makes CLIs installed via editable packages to miss paths required to import code from the editable packages themselves. Related to: pypa/setuptools#3548
Setuptools 64.0.0 introduced change that broke paths of editable cli packages. This change makes CLIs installed via editable packages to miss paths required to import code from the editable packages themselves. Related to: pypa/setuptools#3548
It looks like we started to have the same problem in Airflow.
This started to happen few days ago and adding Airlfow's source to I did some bisecting and pin-pointed it to version 64.0.0 of setuptools. Version 63.4.3 worked perfectly fine, 64.0.0 breaks it. The reason seems to be as described in the issue. I've added those lines to our pyproject.toml and they solved the problem:
See: apache/airflow#25848 It is super-easy to reproduce now:
This works perfectly well (because of the 63.4.3 limit)
You see the stack-trace above |
(The error is also present in all other 64.* and 65* versions BTW). |
Hi @abhinavsingh, Could you provide a minimal reproducer explaining more in details the issues you are having? (Maybe it is worthy to split multiple issues in multiple reproducers). I tried to investigate what you are describing with the following reproducer, but I was not able to find the problematic behaviour you are referring to... (Maybe I understood something wrong? Or maybe the reproducer is missing something? Or -- best case scenario -- the problem might have already gotten solved in the latest release?). # docker run --rm -it python:3.10.6 bash
cd /tmp && rm -rf /tmp/proj_root
mkdir -p /tmp/proj_root
mkdir -p /tmp/proj_root/namespace/cli
echo "def run(): print('hello world')" > /tmp/proj_root/namespace/cli/__init__.py
cat <<EOF > /tmp/proj_root/pyproject.toml
[build-system]
requires = ["setuptools>=65.1.0"]
build-backend = "setuptools.build_meta"
[project]
name = "namespace.cli"
version = "42"
[project.scripts]
namespace-cli = "namespace.cli:run"
EOF
cd /tmp/proj_root
python3.10 -m venv .venv
.venv/bin/python -m pip install -U pip
.venv/bin/python -m pip install -e .
cd /var
/tmp/proj_root/.venv/bin/python -c 'import namespace; print(f"{namespace.__path__=}")'
# ==> namespace.__path__=_NamespacePath(['/tmp/proj_root/namespace'])
/tmp/proj_root/.venv/bin/namespace-cli
# ==> hello world As you can see above, the reproducer show that whenever possible There are a few other remarks I would like to make:
|
@potiuk I suspect airflow's use case is different. By having a look on the Setuptools's implementation of PEP 660 does not use the By running: # docker run --rm -it python:3.10.6 bash
apt update && apt install -y git build-essential
cd /tmp
git clone https://github.com/apache/airflow
cd /tmp/airflow
sed -i 's/==63.4.3/>=65.1.0/g' pyproject.toml
python -m venv .venv
.venv/bin/python -m pip install -U pip
.venv/bin/python -m pip install -e .
cd /var
/tmp/airflow/.venv/bin/python -c 'import airflow.settings; print(dir(airflow.settings))'
# ==> ['AIRFLOW_HOME', 'AIRFLOW_MOVED_TABLE_PREFIX', 'ALLOW_FUTURE_EXEC_DATES', 'CAN_FORK', 'CHECK_SLAS', 'COMPRESS_SERIALIZED_DAGS', 'Callable', 'DAEMON_UMASK', 'DAGS_FOLDER', 'DASHBOARD_UIALERTS', 'DEFAULT_ENGINE_ARGS', 'DONOT_MODIFY_HANDLERS', 'EXECUTE_TASKS_NEW_PYTHON_INTERPRETER', 'Engine', 'GUNICORN_WORKER_READY_PREFIX', 'HEADER', 'HIDE_SENSITIVE_VAR_CONN_FIELDS', 'IS_K8S_OR_K8SCELERY_EXECUTOR', 'KILOBYTE', 'LAZY_LOAD_PLUGINS', 'LAZY_LOAD_PROVIDERS', 'LOGGING_CLASS_PATH', 'LOGGING_LEVEL', 'LOG_FORMAT', 'List', 'MASK_SECRETS_IN_LOGS', 'MEGABYTE', 'MIN_SERIALIZED_DAG_FETCH_INTERVAL', 'MIN_SERIALIZED_DAG_UPDATE_INTERVAL', 'NullPool', 'Optional', 'PLUGINS_FOLDER', 'SASession', 'SIMPLE_LOG_FORMAT', 'SQL_ALCHEMY_CONN', 'STATE_COLORS', 'TIMEZONE', 'TYPE_CHECKING', 'USE_JOB_SCHEDULE', 'Union', 'WEBSERVER_CONFIG', 'WEB_COLORS', '__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_get_rich_console', 'atexit', 'conf', 'configure_action_logging', 'configure_adapters', 'configure_logging', 'configure_orm', 'configure_vars', 'create_engine', 'custom_show_warning', 'dag_policy', 'dispose_orm', 'exc', 'executor_constants', 'functools', 'get_airflow_context_vars', 'get_dagbag_import_timeout', 'get_session_lifetime_config', 'import_local_settings', 'initialize', 'json', 'log', 'logging', 'original_show_warning', 'os', 'pendulum', 'pod_mutation_hook', 'prepare_engine_args', 'prepare_syspath', 'reconfigure_orm', 'replace_showwarning', 'scoped_session', 'sessionmaker', 'setup_event_handlers', 'sqlalchemy', 'sys', 'task_instance_mutation_hook', 'task_policy', 'tz', 'validate_session', 'warnings'] I can see that the package is indeed installed in the editable mode, however the Footnotes
|
Thanks for the pointer @abravalheri . I will take a closer look and see if I can work it out. I was kinda suspecting that we could have been doing something that PEP 660 does not really like :). I will keep you posted. |
Time to do some more deep PEP reading |
@potiuk Hey! Airflow's |
(Copying some opinion from the PyPA discord for eventual readers of this thread).
|
@ofek Airlfow is an ASF project and community makes decisions not me personally. If you want to make a POC and have some good arguments, you will have to start dicsussion at the airflow devlist https://airflow.apache.org/community/ . But you have to - in general - have a good reasoning and justification for such a change in build system. just fixing an error that we can fix without switching to another build mechanism is not good enough reason. |
This comment was marked as resolved.
This comment was marked as resolved.
Hi @lonetwin, Based on this comment I would say that (so far) the stdlib developers have no intention the increase the scope or add features to If you absolutely need to use |
In the spirit of over-communicating: I'm unsubscribing from this since I don't think there's anything for me to do here. To the maintainers, please feel free to @-mention me in case there's something here that's on pip's end. |
@abravalheri Apologies, haven't checked back on GitHub in weeks. Missed your message altogether. A point to note in our case is that, we have all our packages under a namespace. As others have figured, v64 is an issue. At our end, I had to pin setup tools to v62 to let our company workflows pass. In our setup, we simply go by paths returned by I am not on my work system today. But, I'll give you a reproducible scenario as soon as I get to my system. We surely don't want to pin ourself to v62 forever. |
* this allows `pip install -e .` to produce a working editable install locally * the basis for the `setuptools` pin here is based on reading through pypa/setuptools#3548; in short, looks like a behavior change in `setuptools` so let's just pin it for now * since this only affects Python developers for our project I've not added any "regression test"/"CI test" for it, but feel free to add one editable job to the CI if you want
* Fixed a bug in over_approximation of RepeatSurface * Only generate docs for one python version * Workaround for pypa/setuptools/issues/3548 --------- Co-authored-by: Gus Hahn-Powell <gushahnpowell@gmail.com>
* Fixed a bug in over_approximation of RepeatSurface * Only generate docs for one python version * Workaround for pypa/setuptools/issues/3548 --------- Co-authored-by: Gus Hahn-Powell <gushahnpowell@gmail.com> 496c190
* this allows `pip install -e .` to produce a working editable install locally * the basis for the `setuptools` pin here is based on reading through pypa/setuptools#3548; in short, looks like a behavior change in `setuptools` so let's just pin it for now * since this only affects Python developers for our project I've not added any "regression test"/"CI test" for it, but feel free to add one editable job to the CI if you want
I'm running into a related issue, where after installing I can pin setuptools 65 but this seems like a bug on your side. |
Have you tried Hatchling? |
@abravalheri I apologise for missing out on it. I checked our codebase today and we are still using I really want to get past this pinned setuptools issue in our codebase. Will investigate back into it over the coming weekend and come up with a minimal example to reproduce the issue at your end. |
hi team, just checking my luck, by any chance, do we have an update on this issue? I am still facing issues with editable installs in a local virtualenv for Apache Airflow. |
Hi @pankajkoti to keep investigating this issue we need a reproducer of the original problem. I reported some thoughts in #3548 (comment) (please note the remarks about entries in |
Hi @kptkin, in our docs we list the limitation of coinciding names of file entries in the working directory. If you need to support that use case you can try other installation modes, e.g. |
Ah thanks for the reply! Yeah, I found this exact flag in the docs, good to have a verification that this is the recommended approach and it won't be something that is/should be fixed. |
Just ran into this issue after updating to python 3.12, should I just revert to 3.11 and wait or is there a different approach I should take? |
If you're affected by this issue to the point where even pip install -e . --config-settings editable_mode=compat This is not a long term solution. If any of your tools requires |
@HexDecimal What if it's our tool having the issue? How should it be updated to conform to editable installs in python 3.12? |
This issue is not caused by your Python version. It is caused by installing setuptools packages in editable mode using the latest version of setuptools. I've only experienced this issue from the perspective of a tool user (VSCode/Pylance) so I'm not sure what to do on the development side. |
See pypa/setuptools#3548. The dynamic finder meta-path mechanism seems not to take precedence over the nix.pth file, though I am not sure what the correct long-term fix should be.
- Fixes issues with editable builds, [broken by new versions of setuptools](pypa/setuptools#3548) - Migrates project to `pyproject.toml`, [as recommended](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/)
- Fixes issues with editable builds, [broken by new versions of setuptools](pypa/setuptools#3548) - Migrates project to `pyproject.toml`, [as recommended](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/)
- Fixes issues with editable builds, [broken by new versions of setuptools](pypa/setuptools#3548) - Migrates project to `pyproject.toml`, [as recommended](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/)
* Migrate from setuptools to hatch - Fixes issues with editable builds, [broken by new versions of setuptools](pypa/setuptools#3548) - Migrates project to `pyproject.toml`, [as recommended](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/) * Move some configuration from setup.cfg to pyproject.toml * Don't install setuptools on CI - Not required anymore * Move configuration to pyproject.toml * Move more configuration to pyproject.toml * Rename some minor fields * Use Python 3.12 to publish the package --------- Co-authored-by: Uxio Fuentefria <6909403+Uxio0@users.noreply.github.com>
Description
I am starting to observe broken editable installs since past week.
Specifically, editable install now creates a
__editable__.<pkg>.pth
and__editable___<pkg>_finder.py
files. These paths are returned as part ofnamespace.__path__
, which has broken a lot of tooling.pdoc3
went broke. Skipping__editable__
package seems to fix (hack) it.__editable__
paths duringiter_modules
pdoc3/pdoc#408.venv/bin
, it is unable to import the modules since it was installed using-e
.PYTHONPATH
is the only option."python.analysis.extraPaths"
to.vscode/settings.json
is the way outI was unable to find any search result on Google for
__editable__
and__path_hook__
. So, I am unsure what I am up against here.Expected behavior
PYTHONPATH
namespace.__path__
must return actual path instead of__editable__.*
which seems to break a lot of existing toolingpip version
22.2.2
Python version
3.10.5
OS
MacOS 12.5
How to Reproduce
-e
PYTHONPATH
Our projects are using
pyproject.toml
andsetup.cfg
.Output
`ImportError: cannot import name 'entry_point' from 'namespace.cli' (unknown location)`
Code of Conduct
The text was updated successfully, but these errors were encountered: