Skip to content

Commit f3f0459

Browse files
authored
Merge pull request #32 from MrDOS/python3-compatibility
Python 3 compatibility
2 parents 6ddc251 + e82c73f commit f3f0459

6 files changed

Lines changed: 193 additions & 135 deletions

File tree

.github/workflows/test.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Run tests
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check out source
11+
uses: actions/checkout@v6
12+
- name: Restore pip cache
13+
uses: actions/cache@v5
14+
with:
15+
path: ~/.cache/pip
16+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
17+
restore-keys: |
18+
${{ runner.os }}-pip-
19+
- name: Run tests
20+
run: |
21+
python3 -m venv env
22+
. env/bin/activate
23+
pip install --editable ".[dev]"
24+
pytest

README.rst

Lines changed: 74 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,94 @@
11
Python iTunes
22
=============
33

4-
A simple python wrapper to access iTunes Store API http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
4+
A simple Python wrapper to access `iTunes Search API`_.
5+
6+
.. _iTunes Search API: https://performance-partners.apple.com/search-api
57

68
Installation
79
------------
810

9-
Pypi package available at http://pypi.python.org/pypi/python-itunes/1.0
11+
The library is distributed `on PyPI`_,
12+
and can be installed into a `virtual environment`_ for your project
13+
with ``pip``:
14+
15+
.. code-block:: sh
16+
17+
$ pip install python-itunes
18+
19+
To install the latest development version,
20+
``pip`` can fetch the source from the Git repository:
21+
22+
.. code-block:: sh
23+
24+
$ pip install git+https://github.com/ocelma/python-itunes
25+
26+
Usually, you would list this dependency in your ``pyproject.toml``:
27+
28+
.. code-block:: toml
29+
30+
[project]
31+
# ...
32+
dependencies = [
33+
"python-itunes",
34+
# or
35+
"python-itunes @ git+https://github.com/ocelma/python-itunes",
36+
]
1037
11-
::
38+
.. _on PyPI: http://pypi.python.org/pypi/python-itunes
39+
.. _virtual environment: https://docs.python.org/3/library/venv.html
1240

13-
$ easy_install python-itunes
41+
Development
42+
-----------
1443

15-
Or download the code from https://github.com/ocelma/python-itunes/archives/master and then
44+
To hack on the library itself,
45+
create a venv,
46+
and make an *editable* install of the library,
47+
along with development tools:
1648

17-
::
49+
.. code-block:: sh
1850
19-
$ python setup.py install
51+
$ git clone https://github.com/ocelma/python-itunes
52+
$ cd python-itunes
53+
$ python3 -m venv env
54+
$ . env/bin/activate
55+
$ pip install --editable ".[dev]"
2056
21-
.. note::
57+
If you get an error like this::
2258

23-
If you're using python version <= 2.5 you'll need to install simplejson. E.g:
59+
ERROR: File "setup.py" or "setup.cfg" not found. Directory cannot be installed in editable mode: /path/to/python-itunes
60+
(A "pyproject.toml" file was found, but editable mode currently requires a setuptools-based build.)
2461

25-
::
62+
...your ``pip`` is too old.
63+
Upgrading the version installed in your venv
64+
will resolve the problem:
2665

27-
$ easy_install simplejson
66+
.. code-block:: sh
2867
68+
$ pip install --upgrade pip
69+
70+
Whenever you open a new terminal,
71+
don't forget to re-activate the venv:
72+
73+
.. code-block:: sh
74+
75+
$ cd python-itunes
76+
$ . env/bin/activate
77+
78+
Then, when you ``import itunes`` in a Python REPL,
79+
changes made to the library source
80+
are available immediately without reinstalling the package.
2981

3082
Examples
3183
--------
3284

3385
Search
3486
~~~~~~
35-
::
87+
88+
.. code-block:: python
3689
3790
import itunes
38-
91+
3992
# Search band U2
4093
artist = itunes.search_artist('u2')[0]
4194
for album in artist.get_albums():
@@ -52,7 +105,7 @@ Search
52105
53106
# Global Search 'Beatles'
54107
items = itunes.search(query='beatles')
55-
for item in items:
108+
for item in items:
56109
print '[' + item.type + ']', item.get_artist(), item.get_name(), item.get_url(), item.get_release_date()
57110
58111
# Search 'Angry Birds' game
@@ -69,20 +122,20 @@ Search
69122
Lookup
70123
~~~~~~
71124

72-
::
125+
.. code-block:: python
73126
74127
import itunes
75128
76129
# Lookup Achtung Baby album by U2
77130
U2_ACHTUNGBABY_ID = 475390461
78131
album = itunes.lookup(U2_ACHTUNGBABY_ID)
79-
132+
80133
print album.get_url()
81134
print album.get_artwork()
82-
135+
83136
artist = album.get_artist()
84137
tracks = album.get_tracks()
85-
138+
86139
# Lookup song One from Achtung Baby album by U2
87140
U2_ONE_ID = 475391315
88141
track = itunes.lookup(U2_ONE_ID)
@@ -93,7 +146,7 @@ Lookup
93146
Caching JSON results
94147
~~~~~~~~~~~~~~~~~~~~
95148

96-
::
149+
.. code-block:: python
97150
98151
import itunes
99152
@@ -106,6 +159,6 @@ Caching JSON results
106159
Tests
107160
-----
108161

109-
::
162+
.. code-block:: sh
110163
111-
$ nosetests tests
164+
$ pytest

0 commit comments

Comments
 (0)