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

Update package installation to work with Python 3.12 #2304

Open
emily-grabowski opened this issue Aug 1, 2024 · 9 comments
Open

Update package installation to work with Python 3.12 #2304

emily-grabowski opened this issue Aug 1, 2024 · 9 comments

Comments

@emily-grabowski
Copy link
Contributor

emily-grabowski commented Aug 1, 2024

When I tried to install openreview-py using the instructions here, I ran into an issue with the git installation and Python 3.12.

Using Python 3.12:

git clone https://github.com/openreview/openreview-py.git
cd openreview-py
pip install -e .

resulted in the following message: AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

This seems to be related to function pkgutil.ImpImporter that has been removed in Python 3.12

To resolve it, I used Python 3.9 and ran the same commands to install openreview-py. I'd suggest including the version requirement in the installation instructions until we can update the package to be compatible with the new version.

Update 8/5: Seems like the conflict is in the setuptools requirement: 'setuptools==65.5.1' - installing with a more recent version of setuptools has been successful for me - Updating this requirement might help resolve the compatibility issue in the future.

@melisabok
Copy link
Member

Good idea, I'm using Python 3.9 too and I believe the instances in Google Cloud too.

We would need to work on this to give support to higher Python version.

In the meantime, can you add this as a requirement?

@melisabok
Copy link
Member

I believe it is adding python_requires='==3.9.*', in the setup.py?

@emily-grabowski
Copy link
Contributor Author

Ok I can do that. Is the correct process to edit setup.py, then create a PR on the master branch?

@carlosmondra
Copy link
Member

I found an issue that may also be affected by the python version: #1920

@melisabok
Copy link
Member

Yes, you create a branch, push your code and then create the PR to request to merge it into the master branch.

@emily-grabowski
Copy link
Contributor Author

Looking at the code, it seems like the error is coming from the line from setuptools import setup in line 1 of the file. To confirm, I ran just this line in Python 3.9 with no error, and when I run this in Python 3.12, I get the same error as above. From this, it seems like including python_requires won't resolve the issue on its own.

@emily-grabowski
Copy link
Contributor Author

I also tried adding python_requires to the setup.py:

python_requires='==3.9.*',
and when I ran it on Python 3.12, got the same error.

@melisabok
Copy link
Member

ChatGPT tells me there should be an error if you use another Python version:

Yes, adding the python_requires argument to the setup.py file ensures that the Python version requirement is validated during the installation process. When a user tries to install your package, tools like pip will check the Python version against the specified requirement and will prevent the installation if the version does not match.

Here’s how it works in detail:

  1. Add python_requires in setup.py:

    from setuptools import setup, find_packages
    
    setup(
        name='your_package_name',
        version='0.1.0',
        packages=find_packages(),
        python_requires='==3.9.*',
        install_requires=[
            # List your dependencies here
        ],
        # Other arguments
    )
  2. Installation Check:

    • When a user runs pip install your_package_name, pip will read the setup.py file and check the python_requires specification.
    • If the user's Python version does not match 3.9.*, pip will raise an error and prevent the installation.

Example of Installation Error

If a user tries to install the package on a Python version other than 3.9, they will see an error message similar to this:

ERROR: Package 'your_package_name' requires a different Python: 3.x.x not in '==3.9.*'

This ensures that your package is only installed in the appropriate Python environment, thereby preventing potential compatibility issues.

@emily-grabowski
Copy link
Contributor Author

Got it, I think I was having an issue with a cache in my 3.12 environment. I added the python_requires value to the setup.py and when I try to install it on a clean 3.12 environment, I get the following message:
ERROR: Package 'openreview-py' requires a different Python: 3.12.4 not in '==3.9.*'

Which seems like it is behaving as desired. I'll check a couple more cases before pushing it to the repo.

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

3 participants