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.

Native namespace package does not install properly when specifying a target directory (-t option)

See original GitHub issue

Description

I cannot make native namespace packages to install properly when specifying a target directory (-t option).

This is important to me as I need to use the the target option to install some packages for an AWS Lambda.

This looks like a very old issue #1924. However I cannot find, after extensive search, any clarification anywhere and the case was closed without apparent resolution.

To confirm I tried it with the pypa samples from pypa/sample-namespace-packages and failed to install both native packages (pkg_a & pkg_b) with an error stating that the directory already exists.

Please note I tried this both on Windows and Linux and the other packaging methods ‘pkgutil’ and ‘pkg_resources’ had the same exact problem.

Thank You

Expected behavior

Both packages pkg_a & pkg_b should install in the same namespace directory.

pip version

21.1.3

Python version

3.8.5

OS

Windows/Linux

How to Reproduce

git clone https://github.com/pypa/sample-namespace-packages

cd sample-namespace-packages/native mkdir temp

pip install ./pkg_a -t temp pip install ./pkg_b -t temp

Output

The second install fails with a message like:

WARNING: Target directory .../sample-namespace-packages/native/temp/example_pkg already exists. Specify --upgrade to force replacement.

Code of Conduct

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:19 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
pradyunsgcommented, Jul 2, 2021

Based on a trip down the issue tracker history (notably https://github.com/pypa/pip/issues/4389), I don’t think multiple-runs-with---target was ever an intended use case. Using --prefix is a much better fit for such uses cases, and I recommend using that.

I’ve relabelled this but I’m very much inclined to close this as “no, don’t do that; use --prefix instead”. If someone wants to add defenses to --target to prevent such usage, let’s file a separate issue for that.

1reaction
uranusjrcommented, Jun 30, 2021

I’m going to just classify it as a bug. Not sure I (or another maintainer) will be able to work on this in the newer future, so any contribution is welcomed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - `pip install -t` doesn't work with namespace packages
When I install requests with either --target or --prefix and add it to the PYTHONPATH I can import it just fine. But with...
Read more >
Packaging namespace packages
Use native namespace packages. This type of namespace package is defined in PEP 420 and is available in Python 3.3 and later. ·...
Read more >
Howto: Building R 4.2 and packages on Windows
R and packages are built using Rtools, which is a collection of build tools, ... If you have installed it into a different...
Read more >
setuptools 5.1 - PyPI
Easily download, build, install, upgrade, and uninstall Python packages.
Read more >
MSBuild reference for .NET SDK projects - Microsoft Learn
Reference for the MSBuild properties and items that are understood by the .NET SDK.
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