"Can't get a consistent path to setup script from installation directory"
Question:
I’m using pip to install a package from a git repository:
pip install -e git+git://github.com/knipknap/SpiffWorkflow.git@master#egg=SpiffWorkflow-dev
The repo gets cloned without a problem, but installation fails with this message:
Running setup.py egg_info for package SpiffWorkflow
Installing collected packages: SpiffWorkflow
Running setup.py develop for SpiffWorkflow
error: ("Can't get a consistent path to setup script from installation
directory", '/', '/home/fcorreia/venvs/myproj/src/spiffworkflow')
I have tried taking a look to the project’s setup.py, but without much success… Any idea?
Answers:
It is because the flag -e
means “editable”, and it is the same doing python setup.py develop
, that creates a symbolic link from <PACKAGE_NAME_LOWERCASE>
to your site-packages
directory and not running an usual installation.
Looking at SpiffWorkflow’s setup.py
I can see where the problem relies:
srcdir = join(dirname(__file__), 'src')
setup(...,
package_dir = {'': srcdir})
It says that the package content is located at src
, instead of spiffworkflow
(what develop mode expects).
You can just drop the -e
flag and be happy:
pip install git+git://github.com/knipknap/SpiffWorkflow.git@master#egg=SpiffWorkflow-dev
References:
You need to have a pyproject.toml
file in your package. I have no idea why this makes the error go away, but it works. This file is part of PEP 518 “Specifying Minimum Build System Requirements for Python Projects”.
You can have your package in a src
subfolder if you have a pyproject.toml
in your project:
/src/yourpackage/__init__.py
/setup.py
/pyproject.toml
I have no idea why this works, but it makes the error message go away when you run pip install -e .
to install the package in “editable” mode. The file doesn’t even have to have anything in it, it can be a blank file and the error goes away.
(To figure this out, I found a working project that had its package stored under a src
folder and kept deleting things until I got that error. This is clearly some bug in Pip. I have version 18.1 on Windows 10 for Python 3.7 on my machine.)
For future folk, if you’re using an older version of setuptools on windows 10 and it looks like it has an extra slash, you need to update the python package ‘setuptools’ to get around this windows 10 python bug
you can update any number of ways, but one is python -m pip install --upgrade setuptools
In my case problem was with package_dir = {'': './src'}
: I have specified path to dir, rather than dir name, which for some reason worked fine with setup.py bdist_wheel
.
I had the followng structure for my project:
+-- project/
+-- src/
| +-- project/
| +-- __init__.py
+-- doc/
+-- tests/
+-- setup.py
+-- ...
So basically, all python code in /src/project
. This permits to avoid project
to be directly imported from tests scripts or whatever.
setup.py
content:
setuptools.setup(
...
packages=setuptools.find_packages('src'),
package_dir={'': 'src'},
...
)
Now I want to pull all this one level below, so that the overall project can have different components, as follows:
+-- project/
+-- backend/
| +-- src/
| +-- project/
| +-- __init__.py
|
+-- frontend/
| +-- ...
|
+-- doc/
+-- tests/
+-- setup.py
+-- ...
So I got the error message as in OP when trying to pip install -e .
, even after trying to fix all paths.
I solved it by following update in setup.py
:
setuptools.setup(
...
packages=setuptools.find_packages('backend/src'),
package_dir={'': 'backend/src'},
...
)
Hope this helps!
In my cases, https://github.com/quiver-team/torch-quiver/blob/main/setup.py
I remove the ./
chars from the beginning of my package dir configuration.
# package_dir = './srcs/python'
package_dir = 'srcs/python'
And I install it successfully.
refer to https://github.com/pypa/setuptools/discussions/3755
I’m using pip to install a package from a git repository:
pip install -e git+git://github.com/knipknap/SpiffWorkflow.git@master#egg=SpiffWorkflow-dev
The repo gets cloned without a problem, but installation fails with this message:
Running setup.py egg_info for package SpiffWorkflow
Installing collected packages: SpiffWorkflow
Running setup.py develop for SpiffWorkflow
error: ("Can't get a consistent path to setup script from installation
directory", '/', '/home/fcorreia/venvs/myproj/src/spiffworkflow')
I have tried taking a look to the project’s setup.py, but without much success… Any idea?
It is because the flag -e
means “editable”, and it is the same doing python setup.py develop
, that creates a symbolic link from <PACKAGE_NAME_LOWERCASE>
to your site-packages
directory and not running an usual installation.
Looking at SpiffWorkflow’s setup.py
I can see where the problem relies:
srcdir = join(dirname(__file__), 'src')
setup(...,
package_dir = {'': srcdir})
It says that the package content is located at src
, instead of spiffworkflow
(what develop mode expects).
You can just drop the -e
flag and be happy:
pip install git+git://github.com/knipknap/SpiffWorkflow.git@master#egg=SpiffWorkflow-dev
References:
You need to have a pyproject.toml
file in your package. I have no idea why this makes the error go away, but it works. This file is part of PEP 518 “Specifying Minimum Build System Requirements for Python Projects”.
You can have your package in a src
subfolder if you have a pyproject.toml
in your project:
/src/yourpackage/__init__.py
/setup.py
/pyproject.toml
I have no idea why this works, but it makes the error message go away when you run pip install -e .
to install the package in “editable” mode. The file doesn’t even have to have anything in it, it can be a blank file and the error goes away.
(To figure this out, I found a working project that had its package stored under a src
folder and kept deleting things until I got that error. This is clearly some bug in Pip. I have version 18.1 on Windows 10 for Python 3.7 on my machine.)
For future folk, if you’re using an older version of setuptools on windows 10 and it looks like it has an extra slash, you need to update the python package ‘setuptools’ to get around this windows 10 python bug
you can update any number of ways, but one is python -m pip install --upgrade setuptools
In my case problem was with package_dir = {'': './src'}
: I have specified path to dir, rather than dir name, which for some reason worked fine with setup.py bdist_wheel
.
I had the followng structure for my project:
+-- project/
+-- src/
| +-- project/
| +-- __init__.py
+-- doc/
+-- tests/
+-- setup.py
+-- ...
So basically, all python code in /src/project
. This permits to avoid project
to be directly imported from tests scripts or whatever.
setup.py
content:
setuptools.setup(
...
packages=setuptools.find_packages('src'),
package_dir={'': 'src'},
...
)
Now I want to pull all this one level below, so that the overall project can have different components, as follows:
+-- project/
+-- backend/
| +-- src/
| +-- project/
| +-- __init__.py
|
+-- frontend/
| +-- ...
|
+-- doc/
+-- tests/
+-- setup.py
+-- ...
So I got the error message as in OP when trying to pip install -e .
, even after trying to fix all paths.
I solved it by following update in setup.py
:
setuptools.setup(
...
packages=setuptools.find_packages('backend/src'),
package_dir={'': 'backend/src'},
...
)
Hope this helps!
In my cases, https://github.com/quiver-team/torch-quiver/blob/main/setup.py
I remove the ./
chars from the beginning of my package dir configuration.
# package_dir = './srcs/python'
package_dir = 'srcs/python'
And I install it successfully.
refer to https://github.com/pypa/setuptools/discussions/3755