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 local requirements with lockfiles #1696

Closed
Eric-Arellano opened this issue Mar 28, 2022 · 5 comments · Fixed by #1792
Closed

Support local requirements with lockfiles #1696

Eric-Arellano opened this issue Mar 28, 2022 · 5 comments · Fixed by #1792
Assignees

Comments

@Eric-Arellano
Copy link
Contributor

From John re how to implement:

I think the same trick used for VCS basically works for local projects, but there is some juggling to do (The original standard Pex resolver does the juggling but both the --lock resolver and --pex-repository resolver refuse to do this.

Two Pants users have weighed in that this would be very useful for their repos, so Pants would love to see this feature.

@jsirois
Copy link
Member

jsirois commented Apr 2, 2022

Sounds good. IIUC @Eric-Arellano to be able to use this feature Pants will need to get out of the way re requirements parsing, or support local absolute paths in requirements in some ergonomic way. For the former, Pex supports pex . and for the latter pex "pex @ file:///home/jsirois/dev/pantsbuild/pex".

@jsirois jsirois self-assigned this Apr 6, 2022
@jsirois
Copy link
Member

jsirois commented Apr 6, 2022

Ok:

$ python -mpex.cli lock create . --indent 2
{
  "allow_builds": true,
  "allow_prereleases": false,
  "allow_wheels": true,
  "build_isolation": true,
  "constraints": [],
  "locked_resolves": [
    {
      "locked_requirements": [
        {
          "artifacts": [
            {
              "algorithm": "sha256",
              "hash": "0308b8310a8ac7ecbf4be61e3ac3ad6deac818a522ec76aff551b3be9c634910",
              "url": "file:///home/jsirois/dev/pantsbuild/jsirois-pex"
            }
          ],
          "project_name": "pex",
          "requires_dists": [
            "subprocess32>=3.2.7; extra == \"subprocess\" and python_version < \"3\""
          ],
          "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,<3.11,>=2.7",
          "version": "2.1.77"
        }
      ],
      "platform_tag": [
        "cp310",
        "cp310",
        "manylinux_2_35_x86_64"
      ]
    }
  ],
  "pex_version": "2.1.77",
  "prefer_older_binary": false,
  "requirements": [
    "."
  ],
  "requires_python": [],
  "resolver_version": "pip-legacy-resolver",
  "style": "strict",
  "transitive": true,
  "use_pep517": null
}

This runs into the same issues as #1413 though. Time to think about that.

@Eric-Arellano
Copy link
Contributor Author

Exciting! If it is amenable to land that, I think it could be useful as a precursor. While no one will be able to use it in production lock files without 1413, it can be helpful when people are debugging locally

@jsirois
Copy link
Member

jsirois commented Apr 6, 2022

It's not, that's just a lock file, its not consuming it. There is more work to do here to support consumption. The "." in requirements is not a valid PEP requirement, and, on parse it currently needs to be. I generally refuse to half-way things because there is often a very steep cost in self-thrash as fallout. Going to get this right.

@jsirois
Copy link
Member

jsirois commented Apr 15, 2022

A sticky wicket here turned out to be fingerprinting. It's effectively impossible to know what to exclude when hashing a project directory. I took a stab at just omitting pyc related files and dirs and all conceivable VCS dirs, but that's not enough. There are control dirs from tox and mypy and who knows what else that should not affect the project fingerprint when the project source hasn't changed, but do. Since pip download ... does not create an sdist for us (It just generates the sdist metadata we gather in the form of a project name and version from its logs in the Locker.), it seems I'll have to roll an sdist builder. With that in place the hash of a local project can be the hash of its built sdist (Probably the hash of the sdist cracked back open so we don't need to rely on the build backend creating a reproducible sdist / honoring SOURCE_DATE_EPOCH.). This is not too bad to do since we can fall back on setuptools.build_meta:__legacy__ when there is no pyproject.toml with a build backend defined.

This was referenced Apr 18, 2022
This was referenced Apr 28, 2022
@jsirois jsirois mentioned this issue May 25, 2022
1 task
jsirois added a commit to jsirois/pex that referenced this issue May 27, 2022
This is part of a series of a refactors needed to remove dependency
cycles in support of pex-tool#1696.
jsirois added a commit that referenced this issue May 27, 2022
This is part of a series of a refactors needed to remove dependency
cycles in support of #1696.
jsirois added a commit to jsirois/pex that referenced this issue May 27, 2022
This was only used by tests. The rest of Pex operates only on installed
wheels.

This is part of a series of a refactors needed to remove dependency
cycles in support of pex-tool#1696.
jsirois added a commit that referenced this issue May 27, 2022
This was only used by tests. The rest of Pex operates only on installed
wheels.

This is part of a series of a refactors needed to remove dependency
cycles in support of #1696.
jsirois added a commit to jsirois/pex that referenced this issue May 28, 2022
The primary refactors:
+ pex.resolve.lockfile.{lockfile -> model}
+ pex.resolve.lockfile.{create -> operations.create}
+ pex.resolve.lockfile.{load,loads} inlined json_codec.{load,loads}

This is part of a series of a refactors needed to remove dependency
cycles in support of pex-tool#1696.
jsirois added a commit that referenced this issue May 28, 2022
The primary refactors:
+ pex.resolve.lockfile.{lockfile -> model}
+ pex.resolve.lockfile.{create -> operations.create}
+ pex.resolve.lockfile.{load,loads} inlined json_codec.{load,loads}

This is part of a series of a refactors needed to remove dependency
cycles in support of #1696.
jsirois added a commit to jsirois/pex that referenced this issue May 28, 2022
This moves patching out of the Pip tool into dedicated foreign platform
and locker download observers that do their own patching. This allows
the notion of locking to be narrowed to just the lock create use of Pip
download.

This is part of a series of a refactors needed to remove dependency
cycles in support of pex-tool#1696.
jsirois added a commit that referenced this issue May 29, 2022
This moves patching out of the Pip tool into dedicated foreign platform
and locker download observers that do their own patching. This allows
the notion of locking to be narrowed to just the lock create use of Pip
download.

This is part of a series of a refactors needed to remove dependency
cycles in support of #1696.
@jsirois jsirois mentioned this issue May 29, 2022
1 task
jsirois added a commit to jsirois/pex that referenced this issue May 29, 2022
jsirois added a commit to jsirois/pex that referenced this issue May 30, 2022
This will be needed to support getting a consistent fingerprint for
local projects when locking them.

Work towards pex-tool#1696.
jsirois added a commit to jsirois/pex that referenced this issue May 30, 2022
This will be needed to support getting a consistent fingerprint for
local projects when locking them.

Work towards pex-tool#1696.
jsirois added a commit that referenced this issue May 30, 2022
jsirois added a commit that referenced this issue May 31, 2022
This will be needed to support getting a consistent fingerprint for
local projects when locking them.

Work towards #1696.
jsirois added a commit to jsirois/pex that referenced this issue May 31, 2022
jsirois added a commit that referenced this issue May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants