pdm-project / pdm

A modern Python package and dependency manager supporting the latest PEP standards
https://pdm-project.org
MIT License
7.98k stars 410 forks source link

Failed to pass tests #3324

Closed Georgehu716 closed 1 day ago

Georgehu716 commented 1 day ago

Describe the bug

Failed to pass the tests when I follow the steps of https://github.com/pdm-project/pdm/blob/main/CONTRIBUTING.md#local-development to setup a local development environment.

Here is the outputs:

========================================================================================= short test summary info =========================================================================================
SKIPPED [1] tests/test_utils.py:171: Windows test
FAILED tests/cli/test_install.py::test_uv_install - RuntimeError: Call command ['add', 'requests'] failed(1): WARNING: Project requires a python version of >=3.7, The virtualenv is being created for you as it cannot be matched to the right version.
INFO: python.use_venv is on, creating a virtualenv for this project...
INFO: Using uv is experimental and might break due to uv updates.
[PdmUsageError]: use_uv is enabled but can't find uv, please install it first: https://docs.astral.sh/uv/getting-started/installation/
FAILED tests/cli/test_install.py::test_uv_install_pep582_not_allowed - RuntimeError: Call command ['add', 'requests', '--no-sync'] failed(1): INFO: Using uv is experimental and might break due to uv updates.
See /tmp/pytest-of-huerxiong/pytest-8/test_uv_install_pep582_not_all0/logs/pdm-lock-lk5h6otf.log for detailed debug log.
[PdmUsageError]: use_uv is enabled but can't find uv, please install it first: https://docs.astral.sh/uv/getting-started/installation/
FAILED tests/resolver/test_uv_resolver.py::test_resolve_requirements - pdm.exceptions.PdmUsageError: use_uv is enabled but can't find uv, please install it first: https://docs.astral.sh/uv/getting-started/installation/
FAILED tests/resolver/test_uv_resolver.py::test_resolve_vcs_requirement - pdm.exceptions.PdmUsageError: use_uv is enabled but can't find uv, please install it first: https://docs.astral.sh/uv/getting-started/installation/
FAILED tests/resolver/test_uv_resolver.py::test_resolve_with_python_requires - pdm.exceptions.PdmUsageError: use_uv is enabled but can't find uv, please install it first: https://docs.astral.sh/uv/getting-started/installation/
FAILED tests/resolver/test_uv_resolver.py::test_resolve_dependencies_with_nested_extras - pdm.exceptions.PdmUsageError: use_uv is enabled but can't find uv, please install it first: https://docs.astral.sh/uv/getting-started/installation/
FAILED tests/test_formats.py::test_convert_setup_py_project - subprocess.CalledProcessError: Command '['/home/huerxiong/.pyenv/versions/3.12.4/bin/python3.12', '-Es', '/home/huerxiong/code/github.com/pdm/src/pdm/models/in_process/parse_setup.py', '/home/huerxiong/code/github.com/pdm/tests/fixtures/projects/test-setuptools', '/tmp/tmpz8tc3kun.json']' returned non-zero exit status 1.
=================================================================== 7 failed, 963 passed, 1 skipped, 198 warnings in 199.23s (0:03:19) ====================================================================

To reproduce

Just follow the steps of https://github.com/pdm-project/pdm/blob/main/CONTRIBUTING.md#local-development.

Expected Behavior

Pass the tests.

Environment Information

(.venv) huerxiong in george-ubuntu ~/code/github.com/pdm (main)
$ pdm info && pdm info --env
PDM version:
  2.21.1.dev6+g8c674b5c
Python Interpreter:
  /home/huerxiong/code/github.com/pdm/.venv/bin/python (3.12)
Project Root:
  /home/huerxiong/code/github.com/pdm
Local Packages:

{
  "implementation_name": "cpython",
  "implementation_version": "3.12.4",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.8.0-48-generic",
  "platform_system": "Linux",
  "platform_version": "#48~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct  7 11:24:13 UTC 2",
  "python_full_version": "3.12.4",
  "platform_python_implementation": "CPython",
  "python_version": "3.12",
  "sys_platform": "linux"
}

pdm -v output

$ pdm -v
Usage: pdm [-h] [-V] [-c CONFIG] [-v | -q] [--no-cache] [-I] [--pep582 [SHELL]] [-n] ...

    ____  ____  __  ___
   / __ \/ __ \/  |/  /
  / /_/ / / / / /|_/ /
 / ____/ /_/ / /  / /
/_/   /_____/_/  /_/

