I have the following situation that pip install -e.
does not build the develop
version unless I delete the pyproject.toml
which does not contain packaging information, but black configuration.
Does somebody know what to do in order to get the develop
build.
my pyproject.toml
looks like this:
# Source https://github.com/psf/black#configuration-format
[tool.black]
line-length = 100
target-version = ['py38']
exclude = '''
'''
setup.py
from setuptools import find_namespace_packages
from setuptools import setup
setup(
name="webservice",
packages=find_namespace_packages(),
version="0.1.0",
description="description",
author="Author",
license="License",
)
running pip install -e.
with these two files...
(webservice_tool)pk@LAP1:~/webservice_tool$ pip install -e .
Obtaining file:///home/pk/webservice_tool
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: webservice
Building editable for webservice (pyproject.toml) ... done
Created wheel for webservice: filename=webservice-0.1.0-0.editable-py3-none-any.whl size=4070 sha256=dcb7c034ba437503d1059fe9370ccafbda144cd19f3e5d92340a63a7da396422
Stored in directory: /tmp/pip-ephem-wheel-cache-6iqiqbob/wheels/e6/b5/ba/40d8c3d66df94ee2ae46e181034e0c3c47132784db53284d0b
Successfully built webservice
Installing collected packages: webservice
Successfully installed webservice-0.1.0
I delete pyproject.toml
and only then Running setup.py develop
shows up.
(webservice_tool) pk@LAP1:~/webservice_tool$ pip install -e .
Obtaining file:///home/pk/webservice_tool
Preparing metadata (setup.py) ... done
Installing collected packages: webservice
Attempting uninstall: webservice
Found existing installation: webservice 0.1.0
Uninstalling webservice-0.1.0:
Successfully uninstalled webservice-0.1.0
Running setup.py develop for webservice
Successfully installed webservice-0.1.0
versions of some selected packages from my conda env, running within wsl2
packaging 21.3 pyhd3eb1b0_0
pip 22.1.2 py38h06a4308_0
python 3.8.13 h12debd9_0
setuptools 61.2.0 py38h06a4308_0
These are both development installs. The difference in the pip output here is because the presence (or absence) of a pyproject.toml
file causes pip to use the build backend hooks (or not). From PEP 517 :
If the
pyproject.toml
file is absent... the source tree is not using this specification, and tools should revert to the legacy behaviour of running setup.py
You can also control that with a pip command line option:
$ pip install --help | grep pep
--use-pep517 Use PEP 517 for building source distributions
(use --no-use-pep517 to force legacy behaviour).
The difference is that with a PEP 517 style build, pip is setting up a venv and freshly installing setuptools for the purposes of the package build behind the scenes (see "Installing build dependencies... done" in the log), versus invoking python setup.py develop
directly where it is just assumed that an adequate setuptools version is already installed in the Python runtime which you used to execute the setup.py
. The point here is that using a PEP 517 style build system allows the project to specify the setuptools version it requires (or, indeed, to use some other build system entirely).
For setuptools 61.2.20, the end result will be the same - a line will be added into the site-packages/easy-install.pth
path configuration file to expose the source code as a development installation.
As others have already said, both of these installs are editable. The difference in import behavior may be caused by the way an editable install is performed under the hood:
sys.path
;import util
works) setuptools
may choose a different technique based on configuration options and your project structure (supported since version 64.0.0 ):
setuptools
strives to find a balance between allowing the user to see the effects of project files being edited while still trying to keep the editable installation as similar as possible to a regular installation.
Note: You shouldn't do import util
from your package as this won't work when it will be installed regularly! Use import webservice.util
or from. import util
from. import util
instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.