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

Would it be possible to prevent pip-compile to replace . into -? #1595

Closed
avatar-lavventura opened this issue Mar 7, 2022 · 12 comments
Closed

Comments

@avatar-lavventura
Copy link

avatar-lavventura commented Mar 7, 2022

Environment Versions

  1. OS Type Ubuntu
  2. Python 3.8.10
  3. pip 22.0.4 from /home/alper/venv/lib/python3.8/site-packages/pip (python 3.8)
  4. pip-compile, version 6.5.1

pip-compile changes all . into - which affects the correct pip installations, causes errors as follows:

raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'zope-traversing==4.4.1' distribution was not found and is required by ebloc-broker
An exception of type DistributionNotFound occurred. Arguments:
(Requirement.parse('zope-traversing==4.4.1'), {'ebloc-broker'})

due to: zope-traversing replaced into zope.traversing

Example:
image

For example it changes zope.traversing into zope-traversing , which is in correct.

Would it be possible to prevent pip-compile to replace .?

@avatar-lavventura avatar-lavventura changed the title Would it be possible to prevent pip-compile to replace .? Would it be possible to prevent pip-compile to replace . into -? Mar 7, 2022
@AndydeCleyre
Copy link
Contributor

Have you seen #1576?

@AndydeCleyre
Copy link
Contributor

Thanks for reporting! Can you provide reproducible steps for that error message?

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Mar 7, 2022

They way I have installed python and activated venv other than that I have installed latest pip-tools and I just run pip-compile, hope it helps:

sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt-get update
sudo apt install python-dev -y
sudo apt install python2 -y
sudo apt install python-psutil -y
sudo apt install python3-dev -y
sudo apt install python3-pip -y
sudo apt install python3-venv -y
sudo apt install python3-virtualenv -y
sudo apt install python3.7 -y
sudo apt install python3.8-dev -y
sudo apt install python3.8-venv -y

VENV=$HOME/venv
python3.8 -m venv $VENV
source $VENV/bin/activate && $VENV/bin/python3.8 -m pip install --upgrade pip
sudo apt-get install -y libssl-dev zlib1g-dev gcc g++ make libgirepository1.0-dev
python3 -m pip install --no-use-pep517 cm-rgb
$VENV/bin/python3 -m pip install wheel -U
$VENV/bin/python3 -m pip install pip-tools -U

@AndydeCleyre
Copy link
Contributor

Are you saying that running pip-compile directly raises that DistributionNotFound exception? If not, can you provide steps to reproduce that?

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Mar 7, 2022

No pip-compile runs fine it just converts all periods(.) into dashes(-) affecting correct package names.

Basically, I install packages using pip install -e .. Afterwards I can run my code using <repo_name> , during this call it crashes during importing packages. Due to requirement.txt file it looks for zope-traversing instead available one should be zope.traversing.


Due to install_requires=requirements, check, it couldn't find the correct package name.

example setup.pyfile:

#!/usr/bin/python3

from setuptools import find_packages, setup

requirements_filename = "requirements.txt"
with open(requirements_filename, "r") as f:
    requirements = list(map(str.strip, f.read().split("\n")))[:-1]

setup(
    name="project",
    packages=find_packages(),
    setup_requires=["wheel", "eth-brownie"],
    version="2.0.0",  # don't change this manually, use bumpversion instead
    license="MIT",
    long_description=long_description,
    long_description_content_type="text/markdown",
    install_requires=requirements,
    entry_points={
        "console_scripts": ["run_me=project._cli.__main__:main"],
    },
    include_package_data=True,
    python_requires=">=3.6,<4",
)

@AndydeCleyre
Copy link
Contributor

OK I took your example setup file, replaced long_description with a string to make it valid, added a requirements.in with zope.traversal and generated a corresponding .txt, ran pip install -e . and everything installed successfully.

Now you are getting an error when you, what, use the setuptools-generated console script? Or when you use the code generally? If it's just the setuptools-generated console script that fails, I think that's a setuptools bug, as I wrote about in #1576 -- have you read that one yet?

If it is just the generated script file that's the problem, try editing that file down to:

#!/...keep original shebang here
import re
import sys
from project._cli.__main__ import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

If it's not just the setuptools-generated script that fails, can you please provide the full steps needed to produce the error?

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Mar 7, 2022

I don't have a requirements.in file, all changes made on the requirements.txt.

requirements.txt:

zope_security==5.1.1
zope_tales==5.1
zope_testing==4.9
zope_traversing==4.4.1

Does correspoing requirements.txt have zope_traversing==4.4.1 in it right not zope.traversal?

When you setuptools-generated console script?

Yes. When I use the one under ~/venv/bin/, : /home/alper/venv/bin/package_name


I can try to generate example from my main repo.

On my end, setuptools here it parses all the packages from requirement.txt:

requirements_filename = "requirements.txt"
with open(requirements_filename, "r") as f:
    requirements = list(map(str.strip, f.read().split("\n")))[:-1]

where requirements.txt contains zope_traversing and other package names. Afterwards install_requires=requirements, checks whether zope_traversing is installed but instead zope.traversing is installed so it's console script crashed right away.

@AndydeCleyre
Copy link
Contributor

The dots, underscores, and dashes are all interchangeable for package names. pip-compile is always writing with the dash form. Have you read through #1576 yet?

Can you try editing the launch script as above?

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Mar 7, 2022

How could I use the launch script above? I didn't get how it will fix the problem. I did not understand its #!/...keep original shebang here.

pip-compile is always writing with the dash form.

That's not correct on is the older version it was not writing with the dash form, or at least does not convert dot into dash.

@AndydeCleyre
Copy link
Contributor

I hate to be so repetitive, but do please read the discussion at #1576. I think this issue here is really a duplicate of that one.

How could I use the launch script above?

If you paste here the content of the launcher script that setuptools generates on your machine, I'll edit it to remove complications inserted by setuptools, for you to test.

That's not correct

Ah, by "always" I didn't mean for all of history, I just meant in all cases with current versions. Yes the behavior changed recently, matching similar changes within pip itself.

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Mar 7, 2022

Yeah issues seem duplicate of each other.

I think that behavior change causing all the issues. For example correct version should be: aspy.refactor-imports but pip-compile changes it into aspy-refactor-imports.

$ pip freeze | grep aspy.refactor
aspy.refactor-imports==2.1.1

Would it be possible to prevent pip-compile to changing dot into dashes like its old behavior?

@AndydeCleyre
Copy link
Contributor

I'm not convinced there's good reason to change this convergence of canonicalized names, but will keep tracking the problems at #1576 until they are resolved one way or another. I'll close this one in favor of that one for now, and I've gone ahead and opened pypa/setuptools#3157

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

No branches or pull requests

2 participants