Closed Neradoc closed 2 years ago
I ran into not being able to use pip3 install -e
when considering a switch to pyproject.toml
some time ago. The blockers seemed to be more than the version number: https://stackoverflow.com/questions/69711606/how-to-install-a-package-using-pip-in-editable-mode-with-pyproject-toml. I also see this: https://github.com/pypa/pip/issues/6375. So I'm not sure that's the only problem.
This is all really confusing because package management has been changing so much. Many websearch results contain discussions that are obsolete.
I was testing the neopixel library locally and after changing the version in pyproject.toml
I was able to install it in editable mode. I was only testing the install on a Pi 3, so I didn't go further than import neopixel
, but that worked so far.
(I think I should tag you @tekktrik if you don't mind)
Here is a test with a randomly selected library (it works after updating pip).
(venv-test) pi@circuit-pi ~/circuit $ pip list
Package Version
------------------------------ -----------------------------
click 8.0.1
click-aliases 1.0.1
discotool-for-microcontrollers 0.1.2.dev0+g8be5608.d20210723
importlib-metadata 4.6.1
pip 18.1
pkg-resources 0.0.0
psutil 5.8.0
pyserial 3.5
pyudev 0.22.0
setuptools 40.8.0
six 1.16.0
typing-extensions 3.10.0.0
zipp 3.5.0
(venv-test) pi@circuit-pi ~/circuit $ git clone https://github.com/adafruit/Adafruit_CircuitPython_LIS3MDL
[...]
(venv-test) pi@circuit-pi ~/circuit $ cd Adafruit_CircuitPython_LIS3MDL/
(venv-test) pi@circuit-pi ~/circuit/Adafruit_CircuitPython_LIS3MDL $ pip install -e .
Directory '.' is not installable. File 'setup.py' not found.
(venv-test) pi@circuit-pi ~/circuit/Adafruit_CircuitPython_LIS3MDL $ pip install -U pip
[...]
(venv-test) pi@circuit-pi ~/circuit/Adafruit_CircuitPython_LIS3MDL $ pip install -e .
[...]
configuration error: `project.version` must be pep440
[...]
(venv-test) pi@circuit-pi ~/circuit/Adafruit_CircuitPython_LIS3MDL $ nano pyproject.toml
[... edit the version to 0.0.0+auto.0 ...]
(venv-test) pi@circuit-pi ~/circuit/Adafruit_CircuitPython_LIS3MDL $ pip install -e .
[...]
Successfully installed Adafruit-Blinka-8.2.0 Adafruit-PlatformDetect-3.27.0 Adafruit-PureIO-1.1.9 RPi.GPIO-0.7.1 adafruit-circuitpython-busdevice-5.2.1 adafruit-circuitpython-lis3mdl-0.0.0+auto.0 adafruit-circuitpython-register-1.9.11 adafruit-circuitpython-typing-1.7.2 pyftdi-0.54.0 pyusb-1.2.1 rpi-ws281x-4.3.4 sysv-ipc-1.1.0
(venv-test) pi@circuit-pi ~/circuit/Adafruit_CircuitPython_LIS3MDL $ python
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import adafruit_lis3mdl
>>>
My understanding is also that editable installs are not currently supported (always? I share Dan's frustrations with search results) with pyproject.toml
if setuptools
is the backend and we're using pip install -e .
I think this may change if something like flit
is used, or another backend besides setuptools
is used in the build backend. The build backend gets downloaded upon pip install from PyPI, so if editable installs are used widely during development, I think it's worth exploring. I'll double check the documentation again, but those were my learnings during research ahead of time, I think.
It's worth mentioning that 0.0.0-auto.0
is an arbitrary string that the CI replaces later. We could use something like 0.0.0
or 0.0.0.0
and have the CI replace that instead, and that should be PEP 440 compliant.
I'd be up for using 0.0.0+auto.0
. The only places it would get changed are pyproject.toml
and __versions__
attributes, but the string should be easy to replace with bash commands so I'm in favor of a patch if others are!
Anything that allows pip install -e
would be great, so a patch is fine. It could stand alone or we could wait a bit to see if there's any patch that comes up you want to make to the new pyproject.toml
files.
Changing it is fine with me too.
Anything that allows
pip install -e
would be great, so a patch is fine. It could stand alone or we could wait a bit to see if there's any patch that comes up you want to make to the newpyproject.toml
files.
There is! Nothing functional, but I added some instructional comments to the cookiecutter, so adding those to the libraries means they'll all be consistent. I can wrap it into one patch!
@Neradoc I think with the patch and addition to the cookiecutter this is resolved, correct?
Yup ! Thanks all !
When I try to install a library using pyproject.toml in editable mode:
I get this error:
So it demands a pep440 formatted version string, which
0.0.0-auto.0
is not. On the other hand0.0.0+auto.0
is, and there are other alternatives we could use. Unless there is a way to relax the format rule without breaking pip, the build tools could be made to accept both formats and the libraries could be updated afterwards. Are there other places where0.0.0-auto.0
is expected ?Installing in editable mode is a useful tool for working on a library in blinka, it would be nice if it was supported.