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

pdm install does not install all files included in sdist with pdm build #2972

Open
1 task done
NiklasRosenstein opened this issue Jun 25, 2024 · 2 comments
Open
1 task done
Labels
🐛 bug Something isn't working

Comments

@NiklasRosenstein
Copy link

  • I have searched the issue tracker and believe that this is not a duplicate.

Steps to reproduce

  • Create a new PDM project with the pdm-backend
  • Remove the src/ directory and add a Python script to the top-level, e.g. foobar.py
  • Run pdm install
  • Activate the environment and run python -m foobar in another directory (such that Python doesn't find foobar.py in the current directory) and note how it is not able to find the foobar module
  • Run pdm build and tar -tf dist/yourpackage-0.1.0.tar.gz to find that it contains foobar.py

Expected behavior

I would expect that foobar.py gets linked into the the virtual environment because it is also included in the source distribution.

That being said, I'm not 100% sure about the exact process that PDM uses to find which Python source files make up the distribution and I have struggled to find this in the docs. It might be worthwhile to document the behaviour and double down to ensure this behaviour is consistent across pdm install and pdm build.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.15.4
Python Interpreter:
  /home/coder/git/jfrog/jfrog-scripts/.venv/bin/python (3.10)
Project Root:
  /home/coder/git/jfrog/jfrog-scripts
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.14",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.10.218-208.862.amzn2.x86_64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP Tue Jun 4 16:52:10 UTC 2024",
  "python_full_version": "3.10.14",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "linux"
}

Additional notes

The behaviour I'm looking for is actually to have a PDM project that doesn't really require a distribution, but I want to be able to use pdm install to install Python files from the top-level of the project (i.e. next to the pyproject.toml) in subdirectories. The idea here is to create a simple layout for a repository that contains one-off scripts that can do a bit of importing from each other.

@NiklasRosenstein NiklasRosenstein added the 🐛 bug Something isn't working label Jun 25, 2024
@frostming
Copy link
Collaborator

frostming commented Jun 26, 2024

What is unexpected? From my testing pdm install correctly adds the project root to the path.

pdm-backend(yeah it is not even related to PDM) has a default behavior to include source files, if that is unexpected, you can use includes and excludes under tool.pdm.build table to customize it.

@o-moe
Copy link
Contributor

o-moe commented Jun 26, 2024

@NiklasRosenstein Maybe you want to handle it like described in the monorepo documentation? When you adjust the dev dependency to your script(s), they get installed as an editable dependency into your venv (you can change the sources without the need to re-install). But that would be picked up by pdm install (if that's your goal).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants