pipx icon indicating copy to clipboard operation
pipx copied to clipboard

Requirements not installed for local package

Open Chris-May opened this issue 4 years ago • 4 comments
trafficstars

Hey there! Thanks for making such a great tool! I think I might have found an issue with pipx, and I'm happy to help fix it, if necessary.

Describe the bug I'm installing a local package via pipx, and it seems as though it does not install the dependencies.

How to reproduce My setup.py is:

#setup.py
from setuptools import setup, find_packages

testing_requirements =["pytest", "pytest-randomly"]

setup(
    name="es_pipeline",
    packages=find_packages("src"),
    package_dir={"": "src"},
    install_requires=["Pygments", "pandocfilters", 'unsync', 'black'],
    extras_require={
        "tests": testing_requirements,
        "dev": ["pre-commit"] + testing_requirements,
    },
    entry_points={
        "console_scripts": [
            "pandoc_syntx_char = es_pipeline:run",
            "rest_to_icml = es_pipeline.bin:rst_to_icml",
        ]
    },
)

When I run mt code, in this case, rest_to_icml,

ine 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/chrisdev/PROJECTS/es_pipeline/src/es_pipeline/__init__.py", line 11, in <module>
    from black import TargetVersion, Mode, format_str
ModuleNotFoundError: No module named 'black'

I'm actually very confused, since the other dependencies have been installed somehow at some point, but not black, and black is available on the command line.

I installed this package via:

 pipx install . --force

and I also tried

pipx install . --force --include-deps

None of them fixed the issue.

What can I do to help fix this?

Chris-May avatar Sep 17 '21 21:09 Chris-May

You’ll need to provide a reproducible example. It’s impossible to know what went wrong for you from what you provide; the setup.py file runs fine for me if I add an empty src/es_pipeline/__init__.py.

uranusjr avatar Sep 17 '21 22:09 uranusjr

Roger that. I’ll look into it tomorrow.

Thanks for your time!

On Sep 17, 2021, at 6:24 PM, Tzu-ping Chung @.***> wrote:

 You’ll need to provide a reproducible example. It’s impossible to know what went wrong for you from what you provide; the setup.py file runs fine for me if I add an empty src/es_pipeline/init.py.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Chris-May avatar Sep 18 '21 03:09 Chris-May

I came across this today as well. I was interested in using a fork of podman-compose, but to my surprise --no-dependencies is included whenever installing from a local path. Here's some steps to compare and contrast:

$ pipx install podman-compose --verbose
pipx >(setup:717): pipx version is 0.16.3
pipx >(setup:718): Default python interpreter is '/Users/ktindall/.asdf/installs/python/3.9.5/bin/python3.9'
pipx >(package_name_from_spec:323): Determined package name: podman-compose
pipx >(package_name_from_spec:324): Package name determined in 0.0s
creating virtual environment...
pipx >(run_subprocess:135): running /Users/ktindall/.asdf/installs/python/3.9.5/bin/python3.9 -m venv --without-pip /Users/ktindall/.local/pipx/venvs/podman-compose
pipx >(run_subprocess:135): running /Users/ktindall/.local/pipx/venvs/podman-compose/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:135): running /Users/ktindall/.local/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:135): running /Users/ktindall/.local/pipx/venvs/podman-compose/bin/python --version
pipx >(_parsed_package_to_package_or_url:128): cleaned package spec: podman-compose
installing podman-compose...
pipx >(run_subprocess:135): running /Users/ktindall/.local/pipx/venvs/podman-compose/bin/python -m pip install podman-compose
pipx >(run_subprocess:135): running <fetch_info_in_venv commands>
pipx >(get_venv_metadata_for_package:303): get_venv_metadata_for_package: 74ms
pipx >(_parsed_package_to_package_or_url:128): cleaned package spec: podman-compose
pipx >(needs_upgrade:69): Time since last upgrade of shared libs, in seconds: 1118755. Upgrade will be run by pipx if greater than 2592000.
  installed package podman-compose 0.1.5, Python 3.9.5
  These apps are now globally available
    - podman-compose
done! ✨ 🌟 ✨
$ pipx uninstall podman-compose
uninstalled podman-compose! ✨ 🌟 ✨
$ git clone https://github.com/yuvalk/podman-compose.git
$ cd podman-compose
$ git checkout 795af9dc21d386b9e52e345197bffdccbf520aab
$ pipx install . --verbose
pipx >(setup:717): pipx version is 0.16.3
pipx >(setup:718): Default python interpreter is '/Users/ktindall/.asdf/installs/python/3.9.5/bin/python3.9'
pipx >(_parsed_package_to_package_or_url:128): cleaned package spec: /Users/ktindall/repos/github/containers/podman-compose
creating virtual environment...
pipx >(run_subprocess:135): running /Users/ktindall/.asdf/installs/python/3.9.5/bin/python3.9 -m venv --without-pip /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmpo9ek9i88
pipx >(run_subprocess:135): running /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmpo9ek9i88/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:135): running /Users/ktindall/.local/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:135): running /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmpo9ek9i88/bin/python --version
determining package name from '/Users/ktindall/repos/github/containers/podman-compose'...
pipx >(run_subprocess:135): running /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmpo9ek9i88/bin/python -m pip list --format=json
pipx >(run_subprocess:135): running /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmpo9ek9i88/bin/python -m pip install --no-dependencies /Users/ktindall/repos/github/containers/podman-compose
Processing /Users/ktindall/repos/github/containers/podman-compose
  DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
   pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
    ERROR: Command errored out with exit status 1:
     command: /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmpo9ek9i88/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/pip-req-build-xv3xhhr9/setup.py'"'"'; __file__='"'"'/private/var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/pip-req-build-xv3xhhr9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/pip-pip-egg-info-9uc8_g77
         cwd: /private/var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/pip-req-build-xv3xhhr9/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/pip-req-build-xv3xhhr9/setup.py", line 9, in <module>
        from podman_compose import __version__ as podman_compose_version
      File "/private/var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/pip-req-build-xv3xhhr9/podman_compose.py", line 35, in <module>
        import yaml
    ModuleNotFoundError: No module named 'yaml'
    ----------------------------------------
WARNING: Discarding file:///Users/ktindall/repos/github/containers/podman-compose. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
pipx >(subprocess_post_check:169): '/var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmpo9ek9i88/bin/python -m pip install --no-dependencies /Users/ktindall/repos/github/containers/podman-compose' failed
Cannot determine package name from spec '/Users/ktindall/repos/github/containers/podman-compose'. Check package spec for errors.

It seems that there is no way to get rid of the --no-dependencies option as the OP states.

Edit: Admittedly, podman-compose may be a poor example since it tries to import yaml before setup.py is fully parsed.

kevinkjt2000 avatar Sep 30 '21 15:09 kevinkjt2000

podman-compose was indeed a poor example of this. I was able to move import yaml to happen at runtime instead of setup time, and it installs just fine:

pipx install -e . --verbose
pipx >(setup:717): pipx version is 0.16.4
pipx >(setup:718): Default python interpreter is '/Users/ktindall/.asdf/installs/python/3.8.10/bin/python'
pipx >(_parsed_package_to_package_or_url:128): cleaned package spec: /Users/ktindall/repos/github/containers/podman-compose
creating virtual environment...
pipx >(run_subprocess:135): running /Users/ktindall/.asdf/installs/python/3.8.10/bin/python -m venv --without-pip /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmptyjk81u7
pipx >(run_subprocess:135): running /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmptyjk81u7/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:135): running /Users/ktindall/.local/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:135): running /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmptyjk81u7/bin/python --version
determining package name from '/Users/ktindall/repos/github/containers/podman-compose'...
pipx >(run_subprocess:135): running /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmptyjk81u7/bin/python -m pip list --format=json
pipx >(run_subprocess:135): running /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmptyjk81u7/bin/python -m pip install --no-dependencies --editable /Users/ktindall/repos/github/containers/podman-compose
pipx >(run_subprocess:135): running /var/folders/hv/y675tfs11fxd6ysthbn3rxmw0000gn/T/tmptyjk81u7/bin/python -m pip list --format=json
pipx >(install_package_no_deps:283): Determined package name: podman-compose
pipx >(package_name_from_spec:337): Package name determined in 2.5s
creating virtual environment...
pipx >(run_subprocess:135): running /Users/ktindall/.asdf/installs/python/3.8.10/bin/python -m venv --without-pip /Users/ktindall/.local/pipx/venvs/podman-compose
pipx >(run_subprocess:135): running /Users/ktindall/.local/pipx/venvs/podman-compose/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:135): running /Users/ktindall/.local/pipx/venvs/podman-compose/bin/python --version
pipx >(_parsed_package_to_package_or_url:128): cleaned package spec: /Users/ktindall/repos/github/containers/podman-compose
installing podman-compose from spec '/Users/ktindall/repos/github/containers/podman-compose'...
pipx >(run_subprocess:135): running /Users/ktindall/.local/pipx/venvs/podman-compose/bin/python -m pip install --editable /Users/ktindall/repos/github/containers/podman-compose
pipx >(run_subprocess:135): running <fetch_info_in_venv commands>
pipx >(get_venv_metadata_for_package:303): get_venv_metadata_for_package: 84ms
pipx >(_parsed_package_to_package_or_url:128): cleaned package spec: /Users/ktindall/repos/github/containers/podman-compose
pipx >(needs_upgrade:69): Time since last upgrade of shared libs, in seconds: 1120526. Upgrade will be run by pipx if greater than 2592000.
  installed package podman-compose 0.1.7.dev0, Python 3.8.10
  These apps are now globally available
    - podman-compose
done! ✨ 🌟 ✨

My apologies for possibly being noisy on this issue. I thought it was related.

kevinkjt2000 avatar Sep 30 '21 15:09 kevinkjt2000