simion / pip-upgrader

An interactive pip requirements upgrader. It also updates the version in your requirements.txt file.
Apache License 2.0
522 stars 38 forks source link

Not looking at pip.conf when doing the upgrade check? #1

Closed jhermann closed 7 years ago

jhermann commented 7 years ago

Given my first tests, you don't support ~/.pip/pip.conf when doing the version checks, specifically its index-url setting – that in turn prevents the use of local PyPI caches (e.g. devpi).

simion commented 7 years ago

Indeed, I don't check nor support local caches at the moment. The package checks pypi rest api for available upgrades.

This requires quite some implementation, if I will have some time to implement it, I'll let you know. Meanwhile, merge requests are welcome. Just announce if you start working on some feature so we don't both work on the same functionality. Thanks 😉

jhermann commented 7 years ago

What I target is taht you change the PyPI URL from the default to some other URL – same API, just another end-point. Needs reading the INI file, and overriding the default URL when set.

simion commented 7 years ago

I see. Can you paste the contents of the file, so i can know how to parse it? Also, any other possible alternative paths for that ini file.

I will fix it today if you send me the required info.

jhermann commented 7 years ago
$ pip install -h | grep .-i,.--index-url
  -i, --index-url <url>       Base URL of Python Package Index (default http://localhost:3141/local/dev/+simple/). This should point

The possibly best way to handle this is to import pip and then to follow the code path the "help" code uses to display that default – then this is always compatible to what pip does.

simion commented 7 years ago

Yeah, I'm following the code path to read configs. The way they parse values is very strange. Instead, there is this list: pip.locations.site_config_files.

on MacOs:

In [13]: pip.locations.site_config_files
Out[13]: ['/Library/Application Support/pip/pip.conf']

on Linux:

In [2]: pip.locations.site_config_files
Out[2]: ['/etc/xdg/pip/pip.conf', '/etc/pip.conf']

It does not seem to search in homedir. I'll create a predefined list of config locations based on their docs, and add the ones imported from pip. And parse them using ConfigParser.

Please paste here your index-url= setting and also the full json path for a package. Ex: https://pypi.python.org/pypi/requests/json

The implementation is almost done, just checking that index-url parsing is done correctly.

simion commented 7 years ago

Can you test master branch for index-url detection? Clone and pip install -e .

simion commented 7 years ago

I released new version on pip. I hope the URL you have in config is parsed.

jhermann commented 7 years ago

Testing against Artifactory

I'll try devpi during the weekend…

simion commented 7 years ago

@jhermann I'll check canonicalize_name. This would be a correct example of plain html package page?

https://pypi.python.org/simple/django/

If so, parsing it should be quite simple.

simion commented 7 years ago

@jhermann If the index-url ends with /simple, (ex: https://repo.local/artifactory/api/pypi/local/simple the html url for a package would be https://repo.local/artifactory/api/pypi/local/simple/django (and django canonicalized. Is this correct?

jhermann commented 7 years ago

Yes, what you get is a HTML page consisting mostly of "a href" references to the different package types (whl, zip, …) and versions. Supporting that original "simple" scheme depends on parsing the file names, and might be fragile (check the pip code on how many edge cases there actually are). Maybe "packaging" has some support code for that.

Another option is to add "…/json" to Artifactory, do you happen to have a PEP link or something similar for that?

jhermann commented 7 years ago

Regarding devpi support, this is a simple index example: https://devpi.net/hpk/dev/+simple/tox

Not sure if it supports the JSON API (example: tox). @hpk42 ?

simion commented 7 years ago

The examples are good enough. I'll implement them tomorrow. On Sun, 30 Apr 2017 at 16:52, Jürgen Hermann notifications@github.com wrote:

Regarding devpi support, this is a simple index example: https://devpi.net/hpk/dev/+simple/tox

Not sure if it supports the JSON API (example: tox https://pypi.python.org/pypi/tox/json). @hpk42 https://github.com/hpk42 ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/simion/pip-upgrader/issues/1#issuecomment-298233640, or mute the thread https://github.com/notifications/unsubscribe-auth/ACgkjfD4h3L3I8kEaFHr9M1KAmyUtRsGks5r1JI0gaJpZM4NKFpb .

simion commented 7 years ago

Done in https://github.com/simion/pip-upgrader/commit/259346f2634e75e2a9414a5a5cb87908738960f3, you can test it with pip install pip-upgrader==1.4.dev1.

The simple html parsing is quite generic, and it will be applied to index-url which ends with .../simple or .../+simple.

simion commented 7 years ago

@jhermann can you confirm it works please?

simion commented 7 years ago

@jhermann bump

jhermann commented 7 years ago

Works with devpi, trying with Artifactory tomorrow.

simion commented 7 years ago

Cool 😉

jhermann commented 7 years ago

As expected, Artifactory works too.

One minor addition left: please look at the PIP_INDEX_URL env var before checking the config, if that's non-empty, use it. Besides other issues, that makes testing a lot easier.

simion commented 7 years ago

Implemented support for PIP_INDEX_URL environment varibale, and release 1.4.0. Have fun 😉