question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement version constraint operator "tilde" (like npm does)

See original GitHub issue

I see more and more python packages with this kind of deps: pyramid >=1.4.5, <1.5.0. It makes a lot of sense for projects following SemVer, and this pattern looks like a hack.

NPM implemented it as this: ~1.2.3 := >=1.2.3-0 <1.3.0-0 (https://npmjs.org/doc/misc/semver.html)

This syntax would be interesting: pyramid ~= 1.4.5

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dstufftcommented, Dec 14, 2014

The ~= operator is part of PEP 440 and is now in the develop branch of pip.

0reactions
mockturtlcommented, Nov 6, 2014

I totally agree that the tilde operator is not well explicit. Maybe it’s a bad idea.

Consider the caret ^, instead / also. If you can assume SemVer, it’s better behaved:

  • >=1.4.5, <1.5.0 is overconstrained: a 1.x release MUST NOT have breaking changes.
  • ~1.4 allows 1.4.0 when you want a patch-level floor of 1.4.5.
prior art

nodejs (npm) dart (pub) ruby (gem) (see “compound requirement”)

(Apologies if this doesn’t belong here; this issue was my first search-engine result for “npm version constraint.” I believe it’s relevant, per my reading of PEP 440.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

A guide to NPM version constraints for Rubyists - rossta.net
A reference guide to NPM version constraints for dependencies declared in the package.json file of a Rails project from the perspective of a ......
Read more >
What's the difference between tilde(~) and caret(^) in package ...
It is used when you're ready to accept bug-fixes in your dependency, but don't want any potentially incompatible changes. The tilde matches the ......
Read more >
Version Constraints - Configuration Language | Terraform
A version constraint is a string literal containing one or more conditions, which are separated by commas. Each condition consists of an operator...
Read more >
semver - npm Docs
A version range is a set of comparators which specify versions that satisfy the range. A comparator is composed of an operator and...
Read more >
Should You Use Upper Bound Version Constraints?
Bound version constraints (upper caps) are starting to show up in the Python ecosystem. This is causing real world problems with libraries ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found