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
upip numerical version extention #358
Conversation
Not tested in micropython but tested in python3.7 on a per-function basis. I have not tested the wildcard support however |
""" | ||
Parse Version | ||
|
||
This function takes a string and gets all versioning infromation for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
This function takes a string and gets all versioning infromation for | |
This function takes a string and gets all versioning information for |
|
||
def ver_list_cmp(list1, list2): | ||
""" | ||
version list compaire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version list compaire | |
version list compare |
This function takes a string and gets all versioning infromation for | ||
pypi according to PEP508 and PEP440 | ||
|
||
Written by: Stephan Kashkarov 2019 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attribution probably shouldn't be in a method; perhaps best to insert the common MIT header used in a lot of the MicroPython source - it can contain a list of contributors. See pyboard.py for an example.
returns -1 if list zero is larger and 1 list one is larger | ||
otherwise the function will return 0 | ||
|
||
Written by: Stephan Kashkarov 2019 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
@@ -243,6 +249,113 @@ def cleanup(): | |||
except OSError: | |||
print("Warning: Cannot delete " + fname) | |||
|
|||
def parse_version(string): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably have unit tests around this method. I may be able to help there...
Also, consider changing the variable string
since it's very generic. Perhaps version_string
?
I'll try and test this (on the unix and ESP32 ports) soon. I've also only had a superficial glance over the parsing logic; will try to understand it better.
pkg['version'] = max(versions) | ||
return pkg, data | ||
|
||
def ver_list_cmp(list1, list2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, unit testing this would be relatively straightforward and beneficial!
Also, I believe that if you used tuples then the built-in tuple comparisons will work correctly. Haven't yet validated that though...
@@ -268,7 +381,7 @@ def main(): | |||
help() | |||
return | |||
|
|||
if sys.argv[1] != "install": | |||
if sys.argv[1] not in ["install"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original is more readable. The 'not in' form is great for testing if an item is in a collection but that's not the case here.
Thanks @Stephan-kashkarov -- since this PR was raised, upip has been removed and replaced with mip which has much simpler handling of package versions. |
I have written the functionality to provide a numerical package version according to PEP508 and PEP440. I have not implemented letter based versioning systems such as >=1.2.5rc5 but versions can have infinite subversions. The implemented operators include >, >=, <, <=, ==, ~=, ===, !=. Extra arguments are dumped as I am unsure how meta tags for upython are handled, i.e.
upip install example;python_version<"2.7"
. Wildcard characters are also included. Thanks for looking at this pull request