Options:
  -h, --help            Show this help message and exit.
  -V, --version         Show the version and exit
  -c CONFIG, --config CONFIG
                        Specify another config file path [env var: PDM_CONFIG_FILE]
  -v, --verbose         Use `-v` for detailed output and `-vv` for more detailed
  -q, --quiet           Suppress output
  --no-cache            Disable the cache for the current command. [env var: PDM_NO_CACHE]
  -I, --ignore-python   Ignore the Python path saved in .pdm-python. [env var: PDM_IGNORE_SAVED_PYTHON]
  --pep582 [SHELL]      Print the command line to be eval'd by the shell for PEP 582
  -n, --non-interactive
                        Don't show interactive prompts but use defaults. [env var: PDM_NON_INTERACTIVE]

Commands:
  add                   Add package(s) to pyproject.toml and install them
  build                 Build artifacts for distribution
  cache                 Control the caches of PDM
  completion            Generate completion scripts for the given shell
  config                Display the current configuration
  export                Export the locked packages set to other formats
  fix                   Fix the project problems according to the latest version of PDM
  import                Import project metadata from other formats
  info                  Show the project information
  init                  Initialize a pyproject.toml for PDM. Built-in templates: - default: `pdm init`, A simple template with a basic structure. - minimal: `pdm init minimal`, A minimal template with
                        only `pyproject.toml`.
  install               Install dependencies from lock file
  list                  List packages installed in the current working set
  lock                  Resolve and lock dependencies
  outdated              Check for outdated packages and list the latest versions on indexes.
  publish               Build and publish the project to PyPI
  python (py)           Manage installed Python interpreters
  remove                Remove packages from pyproject.toml
  run                   Run commands or scripts with local packages loaded
  search                Search for PyPI packages
  self (plugin)         Manage the PDM program itself (previously known as plugin)
  show                  Show the package information
  sync                  Synchronize the current working set with lock file
  update                Update package(s) in pyproject.toml
  use                   Use the given python version or path as base interpreter. If not found, PDM will try to install one.
  venv                  Virtualenv management

Additional Context

$ python -V
Python 3.12.4

$ pip list
Package                    Version               Editable project location
-------------------------- --------------------- -----------------------------------
annotated-types            0.7.0
anyio                      4.3.0
Arpeggio                   2.0.0
arrow                      1.2.3
attrs                      23.1.0
Babel                      2.14.0
binaryornot                0.4.4
blinker                    1.8.2
cachetools                 5.5.0
certifi                    2024.8.30
cffi                       1.15.1
chardet                    5.2.0
charset-normalizer         3.3.2
click                      8.1.7
colorama                   0.4.6
cookiecutter               2.6.0
copier                     9.3.1
coverage                   7.2.7
cryptography               41.0.1
dep-logic                  0.4.9
distlib                    0.3.8
dunamai                    1.17.0
execnet                    2.1.1
filelock                   3.16.1
findpython                 0.6.2
funcy                      2.0
ghp-import                 2.1.0
griffe                     0.29.0
h11                        0.14.0
hishel                     0.0.33
httpcore                   1.0.6
httpx                      0.27.2
idna                       3.6
iniconfig                  2.0.0
installer                  0.7.0
jaraco.classes             3.2.3
jaraco.context             5.3.0
jaraco.functools           4.0.2
jeepney                    0.8.0
Jinja2                     3.1.4
jinja2-ansible-filters     1.3.2
keyring                    25.4.1
Markdown                   3.6
markdown-exec              1.9.3
markdown-it-py             3.0.0
MarkupSafe                 2.1.5
mdurl                      0.1.2
mergedeep                  1.3.4
mkdocs                     1.6.1
mkdocs-autorefs            1.2.0
mkdocs-get-deps            0.2.0
mkdocs-material            9.5.41
mkdocs-material-extensions 1.3.1
mkdocs-redirects           1.2.1
mkdocs-version-annotations 1.0.0
mkdocstrings               0.26.1
mkdocstrings-python        1.1.0
more-itertools             9.1.0
msgpack                    1.1.0
packaging                  24.1
paginate                   0.5.6
parver                     0.5
pathspec                   0.12.1
pbs-installer              2024.10.16
pdm                        2.21.1.dev6+g8c674b5c /home/huerxiong/code/github.com/pdm
pip                        24.3.1
platformdirs               4.3.6
pluggy                     1.5.0
plumbum                    1.8.2
prompt-toolkit             3.0.38
pycomplete                 0.4.0
pycparser                  2.21
pydantic                   2.9.2
pydantic_core              2.23.4
Pygments                   2.17.2
pymdown-extensions         10.7.1
pyproject-api              1.8.0
pyproject_hooks            1.2.0
pytest                     8.3.3
pytest-cov                 5.0.0
pytest_httpserver          1.1.0
pytest-mock                3.14.0
pytest-rerunfailures       14.0
pytest-xdist               3.6.1
python-dateutil            2.9.0.post0
python-dotenv              1.0.1
python-slugify             8.0.1
PyYAML                     6.0.1
pyyaml_env_tag             0.1
questionary                1.10.0
regex                      2023.12.25
requests                   2.31.0
resolvelib                 1.1.0
rich                       13.9.2
SecretStorage              3.3.3
setuptools                 75.2.0
shellingham                1.5.4
six                        1.16.0
sniffio                    1.3.1
socksio                    1.0.0
text-unidecode             1.3
tomlkit                    0.13.2
towncrier                  24.8.0
tox                        4.23.0
tox-pdm                    0.7.2
truststore                 0.9.2
typing_extensions          4.12.2
unearth                    0.17.2
urllib3                    2.2.1
virtualenv                 20.27.0
watchdog                   4.0.0
wcwidth                    0.2.6
Werkzeug                   2.2.3

Are you willing to submit a PR to fix this bug?

frostming commented 1 day ago

6 of them require uv to installed on your machine and I have skipped them in main branch.

Can you try again and show the failure details of the remaining case?

Georgehu716 commented 1 day ago

Sure, I've installed uv with pip, and here's the one remaining error:

================================================================================================ FAILURES =================================================================================================
______________________________________________________________________________________ test_convert_setup_py_project ______________________________________________________________________________________

project = <Project '/tmp/pytest-of-huerxiong/pytest-9/test_convert_setup_py_project0'>

    def test_convert_setup_py_project(project):
        golden_file = FIXTURES / "projects/test-setuptools/setup.py"
        assert setup_py.check_fingerprint(project, golden_file)
>       result, settings = setup_py.convert(project, golden_file, ns())

tests/test_formats.py:222: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/pdm/formats/setup_py.py:20: in convert
    parsed = parse_setup_py(str(project.environment.interpreter.executable), os.path.dirname(filename))
src/pdm/models/in_process/__init__.py:42: in parse_setup_py
    subprocess.check_call(cmd)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

popenargs = (['/home/huerxiong/.pyenv/versions/3.12.4/bin/python3.12', '-Es', '/home/huerxiong/code/github.com/pdm/src/pdm/models/...se_setup.py', '/home/huerxiong/code/github.com/pdm/tests/fixtures/projects/test-setuptools', '/tmp/tmp9jkfod78.json'],)
kwargs = {}, retcode = 1
cmd = ['/home/huerxiong/.pyenv/versions/3.12.4/bin/python3.12', '-Es', '/home/huerxiong/code/github.com/pdm/src/pdm/models/i...arse_setup.py', '/home/huerxiong/code/github.com/pdm/tests/fixtures/projects/test-setuptools', '/tmp/tmp9jkfod78.json']

    def check_call(*popenargs, **kwargs):
        """Run command with arguments.  Wait for command to complete.  If
        the exit code was zero then return, otherwise raise
        CalledProcessError.  The CalledProcessError object will have the
        return code in the returncode attribute.

        The arguments are the same as for the call function.  Example:

        check_call(["ls", "-l"])
        """
        retcode = call(*popenargs, **kwargs)
        if retcode:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = popenargs[0]
>           raise CalledProcessError(retcode, cmd)
E           subprocess.CalledProcessError: Command '['/home/huerxiong/.pyenv/versions/3.12.4/bin/python3.12', '-Es', '/home/huerxiong/code/github.com/pdm/src/pdm/models/in_process/parse_setup.py', '/home/huerxiong/code/github.com/pdm/tests/fixtures/projects/test-setuptools', '/tmp/tmp9jkfod78.json']' returned non-zero exit status 1.

../../../.pyenv/versions/3.12.4/lib/python3.12/subprocess.py:413: CalledProcessError
------------------------------------------------------------------------------------------ Captured stdout setup ------------------------------------------------------------------------------------------
Changes are written to pyproject.toml.
------------------------------------------------------------------------------------------ Captured stderr call -------------------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/huerxiong/code/github.com/pdm/src/pdm/models/in_process/parse_setup.py", line 219, in <module>
    json.dump(parse_setup(sys.argv[1]), f, default=json_default)
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/huerxiong/code/github.com/pdm/src/pdm/models/in_process/parse_setup.py", line 181, in parse_setup
    raise RuntimeError(
RuntimeError: setuptools is required to convert setup.py, install it by `pdm add setuptools`

========================================================================================= short test summary info =========================================================================================
SKIPPED [1] tests/test_utils.py:171: Windows test
FAILED tests/test_formats.py::test_convert_setup_py_project - subprocess.CalledProcessError: Command '['/home/huerxiong/.pyenv/versions/3.12.4/bin/python3.12', '-Es', '/home/huerxiong/code/github.com/pdm/src/pdm/models/in_process/parse_setup.py', '/home/huerxiong/code/github.com/pdm/tests/fixtures/projects/test-setuptools', '/tmp/tmp9jkfod78.json']' returned non-zero exit status 1.
=================================================================== 1 failed, 969 passed, 1 skipped, 198 warnings in 223.58s (0:03:43) ====================================================================

And setuptools has been installed as well:

(.venv) huerxiong in george-ubuntu ~/code/github.com/pdm (main)
$ pip list | grep -i setuptools
setuptools                 75.2.0
(.venv) huerxiong in george-ubuntu ~/code/github.com/pdm (main)
$ pdm list | grep -i setuptools
│ setuptools                 │ 75.2.0                │                                        │
Georgehu716 commented 1 day ago

I've updated the latest code of fix, but it still not work:

================================================================================================ FAILURES =================================================================================================
______________________________________________________________________________________ test_convert_setup_py_project ______________________________________________________________________________________

project = <Project '/tmp/pytest-of-huerxiong/pytest-11/test_convert_setup_py_project0'>, pdm = <function pdm.<locals>.caller at 0x77b9b0987b00>

    @pytest.mark.usefixtures("local_finder")
    def test_convert_setup_py_project(project, pdm):
        golden_file = FIXTURES / "projects/test-setuptools/setup.py"
        pdm(["add", "setuptools"], obj=project)
        assert setup_py.check_fingerprint(project, golden_file)
>       result, settings = setup_py.convert(project, golden_file, ns())

tests/test_formats.py:224: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/pdm/formats/setup_py.py:20: in convert
    parsed = parse_setup_py(str(project.environment.interpreter.executable), os.path.dirname(filename))
src/pdm/models/in_process/__init__.py:42: in parse_setup_py
    subprocess.check_call(cmd)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

popenargs = (['/home/huerxiong/.pyenv/versions/3.12.4/bin/python3.12', '-Es', '/home/huerxiong/code/github.com/pdm/src/pdm/models/...se_setup.py', '/home/huerxiong/code/github.com/pdm/tests/fixtures/projects/test-setuptools', '/tmp/tmptry2al1j.json'],)
kwargs = {}, retcode = 1
cmd = ['/home/huerxiong/.pyenv/versions/3.12.4/bin/python3.12', '-Es', '/home/huerxiong/code/github.com/pdm/src/pdm/models/i...arse_setup.py', '/home/huerxiong/code/github.com/pdm/tests/fixtures/projects/test-setuptools', '/tmp/tmptry2al1j.json']

    def check_call(*popenargs, **kwargs):
        """Run command with arguments.  Wait for command to complete.  If
        the exit code was zero then return, otherwise raise
        CalledProcessError.  The CalledProcessError object will have the
        return code in the returncode attribute.

        The arguments are the same as for the call function.  Example:

        check_call(["ls", "-l"])
        """
        retcode = call(*popenargs, **kwargs)
        if retcode:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = popenargs[0]
>           raise CalledProcessError(retcode, cmd)
E           subprocess.CalledProcessError: Command '['/home/huerxiong/.pyenv/versions/3.12.4/bin/python3.12', '-Es', '/home/huerxiong/code/github.com/pdm/src/pdm/models/in_process/parse_setup.py', '/home/huerxiong/code/github.com/pdm/tests/fixtures/projects/test-setuptools', '/tmp/tmptry2al1j.json']' returned non-zero exit status 1.

../../../.pyenv/versions/3.12.4/lib/python3.12/subprocess.py:413: CalledProcessError
------------------------------------------------------------------------------------------ Captured stdout setup ------------------------------------------------------------------------------------------
Changes are written to pyproject.toml.
Changes are written to pyproject.toml.
------------------------------------------------------------------------------------------ Captured stderr call -------------------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/huerxiong/code/github.com/pdm/src/pdm/models/in_process/parse_setup.py", line 219, in <module>
    json.dump(parse_setup(sys.argv[1]), f, default=json_default)
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/huerxiong/code/github.com/pdm/src/pdm/models/in_process/parse_setup.py", line 181, in parse_setup
    raise RuntimeError(
RuntimeError: setuptools is required to convert setup.py, install it by `pdm add setuptools`
frostming commented 1 day ago

Try again

Georgehu716 commented 1 day ago

It works! Nice job, thank you.