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 poetry replacing underscores with hyphens #702

Merged
merged 1 commit into from
Aug 31, 2022

Conversation

vale981
Copy link
Contributor

@vale981 vale981 commented Aug 30, 2022

Poetry replaces underscores with hyphens in module names.

This leads to the problem that things like


[tool.poetry.dependencies]
hiro_models = { git = "git@github.com:vale981/two_qubit_model.git", branch="online_calculation" }

don't work, because the sourceSpec is empty in

if isGit then
          (
            builtins.fetchGit ({
              inherit (source) url;
              rev = source.resolved_reference or source.reference;
              ref = sourceSpec.branch or (if sourceSpec ? tag then "refs/tags/${sourceSpec.tag}" else "HEAD");
            } // (
              let
                nixVersion = builtins.substring 0 3 builtins.nixVersion;
              in
              lib.optionalAttrs ((sourceSpec ? rev) && (lib.versionAtLeast nixVersion "2.4")) {
                allRefs = true;
              }
            ))
          )

The poetry lock entry for this looks like

[[package]]
name = "hiro-models"
version = "1.2.3"
description = "Operators for a general model of two interacting qubits coupled to two baths."
category = "main"
optional = false
python-versions = ">=3.9,<3.11"
develop = false

@adisbladis adisbladis merged commit 0434281 into nix-community:master Aug 31, 2022
@vale981
Copy link
Contributor Author

vale981 commented Aug 31, 2022

Thanks for merging ;). I wasn't sure whether this is the correct way to do it, but apparently it is.

@vale981 vale981 deleted the fix_underscores branch August 31, 2022 09:49
@sciyoshi
Copy link
Contributor

sciyoshi commented Sep 8, 2022

This change causes a regression: determining sourceSpec breaks if the dependency is specified in the pyproject.toml using dashes instead of underscores, which is allowed.

@sciyoshi
Copy link
Contributor

sciyoshi commented Sep 8, 2022

In fact, poetry prefers dashes to underscores, as you can see below:

~/workspace/oss/test is 📦 v0.1.0 via 🐍 v3.9.13
λ poetry add typing_extensions
Using version ^4.3.0 for typing-extensions

Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing typing-extensions (4.3.0)

~/workspace/oss/test is 📦 v0.1.0 via 🐍 v3.9.13
λ cat pyproject.toml
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Samuel Cormier-Iijima <samuel@cormier-iijima.com>"]

[tool.poetry.dependencies]
python = "^3.10"
typing-extensions = "^4.3.0"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

This leads me to think that this change should be reverted until a proper fix can be put in place.

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 this pull request may close these issues.

None yet

3 participants