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

Support "<" in package specifiers #115

Open
techtonik opened this issue Sep 4, 2019 · 4 comments
Open

Support "<" in package specifiers #115

techtonik opened this issue Sep 4, 2019 · 4 comments

Comments

@techtonik
Copy link
Contributor

For some reason there is an assertion against using < is package specifier.

$ hashin.py -r requirements_dev.txt "pytest<4.0.0"
Traceback (most recent call last):
  File "../hashin/hashin.py", line 832, in <module>
    sys.exit(main())
  File "../hashin/hashin.py", line 824, in main
    index_url=args.index_url,
  File "../hashin/hashin.py", line 135, in run
    return run_packages(specs, requirements_file, *args, **kwargs)
  File "../hashin/hashin.py", line 176, in run_packages
    package, version, restriction = _explode_package_spec(spec)
  File "../hashin/hashin.py", line 145, in _explode_package_spec
    assert ">" not in spec and "<" not in spec
AssertionError
@peterbe
Copy link
Owner

peterbe commented Sep 4, 2019

The reason is because that functionality simply doesn't exist. What we'd need is to write some code that downloads all possible versions of pytest and then, using the operator, calculate what the best version would be.
E.g. ["3.9.8", "3.9.9", "4.0.0", "4.1"] ==> 3.9.9

In a sense, it already supports

$ hashin.py -r requirements_dev.txt "pytest>=4.0.0"

because if you omit the operator (or the version) it knows to pick the latest and greatest which is a lot easier to compute.

If you feel like you often need to add a version with an operator other than >= or == then I think it's pretty straight forward to add.

Also, doing that kind of version operation arithmatic "should be easy" if done using pip's underlying tools and functions.

@techtonik
Copy link
Contributor Author

techtonik commented Sep 5, 2019

I thought that it should somehow be done through the imported pip_api, but I don't know if I will need it second time. Right now hierarchical dependency updates are more useful and fun for learning pip_api.

@peterbe
Copy link
Owner

peterbe commented Sep 5, 2019

Perhaps because I've been lazy but there's been a couple of times where I know I don't want the latest version. For example, when I upgrade or add a lib in a Python2 project. Then I usually, for example, open the CHANGELOG.rst and read it for which version is right for my project. It might, for example, say that "As of version 2.0.0 it only works for Python3". So I figured out I need version ==1.9.3 and then I go to use hashin.

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

3 participants
@peterbe @techtonik and others