Skip to content

Switch from using 0.0.0-auto.0 to pep440 ? #91

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

Closed
Neradoc opened this issue Aug 14, 2022 · 9 comments
Closed

Switch from using 0.0.0-auto.0 to pep440 ? #91

Neradoc opened this issue Aug 14, 2022 · 9 comments

Comments

@Neradoc
Copy link
Contributor

Neradoc commented Aug 14, 2022

When I try to install a library using pyproject.toml in editable mode:

pip install -e .

I get this error:

[…]
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [48 lines of output]
      /private/var/folders/47/m_w7xs510pn0v97qjffgh_fm0000gn/T/pip-build-env-8taqdg7m/overlay/lib/python3.9/site-packages/setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
        warnings.warn(msg, _BetaConfiguration)
      configuration error: `project.version` must be pep440
      DESCRIPTION:
          The version of the project as supported by :pep:`440`.
      
      GIVEN VALUE:
          "0.0.0-auto.0"
      
      OFFENDING RULE: 'format'
      
      DEFINITION:
          {
              "type": "string",
              "format": "pep440"
          }
[…]

So it demands a pep440 formatted version string, which 0.0.0-auto.0 is not.
On the other hand 0.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 where 0.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.

@dhalbert
Copy link
Contributor

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: pypa/pip#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.

@Neradoc
Copy link
Contributor Author

Neradoc commented Aug 15, 2022

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 only had to upgrade pip to latest (from 18 on the Pi or 21 on the mac to 22.2.2).
  • Our pyprojects use setuptools, but the Pi has 40.* and gave me no issue, installed the requirements and all.
    (the stackoverflow link mentions version 64, current is 65, so a recent one), but

(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
>>> 

@tekktrik
Copy link
Member

tekktrik commented Aug 15, 2022

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.

@tekktrik
Copy link
Member

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!

@dhalbert
Copy link
Contributor

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.

@tannewt
Copy link
Member

tannewt commented Aug 15, 2022

Changing it is fine with me too.

@tekktrik
Copy link
Member

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.

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!

@tekktrik
Copy link
Member

@Neradoc I think with the patch and addition to the cookiecutter this is resolved, correct?

@Neradoc
Copy link
Contributor Author

Neradoc commented Aug 22, 2022

Yup ! Thanks all !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants