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

Fix passing constraints file path into pipx install operation via --pip-args #1390

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

guysalt
Copy link

@guysalt guysalt commented May 4, 2024

closes #1389

  • I have added a news fragment under changelog.d/ (if the patch affects the end users)

Summary of changes

Fix error with pipx install Command Using Relative Path for Pip Arguments

Test plan

Tested by running

pipx install --pip-args=--constraint=some_constraint_file.txt some_package_inside_constraint_file

@guysalt guysalt changed the title Fix error with pipx install command using --pip-args (#1389) Fix error with pipx install command using --pip-args May 4, 2024
Copy link
Contributor

@chrysle chrysle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! Please also extend the docstring of the changed function.

src/pipx/package_specifier.py Outdated Show resolved Hide resolved
src/pipx/package_specifier.py Outdated Show resolved Hide resolved
changelog.d/1389.bugfix.md Outdated Show resolved Hide resolved
src/pipx/package_specifier.py Outdated Show resolved Hide resolved
@guysalt
Copy link
Author

guysalt commented May 4, 2024

Thanks for catching this! Please also extend the docstring of the changed function.

I have considered this * Convert local paths to absolute paths as the same description, doesn't it?

@guysalt guysalt force-pushed the main branch 2 times, most recently from 47f4b58 to 138fa87 Compare May 4, 2024 14:14
@guysalt guysalt force-pushed the main branch 3 times, most recently from 6bd33c5 to d9d8663 Compare May 4, 2024 23:32
@guysalt guysalt changed the title Fix error with pipx install command using --pip-args Fix passing constraints file path into pipx install operation via --pip-args May 4, 2024
@chrysle
Copy link
Contributor

chrysle commented May 7, 2024

Great, let's get down to business once again, then. Don't fail to inform us about your XONSH compatibility research.
Could you add a functional test, please?

@guysalt
Copy link
Author

guysalt commented May 7, 2024

Great, let's get down to business once again, then. Don't fail to inform us about your XONSH compatibility research. Could you add a functional test, please?

sure, hope to do so soon...

@guysalt guysalt force-pushed the main branch 2 times, most recently from 677d47b to 919d7e9 Compare May 7, 2024 18:42
@guysalt
Copy link
Author

guysalt commented May 7, 2024

Great, let's get down to business once again, then. Don't fail to inform us about your XONSH compatibility research. Could you add a functional test, please?

hey, so I wrote a test, but i will glad if you help me with a question...

the test right now is not passing and I dont understand why.
first I wrote a test just for checking the path is absolute and the command working (with empty constraint file).

then I want to add a check for installing the right constraint from the file.
when I put in the constraint file pycowsay==0.0.0.1 it does not installing the package (says something about conflict).

and if I run similar command on my terminal its working, so im trying to understand what is the different?
maybe you can help me understand its related to the tests architecture or something like this.

@guysalt
Copy link
Author

guysalt commented May 8, 2024

Great, let's get down to business once again, then. Don't fail to inform us about your XONSH compatibility research. Could you add a functional test, please?

hey, so I wrote a test, but i will glad if you help me with a question...

the test right now is not passing and I dont understand why. first I wrote a test just for checking the path is absolute and the command working (with empty constraint file).

then I want to add a check for installing the right constraint from the file. when I put in the constraint file pycowsay==0.0.0.1 it does not installing the package (says something about conflict).

and if I run similar command on my terminal its working, so im trying to understand what is the different? maybe you can help me understand its related to the tests architecture or something like this.

understand the catch, add pycowsay==0.0.0.1 to the tests_packages files...
need to see all the tests pass

chrysle
chrysle previously approved these changes May 8, 2024
Copy link
Contributor

@chrysle chrysle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the tests.

tests/test_install.py Outdated Show resolved Hide resolved
tests/test_install.py Outdated Show resolved Hide resolved

temp_file = current_directory / constraint_file_name
temp_file.touch()
temp_file.write_text(f"pycowsay=={pycowsay_version}")
Copy link
Contributor

@chrysle chrysle May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a small database for our test packages, which we use in tests.

Suggested change
temp_file.write_text(f"pycowsay=={pycowsay_version}")
temp_file.write_text(PKG["ipython"]["spec"])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guysalt I think you overlooked this comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, if someone change to the newer version the test will not check if the older versions indeed installed.

Changed

testdata/tests_packages/unix-python3.10.txt Outdated Show resolved Hide resolved
tests/test_install.py Outdated Show resolved Hide resolved
Comment on lines 272 to 280
subprocess_pycowsay_available_versions = subprocess.run(
[sys.executable, "-m", "pip", "index", "versions", "pycowsay"], capture_output=True, text=True, check=False
)
subprocess_pycowsay_available_versions_output = subprocess_pycowsay_available_versions.stdout
output_lines = subprocess_pycowsay_available_versions_output.split("\n")
available_versions_line = next(line for line in output_lines if "Available versions:" in line)
versions_string = available_versions_line.split(":")[1].strip()
available_versions = versions_string.split(", ")
assert pycowsay_version in available_versions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? Besides, pip index is still experimental.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For double check if the required package version is available and if not, will be more clearly to say why the test fails.

do you prefer to remove this block?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, if it wasn't available, there would be something wrong with our test packages setup. I'd tend not to over-complicate things.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just wanted to check the setup for the tests good, and we have two different versions available on the tests and see the constraint flag works and the older version is installed.

Now after I wrote this I also see I did not check there at lease newer version indeed...

Anyway, Im ok also with not checking this,

Removed.

Copy link
Contributor

@chrysle chrysle May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just wanted to check the setup for the tests good, and we have two different versions available on the tests and see the constraint flag works and the older version is installed.

Although I think we can trust pip it handles the constraints files it is given correctly (if it does find them), creating a constraints file without a proper constraint doesn't seem good. Could you try specifying a version not equal (!=) to the spec in the constraints file? That way, we should be able to determine whether the mechanism works.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok now I got you, to do so with the PKG[package_name]["spec"] or with const?

I prefer const as the PKG[package_name]["spec"] taking the older version, and with const I can put not equal != to the newer version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer const as the PKG[package_name]["spec"] taking the older version, and with const I can put not equal != to the newer version.

You could run a replace on that, but either way is fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see the newer version isn't the same in all the tests_packages constraint files 😪 ...

How do I run a replace? Can I change it manually?

What do you think about put in the constraint file < from PKG[package_name]["spec"] and then check the version is indeed less then the PKG[package_name]["spec"].

For this I need that every test constraint file will contain at lease one version less the PKG[package_name]["spec"] version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I run a replace? Can I change it manually?

I thought of just using the str types' replace() function?

As far as I'm aware, we don't even need to test whether the version after installing with constraints is less than the spec given; only if it is not equal? Sorry for the hassle here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey im sorry for the delay, yea im sorry for the hassle too lets finish it.

I wanted to check if it less than the spec given, to validate for sure the constraint file is working. as I mention before, even if I using not equal sign and the constraint file somehow does not working, the test still can pass if the pypi versions matching the constraint.

Anyway, if its ok for you its ok for me, so now I believe I did it as you asked for.

thanks for your time!

tests/test_install.py Outdated Show resolved Hide resolved
tests/test_install.py Outdated Show resolved Hide resolved
testdata/tests_packages/unix-python3.10.txt Outdated Show resolved Hide resolved
src/pipx/package_specifier.py Outdated Show resolved Hide resolved
src/pipx/package_specifier.py Outdated Show resolved Hide resolved
@guysalt guysalt force-pushed the main branch 4 times, most recently from ec8ed19 to d45a72e Compare May 14, 2024 16:35
@guysalt guysalt force-pushed the main branch 2 times, most recently from c2764bb to d77d362 Compare May 15, 2024 09:55
tests/test_install.py Show resolved Hide resolved
tests/test_install.py Outdated Show resolved Hide resolved
@guysalt guysalt force-pushed the main branch 3 times, most recently from dbe79eb to 45b925b Compare May 15, 2024 13:38
@guysalt
Copy link
Author

guysalt commented May 19, 2024

Its seems that the tests fails exactly on what I was trying to tell you on the pip args split...

that the splitting does now working on the workflow, as it does now working on my terminal (xonsh).

do you have a clue why does it happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error with pipx install Command Using Relative Path for Pip Arguments
2 participants