ButterCMS / buttercms-python

Python API client for ButterCMS (https://buttercms.com)
MIT License
36 stars 11 forks source link

Add necessary fixes to make new releases #9

Closed martinalbert closed 7 months ago

martinalbert commented 7 months ago

This PR adds necessary fixes to make new releases possible.

  1. Adds requirements.txt for defining required dependencies (for command pip install -r requirements.txt)
  2. Gets version from __version__.py file with use of exec - avoiding initialization of the package prematurely
  3. Fixes typo in imported exception HTTPError from package requests
Toreno96 commented 7 months ago
  1. Adds reading of __version__.py file avoiding initialization of the package prematurely

@martinalbert It's not clear to me why this is needed, could you elaborate?

martinalbert commented 7 months ago

@Toreno96 sure, the change regarding version is required mainly due to how python module pypa/build for building is working. Using older, deprecated, tool bdist_wheel (python setup.py sdist bdist_wheel) which does not throw an error when importing version like it was before this change, should be avoided and for building we should use pypa/build. I don’t know exactly how differently they work, but it has something to do with how these tools initialize and load package setup.

Toreno96 commented 7 months ago

the change regarding version is required mainly due to how python module pypa/build for building is working. Using older, deprecated, tool bdist_wheel (python setup.py sdist bdist_wheel) which does not throw an error when importing version like it was before this change, should be avoided and for building we should use pypa/build. I don’t know exactly how differently they work, but it has something to do with how these tools initialize and load package setup.

@martinalbert Do you mean that pypa/build is not able to use a version imported from a module like bdist_wheel? Am I getting it right?

A loose idea, but what if we try to go extra simple and define the version inline in the setup.py itself, instead of having a separate file and hacking its content into the setup.py? What could be the possible cons of that?

martinalbert commented 7 months ago

@Toreno96 Yes, when using pypa/build and imported version from a module, it probably tries to automatically find other needed dependecies (even though version file is not using any), which are at the time of setup.py not needed nor available.

I responded here regarding the version in setup.py.