easlice / bandcamp-downloader

Download your bandcamp collection using this python script.
MIT License
281 stars 34 forks source link

setup.py review #18

Closed JOJ0 closed 4 months ago

JOJ0 commented 1 year ago

Hi, I finally found time to review your new setup.py

$ pyenv virtualenv 3.10.8 testbandcamp
$ pyenv activate testbandcamp
$ pip list
Package    Version
---------- -------
pip        22.2.2
setuptools 63.2.0

[notice] A new release of pip available: 22.2.2 -> 23.0.1
[notice] To update, run: python3.10 -m pip install --upgrade pip

$ pip install -e .
Obtaining file:///home/jojo/git/bandcamp-downloader
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Collecting tqdm
  Downloading tqdm-4.65.0-py3-none-any.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.1/77.1 kB 2.1 MB/s eta 0:00:00
Collecting browser-cookie3
  Using cached browser_cookie3-0.17.1-py3-none-any.whl (14 kB)
Collecting bs4
  Using cached bs4-0.0.1-py3-none-any.whl
Collecting requests
  Using cached requests-2.28.2-py3-none-any.whl (62 kB)
Collecting jeepney
  Using cached jeepney-0.8.0-py3-none-any.whl (48 kB)
Collecting lz4
  Downloading lz4-4.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 4.5 MB/s eta 0:00:00
Collecting pycryptodomex
  Using cached pycryptodomex-3.17-cp35-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB)
Collecting beautifulsoup4
  Downloading beautifulsoup4-4.12.0-py3-none-any.whl (132 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 132.2/132.2 kB 5.4 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.3/199.3 kB 6.6 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.9/140.9 kB 4.0 MB/s eta 0:00:00
Collecting soupsieve>1.2
  Downloading soupsieve-2.4-py3-none-any.whl (37 kB)
Building wheels for collected packages: bandcamp-downloader
  Building editable for bandcamp-downloader (pyproject.toml) ... done
  Created wheel for bandcamp-downloader: filename=bandcamp_downloader-0.1.0-0.editable-py3-none-any.whl size=6362 sha256=d82b6c66d24e042a331aae8b3c3456a97969b13ad4a1982a21e2d4dbdc6356c3
  Stored in directory: /tmp/pip-ephem-wheel-cache-rlicu7c2/wheels/2f/9c/ed/4def8dda1805d1eb5c3469ca6607b63b3254938b86dba12ce4
Successfully built bandcamp-downloader
Installing collected packages: urllib3, tqdm, soupsieve, pycryptodomex, lz4, jeepney, idna, charset-normalizer, certifi, requests, browser-cookie3, beautifulsoup4, bs4, bandcamp-downloader
Successfully installed bandcamp-downloader-0.1.0 beautifulsoup4-4.12.0 browser-cookie3-0.17.1 bs4-0.0.1 certifi-2022.12.7 charset-normalizer-3.1.0 idna-3.4 jeepney-0.8.0 lz4-4.3.2 pycryptodomex-3.17 requests-2.28.2 soupsieve-2.4 tqdm-4.65.0 urllib3-1.26.15

[notice] A new release of pip available: 22.2.2 -> 23.0.1
[notice] To update, run: python3.10 -m pip install --upgrade pip

$ which bandcamp-downloader
bandcamp-downloader not found

$ ./bandcamp-downloader
zsh: command not found: bandcamp-downloader

I think your setup.py is missing the part where it installs an actual cli wraper to the bin-path of the virtualenv / the env currently active / the user-env

An entry-points-part like this:

https://github.com/JOJ0/synadm/blob/2dbe0c62e25c6c293913fd1e7986ba1ccaf9ec22/setup.py#L59-L62

If you have that, usually bandcamp-downloader should be executable without the ./ in front of it.

JOJ0 commented 1 year ago

I think you could close the other issue btw.

JOJ0 commented 1 year ago

Sure you could go the other route as you state in the readme now that still bancamp-downloader needs to be executed right from the repo with ./bandcamp-downloader.py, I still find the easiest way is when it gets installed with an entry point automatically. I think there would be some prerequisistes though. You would have to put the .py files together with an empty __init__.py file into a subdirectory. That then makes it "a package", and from such a package the entry point, which is a function (often called main() in a package, can be pulled (see the repo link I posted above. Some syntax with : in it.

Anyway, back to your approch of keeping the .py file in the root of the repo:

Somehow the file bandcamp-downloader.py is not executable after I did a git pull. I see you aded the exec flag in one of your commits but it doesn't seem to work, at least on my end. Maybe you test again with a fresh repo and fresh venv.

Hope that helps at least a little.

JOJ0 commented 1 year ago

Docs about entry points: https://packaging.python.org/en/latest/specifications/entry-points/#use-for-scripts

easlice commented 10 months ago

Hey @JOJ0 , I know it's been a while, but I took another look at this.

In all honesty, I don't like the idea of using entry_points if it requires moving the base script into a subfolder. I don't like complicating running the thing any more than I have to for users that are not command line or tech savvy.

That said, I found that I can use a scripts section and it seems to work just fine, at least in my test environment. It seems this isn't recommended over entry_points for bigger or more complicated projects, but this isn't a bigger and more complicated project. (And I hope it never gets to be one.)

Do you want to give it a shot? It looks like if you do pip install [-e] . that it adds bandcamp-downloader.py to your path and things just work after that.

easlice commented 4 months ago

Closing this, as I think the request has been resolved. But if it hasn't then feel free to re-open it.