Skip to content
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

[Fix] Package schema and request errors #658

Closed
wants to merge 3 commits into from
Closed

[Fix] Package schema and request errors #658

wants to merge 3 commits into from

Conversation

lambdaclan
Copy link
Contributor

@lambdaclan lambdaclan commented Jul 8, 2019

Description

[Depends on PR #602 #654 #656]

This PR has been extracted from #628 (a lot of the relevant discussion still lives there)

Package version schema and request errors

Breakdown

  • fix schema issue with packages including dashes for example importlib_metadata->=0.5

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Test Configuration:

  • Python version: 2.7.15, 2.7.16
  • OS: Linux, Windows 10
  • Toolchain: rez 2.33, pip 18.1, 19.1.1, distlib 0.2.9.post0

Todos

  • Tests

@@ -14,7 +14,7 @@
import time


PACKAGE_NAME_REGSTR = "[a-zA-Z_0-9](\.?[a-zA-Z0-9_]+)*"
PACKAGE_NAME_REGSTR = "[a-zA-Z_0-9](\.?[a-zA-Z0-9_-]+)*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I'm not quite clear on what's going on here.

The problem with this change is that in rez, - always separates the package name from its version. If a package name can contain hyphen, then which part is the name and which is the version becomes ambiguous.

Copy link
Contributor Author

@lambdaclan lambdaclan Jul 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Allan, yes this is true. This commit was from some time ago before I realized that rez uses dash to separate the package name from its version. After some tests it does not seem to be relevant to the SchemaError that occurs with some packages. It just happened to be a package with a dash in its name which is what made me think they are related.

I will revert this change and provide an example to the SchemaError.

Edit: Looking at the commit message for changing the REGEX I remembered that for whatever reason errors such as the one below used to occur

ERROR    PackageRequestError: Not a valid package name: u'import-class'.

This is from formatting.py

    is_valid = PACKAGE_NAME_REGEX.match(name)
    if raise_error and not is_valid:
        raise PackageRequestError("Not a valid package name: %r" % name)
    return is_valid

Not sure what could have possibly changed that is not triggering the issue anymore but I guess adding the dash to the REGEX is not the way to fix it. I will keep my eyes open and if it occurs again I will make a new post.

rez-pip -i import-class
11:40:04 INFO     Using pip-19.1.1 (/home/iakritas/packages/pip/19.1.1/package.py[0])
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting import-class
  Downloading https://files.pythonhosted.org/packages/14/b0/715a9ddb10f9da12abeebef28a3276ea29724e56ad8245e720ad99dca6d1/import_class-0.1.1-py2.py3-none-any.whl
Installing collected packages: import-class
Successfully installed import-class-0.1.1
11:40:06 DEBUG    Removed 1.0 due to Classifier
11:40:06 DEBUG    Found /tmp/pip-eH0KeY-rez/rez_staging/python/import_class-0.1.1.dist-info

1 packages were installed:
  import_class-0.1.1: /home/iakritas/packages/import_class/0.1.1/package.py (platform-linux/arch-x86_64/os-Arch-rolling/python-2.7)

@nerdvegas
Copy link
Contributor

I'm a little lost on this one - I've gone over the conversation history on #628 but I can't see how these changes relate.

Also might be good to re-merge with master now that #602 is merged, there are loads of diffs here that no longer apply and it's quite difficult to see which changes are specific to this PR.

Thx!
A

@lambdaclan
Copy link
Contributor Author

Re-merged as required!

@nerdvegas
Copy link
Contributor

nerdvegas commented Jul 11, 2019 via email

Fix the SchemaError "should be instance of" PackageRequest but
is None. This is occuring when the requires list includes None
and validation takes place.
Modify the allowed package name regex string to allow for packages
that include a dash in their names which is quite common for Python
packages. This eliminates issues like the one below:
ERROR    PackageRequestError: Not a valid package name: u'import-class'.
@nerdvegas
Copy link
Contributor

I'm pretty confident that #667 addresses this, so will close this PR when that is merged.

@nerdvegas nerdvegas added the ON HOLD Awaiting other tasks, or kept for reference only label Jul 20, 2019
@nerdvegas
Copy link
Contributor

Closing now, I'm certain that #667 fixes the issue, cheers

@nerdvegas nerdvegas closed this Jul 23, 2019
@lambdaclan lambdaclan deleted the fix/package-schema-request-errors branch April 6, 2020 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ON HOLD Awaiting other tasks, or kept for reference only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants