Skip to content

Commit

Permalink
fix: update package to make release possible
Browse files Browse the repository at this point in the history
- Add `requirements.txt` for defining required dependencies
- Get version from `__version__.py` file with exec - avoiding initialization of the package prematurely
- Fix typo in imported exception HTTPError from package requests
  • Loading branch information
martinalbert committed Apr 24, 2024
1 parent 46d9b0f commit 64ea1c2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions butter_cms/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import requests

from .__version__ import __version__
from requests.exceptions import HttpError
from requests.exceptions import HTTPError


class Client(object):
Expand Down Expand Up @@ -40,7 +40,7 @@ def api_get(self, slug='', params=None, path_override=None):
# We are not using response.raise_for_status(), as it only raises errors for definite error codes; we want to raise errors for any status other than 200.
# more info here: https://github.com/ButterCMS/buttercms-python/issues/5
if response.status_code != 200:
raise HttpError(response.status_code)
raise HTTPError(response.status_code)

return response.json()

Expand Down
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build==1.2.1
certifi==2024.2.2
charset-normalizer==3.3.2
idna==3.7
packaging==24.0
pyproject_hooks==1.0.0
requests==2.31.0
urllib3==2.2.1
16 changes: 11 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import sys

from butter_cms.__version__ import __version__
import os

try:
from setuptools import setup
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup

Expand All @@ -22,11 +21,18 @@
else:
install_requires.append('requests')

package_root = os.path.abspath(os.path.dirname(__file__))
version = {}

with open(os.path.join(package_root, "butter_cms/__version__.py")) as fp:
exec(fp.read(), version)

version = version["__version__"]

setup(
name = 'buttercms-python',
packages = ['butter_cms'],
version = __version__,
packages = find_packages(),
version = version,
description = 'API First Blogging and CMS platform built for developers',
long_description=readme,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 64ea1c2

Please sign in to comment.