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

[py] moved project metadata from setup.py to pyproject.toml #14311

Merged
merged 9 commits into from
Nov 20, 2024

Conversation

sandeepsuryaprasad
Copy link
Contributor

@sandeepsuryaprasad sandeepsuryaprasad commented Jul 26, 2024

User description

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

  • Moved project metadata from setup.py to pyproject.toml

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement


Description

  • Moved project metadata from setup.py to pyproject.toml.
  • Removed project metadata such as name, version, license, description, URLs, classifiers, packages, and dependencies from setup.py.
  • Added project metadata including name, version, license, description, readme, Python requirements, classifiers, and dependencies to pyproject.toml.
  • Defined package inclusion and exclusion rules in pyproject.toml.
  • Added project URLs for repository, bug tracker, changelog, documentation, and source code in pyproject.toml.

Changes walkthrough 📝

Relevant files
Enhancement
setup.py
Removed project metadata from `setup.py`.                               

py/setup.py

  • Removed project metadata such as name, version, license, description,
    URLs, classifiers, packages, and dependencies.
  • Retained custom installation command and Rust extensions
    configuration.
  • +0/-57   
    pyproject.toml
    Added project metadata to `pyproject.toml`.                           

    py/pyproject.toml

  • Added project metadata including name, version, license, description,
    readme, Python requirements, classifiers, and dependencies.
  • Defined package inclusion and exclusion rules.
  • Added project URLs for repository, bug tracker, changelog,
    documentation, and source code.
  • +44/-0   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No key issues to review

    Copy link
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Correct the format of the RustExtension key to use a string instead of a dictionary

    The dictionary key for the RustExtension is incorrectly formatted as a dictionary
    itself. It should be a string representing the name of the extension.

    py/setup.py [32]

    -RustExtension(
    -    {"selenium-manager": "selenium.webdriver.common.selenium-manager"}
    +RustExtension("selenium-manager", "selenium.webdriver.common.selenium-manager")
     
    • Apply this suggestion
    Suggestion importance[1-10]: 10

    Why: The suggestion corrects a potential bug by changing the dictionary key to a string, which is the correct format for the RustExtension.

    10
    Best practice
    Specify a precise Python version range in requires-python to avoid including future, potentially unsupported versions

    The requires-python field should specify a range that includes only the supported
    versions, not using the tilde approximation which might unintentionally include
    future, unsupported Python versions.

    py/pyproject.toml [11]

    -requires-python = "~=3.8"
    +requires-python = ">=3.8, <3.13"
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: This suggestion improves the precision of the Python version range, ensuring compatibility and preventing future unsupported versions from being included.

    8
    Adjust the version constraint for urllib3 to allow for minor updates within the same major version

    The dependency version for urllib3 should allow for minor updates within a major
    version, rather than restricting to a minor version range.

    py/pyproject.toml [29]

    -"urllib3[socks]>=1.26,<3"
    +"urllib3[socks]>=1.26,<2"
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Allowing minor updates within the same major version for urllib3 can improve compatibility and security by including minor updates and patches.

    7
    Enhancement
    Enable namespace packaging if the packages are part of a namespace

    The namespace field in the [tool.setuptools.packages.find] section should be set to
    true if the packages are intended to be part of a namespace package.

    py/pyproject.toml [40]

    -namespace = false
    +namespace = true
     
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: This suggestion is contextually accurate but should be verified if the packages are indeed part of a namespace. If not, this change could introduce issues.

    6

    @diemol diemol requested a review from AutomatedTester July 29, 2024 08:04
    @sandeepsuryaprasad
    Copy link
    Contributor Author

    @AutomatedTester could you review this PR please. Thanks!

    @VietND96 VietND96 added the C-py label Nov 1, 2024
    @sandeepsuryaprasad
    Copy link
    Contributor Author

    After the changes that I have made in this PR, I ran the build locally.

    bazel build //py:selenium-wheel

    Screenshot 2024-11-15 at 9 09 08 AM
    ~$ pip3 install selenium-4.27.0.dev202410311942-py3-none-any.whl
    Processing ./selenium-4.27.0.dev202410311942-py3-none-any.whl
    Requirement already satisfied: urllib3<3,>=1.26 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from urllib3[socks]<3,>=1.26->selenium==4.27.0.dev202410311942) (2.2.3)
    Requirement already satisfied: trio~=0.17 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202410311942) (0.27.0)
    Requirement already satisfied: trio-websocket~=0.9 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202410311942) (0.11.1)
    Requirement already satisfied: certifi>=2021.10.8 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202410311942) (2024.8.30)
    Requirement already satisfied: typing_extensions~=4.9 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202410311942) (4.12.2)
    Requirement already satisfied: websocket-client~=1.8 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202410311942) (1.8.0)
    Requirement already satisfied: attrs>=23.2.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202410311942) (24.2.0)
    Requirement already satisfied: sortedcontainers in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202410311942) (2.4.0)
    Requirement already satisfied: idna in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202410311942) (3.10)
    Requirement already satisfied: outcome in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202410311942) (1.3.0.post0)
    Requirement already satisfied: sniffio>=1.3.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202410311942) (1.3.1)
    Requirement already satisfied: wsproto>=0.14 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio-websocket~=0.9->selenium==4.27.0.dev202410311942) (1.2.0)
    Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from urllib3[socks]<3,>=1.26->selenium==4.27.0.dev202410311942) (1.7.1)
    Requirement already satisfied: h11<1,>=0.9.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium==4.27.0.dev202410311942) (0.14.0)
    Installing collected packages: selenium
    Successfully installed selenium-4.27.0.dev202410311942
    
    Screenshot 2024-11-15 at 9 11 12 AM

    @VietND96 @AutomatedTester can this be uploaded to test Pypi for further validation..

    @VietND96
    Copy link
    Member

    Sure, I will trigger the CI to validate it once and get back to you

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    sandeepsuryaprasad commented Nov 15, 2024

    @VietND96 I have installed the test version from test Pypi. The installation is successful. I also verified the tar file by downloading it, but I don't see the changes that I have made in pyproject.toml.. i.e all the metadata information is still in setup.py..

    tar file download

    ~$ pip3 install -i https://test.pypi.org/simple/ selenium
    Looking in indexes: https://test.pypi.org/simple/
    Collecting selenium
      Downloading https://test-files.pythonhosted.org/packages/a6/b3/ea3ef67230bc1c29cdfa38702f3e6c3d57a15f369562a8c65c7da6b276b4/selenium-4.27.0.202410311942-py3-none-any.whl.metadata (7.1 kB)
    Requirement already satisfied: urllib3<3,>=1.26 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from urllib3[socks]<3,>=1.26->selenium) (2.2.3)
    Requirement already satisfied: trio~=0.17 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium) (0.27.0)
    Requirement already satisfied: trio-websocket~=0.9 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium) (0.11.1)
    Requirement already satisfied: certifi>=2021.10.8 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium) (2024.8.30)
    Requirement already satisfied: typing_extensions~=4.9 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium) (4.12.2)
    Requirement already satisfied: websocket-client~=1.8 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium) (1.8.0)
    Requirement already satisfied: attrs>=23.2.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium) (24.2.0)
    Requirement already satisfied: sortedcontainers in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium) (2.4.0)
    Requirement already satisfied: idna in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium) (3.10)
    Requirement already satisfied: outcome in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium) (1.3.0.post0)
    Requirement already satisfied: sniffio>=1.3.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium) (1.3.1)
    Requirement already satisfied: wsproto>=0.14 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio-websocket~=0.9->selenium) (1.2.0)
    Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from urllib3[socks]<3,>=1.26->selenium) (1.7.1)
    Requirement already satisfied: h11<1,>=0.9.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium) (0.14.0)
    Downloading https://test-files.pythonhosted.org/packages/a6/b3/ea3ef67230bc1c29cdfa38702f3e6c3d57a15f369562a8c65c7da6b276b4/selenium-4.27.0.202410311942-py3-none-any.whl (9.7 MB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.7/9.7 MB 4.2 MB/s eta 0:00:00
    Installing collected packages: selenium
    Successfully installed selenium-4.27.0.202410311942
    

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    sandeepsuryaprasad commented Nov 16, 2024

    @VietND96 looks like the tar file is uploaded on Nov-11th. Not the latest one after I ran this build (this build was run on Nov-15th). I think this is the reason why my latest pyproject.toml is not getting reflected.. Can you please check on this one please..

    Copy link
    Member

    @VietND96 VietND96 left a comment

    Choose a reason for hiding this comment

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

    Daily, the Nightly is built from the trunk, so your changes can be found in a specific build.
    Here is the CI validation I just triggered
    Nightly build & upload: https://github.com/SeleniumHQ/selenium/actions/runs/11887595671
    TestPyPi: https://test.pypi.org/project/selenium/4.27.0.dev202411180720/
    Tests run: https://github.com/SeleniumHQ/seleniumhq.github.io/actions/runs/11887729210
    Overall is LGTM!

    @VietND96
    Copy link
    Member

    @sandeepsuryaprasad, can you check, CI this PR is failing

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    @sandeepsuryaprasad, can you check, CI this PR is failing

    @VietND96 sure, I will look into this and confirm.

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    @VietND96 I have fixed the defect.. the table [tool.setuptools.packages.find] was duplicated in pyproject.toml. Now I have removed the duplicate occurrence. Request you to re-trigger CI.

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    Installed selenium from test PyPI

    ~$ pip3 install pip install -i https://test.pypi.org/simple/ selenium==4.27.0.dev202411180720
    Looking in indexes: https://test.pypi.org/simple/
    Requirement already satisfied: pip in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (24.2)
    Requirement already satisfied: install in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (0.0.1)
    Collecting selenium==4.27.0.dev202411180720
      Using cached https://test-files.pythonhosted.org/packages/57/29/8d35116db32fd561d87a3897f8fde13680a47150109eb5cf217f2c877274/selenium-4.27.0.dev202411180720-py3-none-any.whl.metadata (7.1 kB)
    Requirement already satisfied: urllib3<3,>=1.26 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from urllib3[socks]<3,>=1.26->selenium==4.27.0.dev202411180720) (2.2.3)
    Requirement already satisfied: trio~=0.17 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202411180720) (0.27.0)
    Requirement already satisfied: trio-websocket~=0.9 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202411180720) (0.11.1)
    Requirement already satisfied: certifi>=2021.10.8 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202411180720) (2024.8.30)
    Requirement already satisfied: typing_extensions~=4.9 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202411180720) (4.12.2)
    Requirement already satisfied: websocket-client~=1.8 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from selenium==4.27.0.dev202411180720) (1.8.0)
    Requirement already satisfied: attrs>=23.2.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202411180720) (24.2.0)
    Requirement already satisfied: sortedcontainers in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202411180720) (2.4.0)
    Requirement already satisfied: idna in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202411180720) (3.10)
    Requirement already satisfied: outcome in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202411180720) (1.3.0.post0)
    Requirement already satisfied: sniffio>=1.3.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio~=0.17->selenium==4.27.0.dev202411180720) (1.3.1)
    Requirement already satisfied: wsproto>=0.14 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from trio-websocket~=0.9->selenium==4.27.0.dev202411180720) (1.2.0)
    Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from urllib3[socks]<3,>=1.26->selenium==4.27.0.dev202411180720) (1.7.1)
    Requirement already satisfied: h11<1,>=0.9.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium==4.27.0.dev202411180720) (0.14.0)
    Using cached https://test-files.pythonhosted.org/packages/57/29/8d35116db32fd561d87a3897f8fde13680a47150109eb5cf217f2c877274/selenium-4.27.0.dev202411180720-py3-none-any.whl (9.7 MB)
    Installing collected packages: selenium
    Successfully installed selenium-4.27.0.dev202411180720
    
    Screenshot 2024-11-18 at 8 02 27 PM

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    sandeepsuryaprasad commented Nov 18, 2024

    @VietND96 I have verified installing selenium from test PyPI. Looks good.. Also, I have fixed the defect. Now the CI is passing.

    @VietND96 VietND96 merged commit 673d2c7 into SeleniumHQ:trunk Nov 20, 2024
    16 of 17 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants