Fix dependency declaration in setup.py
- Removed environment dependent dependency checks.
- Declared runtime dependencies explicitly using install_requires.
- Removed deprecated setup_requires usage.
This improves installation reliability and aligns with Python packaging best practices.
Summary by Sourcery
Declare runtime dependencies explicitly in setup.py and simplify version retrieval logic by assuming the requests library is available.
Bug Fixes:
- Ensure the requests dependency is always installed at runtime by listing it unconditionally in install_requires instead of relying on environment checks and setup_requires.
Enhancements:
- Remove deprecated setup_requires usage and environment-dependent dependency handling to align with current Python packaging best practices.
Build:
- Update setup.py dependency declarations to use a fixed install_requires list for numpy and requests.
Reworks setup.py dependency handling to declare requests as a hard runtime dependency, remove environment-dependent logic and deprecated setup_requires usage, and simplify PyPI version lookup.Reviewer's guide (collapsed on small PRs)
Reviewer's Guide
Sequence diagram for package installation with explicit requests dependency
sequenceDiagram
actor Developer
participant pip
participant setup_py
participant requests
participant PyPI
Developer->>pip: pip install easyPythonpi
pip->>setup_py: Evaluate install_requires
setup_py-->>pip: numpy>=1.19.5, requests>=2.25.1
pip->>pip: Resolve and install dependencies
pip->>requests: Install requests
pip->>setup_py: Run setup and get version
setup_py->>requests: get https://pypi.org/pypi/easyPythonpi/json
requests->>PyPI: HTTP GET package metadata
PyPI-->>requests: JSON version data
requests-->>setup_py: Parsed response
setup_py-->>pip: Package version from PyPI
pip-->>Developer: Installation complete
Flow diagram for dependency handling in setup.py before and after change
flowchart TD
subgraph Before_change
B1[Check environment for requests_installed]
B1 -->|requests_installed is False| B2[install_requires includes numpy and requests]
B1 -->|requests_installed is True| B3[install_requires includes only numpy]
B2 --> B4[setup_requires includes requests]
B3 --> B4
B4 --> B5[Call get_pypi_version]
B5 --> B6[If requests not installed, return default version]
end
subgraph After_change
A1[install_requires includes numpy and requests unconditionally]
A1 --> A2[pip installs numpy and requests]
A2 --> A3[Call get_pypi_version]
A3 --> A4[Use requests to fetch version from PyPI]
end
File-Level Changes
Change
Details
Files
Simplify PyPI version resolution by assuming requests is always available.
setup.py
Make requests a direct runtime dependency and remove deprecated/conditional dependency mechanisms.
setup.py
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
@sourcery-ai ai review
Sure! I'm generating a new review now.
@calchiwo pls check it's failing the tests and check the feedback from ai. I hope this will help you in resolving the issues
Hey @extinctsion, I've posted a new review for you!
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
@extinctsion fixed. i've removed setup-time network calls + dynamic versioning from setup.py. switched to static version so installs/tests don’t break in offline or CI envs. should be good now.
@calchiwo the test cases are failing. Pls see why.
@extinctsion found the issue. tests import methods.* as a top-level module, but it lives under easyPythonpi.methods. imports break in a clean env. i can fix the test imports if you want me to.
Sure. You can create an issue and raise a PR against it