"pyproject.toml does not exist" when pdm add git+https from a subdirectory of a repository
See original GitHub issue- I have searched the issue tracker and believe that this is not a duplicate.
Make sure you run commands with -v
flag before pasting the output.
Steps to reproduce
- In an empty directory
pdm init
pdm add -v git+https://username:password@gitlab.com/path/to/my/project.git#egg=package_name#subdirectory=python_utils
Actual behavior
======== Start resolving requirements ========
package_name-subdirectory-python-utils @ git+https://username:password@gitlab.com/path/to/my/project.git
python>=3.8,<3.10.1
Adding requirement package_name-subdirectory-python-utils @ git+https://username:password@gitlab.com/path/to/my/project.git
Preparing isolated env for PEP 517 build...
Traceback (most recent call last):
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/pep517/metadata.py", line 72, in _read_pyproject
with self.filepath.open("rb") as f:
File "/usr/lib/python3.8/pathlib.py", line 1222, in open
return io.open(self, mode, buffering, encoding, errors, newline,
File "/usr/lib/python3.8/pathlib.py", line 1078, in _opener
return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pdm-build-inloop56/pyproject.toml'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ds/.local/bin/pdm", line 8, in <module>
sys.exit(main())
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/core.py", line 233, in main
return Core().main(args)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/core.py", line 168, in main
raise cast(Exception, err).with_traceback(traceback)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/core.py", line 163, in main
f(options.project, options)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/cli/commands/add.py", line 53, in handle
actions.do_add(
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/cli/actions.py", line 251, in do_add
resolved = do_lock(project, strategy, tracked_names, reqs, dry_run=dry_run)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/cli/actions.py", line 90, in do_lock
mapping, dependencies = resolve(
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/resolver/core.py", line 31, in resolve
result = resolver.resolve(requirements, max_rounds)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/resolvelib/resolvers.py", line 481, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/resolvelib/resolvers.py", line 348, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/resolvelib/resolvers.py", line 168, in _add_to_criteria
candidates=build_iter_view(matches),
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/resolvelib/structs.py", line 164, in build_iter_view
matches = list(matches)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/resolver/providers.py", line 237, in find_matches
yield from super().find_matches(identifier, requirements, incompatibilities)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/resolver/providers.py", line 145, in find_matches
candidates = self._find_candidates(reqs[0])
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/resolver/providers.py", line 125, in _find_candidates
can.prepare(self.repository.environment).prepare_metadata()
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/models/candidates.py", line 397, in prepare_metadata
self._metadata_dir = builder(
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 185, in __init__
self.init_build_system(build_system)
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 203, in init_build_system
self.ensure_setup_py()
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 318, in ensure_setup_py
return builder.ensure_setup_py().as_posix()
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/pep517/base.py", line 433, in ensure_setup_py
setup_py_path.write_text(self.format_setup_py(), encoding="utf-8")
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/pep517/base.py", line 278, in format_setup_py
meta = self.meta
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/pep517/base.py", line 143, in meta
self._meta = Metadata(self.location / "pyproject.toml")
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/pep517/metadata.py", line 68, in __init__
self._read_pyproject()
File "/home/ds/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/pep517/metadata.py", line 75, in _read_pyproject
raise ProjectError("pyproject.toml does not exist.")
pdm.pep517.exceptions.ProjectError: pyproject.toml does not exist.
If I install other packages using pdm add
, it completes with no error. (I tried pandas
)
Expected behavior
Install the package and add the corresponding dependency in pyproject.toml
Environment Information
# Paste the output of `pdm info && pdm info --env` below:
$ pdm info && pdm info --env
PDM version: 1.14.0
Python Interpreter: /usr/bin/python3.8 (3.8)
Project Root: /path/to/my/project
Project Packages: /path/to/my/project/__pypackages__/3.8
{
"implementation_name": "cpython",
"implementation_version": "3.8.10",
"os_name": "posix",
"platform_machine": "x86_64",
"platform_release": "5.4.0-1040-gcp",
"platform_system": "Linux",
"platform_version": "#43-Ubuntu SMP Fri Mar 19 17:49:48 UTC 2021",
"python_full_version": "3.8.10",
"platform_python_implementation": "CPython",
"python_version": "3.8",
"sys_platform": "linux"
}
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
poetry add of a GitHub repo with subdirectory fails · Issue #5521
I have tried adding this to my pyproject.toml: ... This is because it looks like the subdirectory is not passed to build.ProjectBuilder ....
Read more >Dependency Management With Python Poetry
When you add a requirement to the pyproject.toml file, it's not installed yet. As long as there's no poetry.lock file present in your...
Read more >Manage Dependencies - PDM
If pyproject.toml is already present, it will be updated with the metadata. ... a subdirectory pdm add "git+https://github.com/owner/repo.git@master#egg= ...
Read more >How can I install from a git subdirectory with pip?
Is it possible to install the module directly with pip without explicitly cloning ? I tried: pip install git+https://server/repo.git/mymodule/ ...
Read more >Packaging in Python: Tools and Formats | by Martin Thoma
A Python environment is the python executable, pip, and the set of installed packages. Different environments are isolated from each other and ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the exact same problem, although @cye18’s workaround with manual addition didn’t do it for me. I’ve tried with 2.1.0 and 2.1.5 versions and none of those worked. Then, miraculously, installing 2.1.3 and retrying helped.
A note to anyone who has the same issue. As mentioned in the comment, while
pdm add "git+https"
could give you the error, manually addingpackage_name@ git+https://username:password@gitlab.com/path/to/my/project.git#subdirectory=python_utils
to dependencies inpyproject.toml
works for me.