Closed evan0greenup closed 1 month ago
Steps to replicate are missing. Also, the pipenv --support instructions are not necessary in the post
@aidencullo , just copy the Pipfile
above and run pipenv install
@evan0greenup we don't have that local .git -- Its not clear to me how to test a local .git repository, wouldn't it normally be a local file install?
@matteius I've been able to reproduce this, with an arbitrary local git repo (system specs at bottom).
Here's a possible workaround for the OP (at least it works on my system):
Before running pipenv
, set an env variable, using absolute path without leading slash:
export REPO_PATH="home/myuser/PycharmProjects/typer.git"
In the pipfile, use this env var and file:///
with triple slash:
typer = {git = "file:///${REPO_PATH}"}
In addition, although I'm not sure if this is always required, I also had to remove the existing Pipfile.lock before running pipenv install
or pipenv update
.
More details below.
Using only pip 24.2, the following works without issue:
pip install git+file:///home/me/my-package
Note git+file://
is a form of VCS installation, allowing us to install e.g. a specific version from a local repo.
Afaik, "translating" this to Pipfile
format yields:
...
mypackage = {git = "file:///home/me/my-package"}
...
This is what the OP has, and I run into the same errors as the OP.
Trying to understand what's going on, I switched to using an env variable for the path:
export ABSOLUTE_PATH_TO_MY_PACKAGE="/home/me/my-package"
and in the Pipfle:
mypackage = {git = "file://${ABSOLUTE_PATH_TO_MY_PACKAGE}"}
For some reason, this does work, and installation succeeds.
However, if I add a ref
, as in:
mypackage = {git = "file://${ABSOLUTE_PATH_TO_MY_PACKAGE}", ref = "2024.1"}
again, I see the same error as the OP (or very similar).
On a hunch, I tried adding a slash to the Pipfile, as in file:///
, and removing the leading slash from the env variable value, as in home/me/my-package
.
That works, both with the ref
, and without.
If we use triple slash in the pipfile (file:///
) and leading slash in the env var (/home/me/my-package
), installation fails with:
... INFO:pip.subprocessor:Running command git clone --filter=blob:none --quiet file://home/me/my-package /tmp/pipfile-envvar/.venv/src/fsproc INFO:pip.subprocessor:fatal: '/me/my-package' does not appear to be a git repository ...
Showing that the /home
part is being stripped.
Stepping back again to "pure" pip:
Using a requirements.txt
file with git+file://
(double slash) and ref:
git+file://${ABSOLUTE_PATH_TO_MY_PACKAGE}@2024.1
and env variable with /home/me/my-package
, i.e. with proper leading slash, installation succeeds (using pip install -r requirements.txt
).
Side note;
On Windows, if we use the same requirements.txt
, and specify a path with windows separators (\
) , e.g. $env:ABSOLUTE_PATH_TO_MY_PACKAGE = 'c:\users\me\my-package'
in powershell 5.1, then pip fails again:
... collecting git+file://C:****@2024.1 (from -r requirements.txt (line1)) ... does not appear to be a git repository ...
In this case pip install only succeeds if the expanded value looks like the following, with triple slash:
git+file:///c:\users\me\my-package@2024.1
system:
some issues that may be (remotely) related:
In my point of view, the feature for checkout and install local file:///
package dependencies should not depend on pip
, it should implement its own capability for checkout the local bare repository into an temporary directory and pack it into a wheel and install it.
And the scheme should not be git+file
, this is too redundant, for project dependency manager for other programming languages, they all support {git = "file:///path/to/repo.git"}
if they use TOML as project specification.
And git
in git+file
is unnecessary because there is already a git
in {git = ... }
.
@evan0greenup There are different types of local installation, both with valid use-cases:
mypackage = {path = "/path/to/mypackage"}
Even if the path represents a git repo, the above will simply install the current state of the workspace.
mypackage = {git = "file:///path/to/mypackage", ref = "2024.37"}
This allows you to install a specific reference state from the git repository, e.g. a specific tag or branch.
And the scheme should not be git+file, this is too redundant, for project dependency manager for other programming languages, they all support {git = "file:///path/to/repo.git"} if they use TOML as project specification.
Afaik, pipenv supports both {git = "file://...}"
and {git = "git+file://...}"
.
(@matteius please correct me if I'm wrong here)
I am not sure if https://github.com/pypa/pipenv/pull/6242 will change the behavior here, since git: git+file
is overly verbose I believe {git = "file://...}"
is preferred over {git = "git+file://...}
I just checked and #6242 does not break the existing assumptions -- but I think the confusion with this ticket is when installing a vcs repository from a local file path, it typically does not end with .git
because its just a directory path.
Issue description
When add a local git repository as dependency, it will cause resolution failure.
Here is the
Pipfile
Expected result
Just like how
Cargo.toml
do, it should clone the repository and install the dependency.Actual result
Resolution failure.
Here is the output
Steps to replicate
Provide the steps to replicate (which usually at least includes the commands and the Pipfile).
Please run
$ pipenv --support
, and paste the results here. Don't put backticks (`
) around it! The output already contains Markdown formatting.If you're on macOS, run the following:
If you're on Windows, run the following:
If you're on Linux, run the following:
$ pipenv --support
Pipenv version: `'2024.0.1'` Pipenv location: `'/usr/lib/python3.12/site-packages/pipenv'` Python location: `'/usr/bin/python'` OS Name: `'posix'` User pip version: `'24.0'` user Python installations found: PEP 508 Information: ``` {'implementation_name': 'cpython', 'implementation_version': '3.12.4', 'os_name': 'posix', 'platform_machine': 'x86_64', 'platform_python_implementation': 'CPython', 'platform_release': '6.10.2-arch1-1', 'platform_system': 'Linux', 'platform_version': '#1 SMP PREEMPT_DYNAMIC Sat, 27 Jul 2024 16:49:55 +0000', 'python_full_version': '3.12.4', 'python_version': '3.12', 'sys_platform': 'linux'} ``` System environment variables: - `SHELL` - `SESSION_MANAGER` - `COLORTERM` - `CSF_MDTVTexturesDirectory` - `XDG_MENU_PREFIX` - `TERM_PROGRAM_VERSION` - `CSF_DrawPluginDefaults` - `MATHEMATICA_HOME` - `CSF_LANGUAGE` - `SSH_AUTH_SOCK` - `CSF_MIGRATION_TYPES` - `MEMORY_PRESSURE_WRITE` - `DESKTOP_SESSION` - `CSF_OCCTResourcePath` - `CSF_STEPDefaults` - `PWD` - `XDG_SESSION_DESKTOP` - `LOGNAME` - `XDG_SESSION_TYPE` - `DRAWHOME` - `SYSTEMD_EXEC_PID` - `XAUTHORITY` - `CSF_StandardLiteDefaults` - `GJS_DEBUG_TOPICS` - `WINDOWPATH` - `MOTD_SHOWN` - `GDM_LANG` - `HOME` - `USERNAME` - `LANG` - `XDG_CURRENT_DESKTOP` - `MEMORY_PRESSURE_WATCH` - `VTE_VERSION` - `INVOCATION_ID` - `MANAGERPID` - `CSF_ShadersDirectory` - `CSF_EXCEPTION_PROMPT` - `CSF_XmlOcafResource` - `GJS_DEBUG_OUTPUT` - `CSF_SHMessage` - `XDG_SESSION_CLASS` - `TERM` - `USER` - `CUDA_PATH` - `CSF_StandardDefaults` - `CSF_IGESDefaults` - `DISPLAY` - `CSF_XCAFDefaults` - `SHLVL` - `CSF_PluginDefaults` - `CSF_TObjMessage` - `CASROOT` - `XDG_RUNTIME_DIR` - `MKLROOT` - `NVCC_CCBIN` - `DEBUGINFOD_URLS` - `JOURNAL_STREAM` - `CSF_XSMessage` - `MMGT_CLEAR` - `PATH` - `CSF_TObjDefaults` - `GDMSESSION` - `DBUS_SESSION_BUS_ADDRESS` - `HG` - `MAIL` - `DRAWDEFAULT` - `GIO_LAUNCHED_DESKTOP_FILE_PID` - `GIO_LAUNCHED_DESKTOP_FILE` - `TERM_PROGRAM` - `_` - `PIP_DISABLE_PIP_VERSION_CHECK` - `PYTHONDONTWRITEBYTECODE` - `PYTHONFINDER_IGNORE_UNSUPPORTED` Pipenv–specific environment variables: Debug–specific environment variables: - `PATH`: `/home/myuser/.pyenv/versions/3.11.9/bin:/home/myuser/.pyenv/versions/3.11.8/bin:~/.local/share/JetBrains/Toolbox/scripts/:/usr/local/bin:/usr/bin:/usr/local/sbin:/opt/cuda/bin:/opt/cuda/nsight_compute:/opt/cuda/nsight_systems/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin` - `SHELL`: `/bin/bash` - `LANG`: `en_US.UTF-8` - `PWD`: `/home/myuser/PycharmProjects/hello_pipenv` --------------------------- Contents of `Pipfile` ('/home/myuser/PycharmProjects/hello_pipenv/Pipfile'): ```toml [[source]] url = "https://pypi.org/simple" verify_ssl = true name = "pypi" [packages] typer = {git = "file:///home/myuser/PycharmProjects/typer.git"} [dev-packages] [requires] python_version = "3.12" ``` Contents of `Pipfile.lock` ('/home/myuser/PycharmProjects/hello_pipenv/Pipfile.lock'): ```json { "_meta": { "hash": { "sha256": "702ad05de9bc9de99a4807c8dde1686f31e0041d7b5f6f6b74861195a52110f5" }, "pipfile-spec": 6, "requires": { "python_version": "3.12" }, "sources": [ { "name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true } ] }, "default": {}, "develop": {} } ```