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

--extra-index flag throws error #314

Closed
matteosantama opened this issue Mar 14, 2021 · 5 comments · Fixed by #315
Closed

--extra-index flag throws error #314

matteosantama opened this issue Mar 14, 2021 · 5 comments · Fixed by #315

Comments

@matteosantama
Copy link
Contributor

matteosantama commented Mar 14, 2021

My CI starts to fail if I bump nox-poetry from 0.8.1 to 0.8.2 with the following error

...
 File "/usr/local/lib/python3.8/site-packages/nox_poetry/sessions.py", line 209, in export_requirements
    constraints = to_constraints(self.poetry.export())
  File "/usr/local/lib/python3.8/site-packages/nox_poetry/sessions.py", line 88, in to_constraints
    return "\n".join(_to_constraints())
  File "/usr/local/lib/python3.8/site-packages/nox_poetry/sessions.py", line 84, in _to_constraints
    constraint = to_constraint(requirement, line)
  File "/usr/local/lib/python3.8/site-packages/nox_poetry/sessions.py", line 69, in to_constraint
    raise RuntimeError(f"line {line}: {requirement_string!r}: {error}")
RuntimeError: line 1: '--extra-index-url https://gitlab.com/api/v4/projects/20895990/packages/pypi/simple': 
Parse error at "'--extra-'": Expected W:(abcd...)

@cjolowicz
Copy link
Owner

cjolowicz commented Mar 14, 2021

Thanks for reporting!

We should ignore requirement lines starting with ˋ-ˋ as it is not a valid way to start a package name, and must be a pip option. The function is ˋto_constraintˋ in the sessions module of you're interested in submitting a PR.

@cjolowicz
Copy link
Owner

@matteosantama A fix was released in 0.8.3, can you try?

@RomainBrault
Copy link

RomainBrault commented Mar 14, 2021

Thanks @cjolowicz your patch sloved part of my error I get since updating from 8.1 to 8.2.

I think this is related to the extra url I am setting:

[[tool.poetry.source]]
name = "default"
url = "{{cookiecutter.pip_index_url}}"
secondary = false

Here is a log

nox > Running session pre-commit                                                                                                                                                                                   
nox > Creating virtual environment (virtualenv) using python3.9 in .cache/pre-commit                                                                                                                               
nox > poetry build --format=wheel                                                                                                                                                                                  
nox > poetry export --format=requirements.txt --dev --without-hashes                                                                                                                                               
nox > Session pre-commit raised exception RuntimeError('line 2: \'\': Parse error at "\'\'": Expected W:(abcd...)')                                                                                                
Traceback (most recent call last):                                                                                                                                                                                 
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/packaging/requirements.py", line 113, in __init__                                                                                        
    req = REQUIREMENT.parseString(requirement_string)                                                                                                                                                              
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/pyparsing.py", line 1955, in parseString                                                                                                 
    raise exc                                                                                                                                                                                                      
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/pyparsing.py", line 3250, in parseImpl                                                                                                   
    raise ParseException(instring, loc, self.errmsg, self)                                                                                                                                                         
pyparsing.ParseException: Expected W:(abcd...)  (at char 0), (line:1, col:1)                                                                                                                                       
                                                                                                                                                                                                                   
During handling of the above exception, another exception occurred:                                                                                                                                                
                                                                                                                                                                                                                   
Traceback (most recent call last):                                                                                                                                                                                 
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/nox_poetry/sessions.py", line 67, in to_constraint                                                                                       
    requirement = Requirement(requirement_string)                                                                                                                                                                  
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/packaging/requirements.py", line 115, in __init__                                                                                        
    raise InvalidRequirement(                                                                                                                                                                                      
packaging.requirements.InvalidRequirement: Parse error at "''": Expected W:(abcd...)                                                                                                                               
                                                                                                                                                                                                                   
During handling of the above exception, another exception occurred:                                                                                                                                                
                                                                                                                                                                                                                   
Traceback (most recent call last):                                                                                                                                                                                 
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/nox/sessions.py", line 549, in execute                                                                                                   
    self.func(session)                                                                                                                                                                                             
  File "xxx/ppt/.cache/tests-3-9/lib/python3.9/site-packages/nox/_decorators.py", line 53, in __call__                                                                                                
    return self.func(*args, **kwargs)                                                                                                                                                                              
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/nox_poetry/sessions.py", line 42, in wrapper                                                                                             
    function(proxy, *_args, **_kwargs)                                                                                                                                                                             
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/typeguard/__init__.py", line 912, in wrapper                                                                                             
    retval = func(*args, **kwargs)                                                                                                                                                                                 
  File "xxx/pytest-35/test_bake_project_tiss_inner_o0/cookies/bake00/Awesome Thales Project/noxfile.py", line 225, in precommit                                                                  
    session.poetry.installroot(distribution_format=nox_poetry.WHEEL)                                                                                                                                               
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/nox_poetry/sessions.py", line 170, in installroot                                                                                        
    requirements = self.export_requirements()                                                                                                                                                                      
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/nox_poetry/sessions.py", line 209, in export_requirements                                                                                
    constraints = to_constraints(self.poetry.export())                                                                                                                                                             
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/nox_poetry/sessions.py", line 88, in to_constraints                                                                                      
    return "\n".join(_to_constraints())                                                                                                                                                                            
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/nox_poetry/sessions.py", line 84, in _to_constraints                                                                                     
    constraint = to_constraint(requirement, line)                                                                                                                                                                  
  File "xxx/.cache/tests-3-9/lib/python3.9/site-packages/nox_poetry/sessions.py", line 69, in to_constraint                                                                                       
    raise RuntimeError(f"line {line}: {requirement_string!r}: {error}")                                                                                                                                            
RuntimeError: line 2: '': Parse error at "''": Expected W:(abcd...)                                                                                                                                                
nox > Session pre-commit failed. 

@matteosantama
Copy link
Contributor Author

@cjolowicz Unfortunately the patch doesn't totally resolve the issue. I am getting the same error as @RomainBrault

My pyproject.toml looks like

[[tool.poetry.source]]
name = "gitlab_pypi"
url = "https://gitlab.com/api/v4/projects/XXX/packages/pypi/simple"
secondary = false

@cjolowicz
Copy link
Owner

@matteosantama @RomainBrault thanks for the input and the PR!

Another fix was released in 0.8.4, please let me know if you still encounter any problems.

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

Successfully merging a pull request may close this issue.

3 participants