Skip to content

Refactor/project layout#35

Merged
Notenlish merged 38 commits intoNotenlish:mainfrom
Gallophostrix:refactor/project-layout
Jun 23, 2025
Merged

Refactor/project layout#35
Notenlish merged 38 commits intoNotenlish:mainfrom
Gallophostrix:refactor/project-layout

Conversation

@Gallophostrix
Copy link
Contributor

@Gallophostrix Gallophostrix commented Jun 5, 2025

This might close #12, makes the user able to use the CLI from everywhere using for example anifetch -W 70 -C -c "--symbols ascii --fg-only", by going in the anifetch folder, and using either pip install . or pipx install . if they don't want to create a venv.

The project is now composed of a src/anifetch folder, containing the main program (separated in different parts for future adaptation/tests), a tools folder, containing benchmark.py for devs, a docs folder for future documentation and a snap folder (for future snap integration #7 ).
This version is also based on the main anifetch version, merged with #30 (hence solving #31 ) , #32 , but also #6 .

The pip/pipx installation allows the user to have access to the asset folder (with the examples), but tools is only available for devs from the downloaded GitHub repo.

@Immelancholy
Copy link
Contributor

Immelancholy commented Jun 5, 2025

How much will I need to change on the Nix end of things? I've been busy for a hot minute but no biggy if so cos I should have some time later this week. Already I can see I'll have to change the paths to files for some stuff, but otherwise how much will I need to do? Any deps I need to add or anything?

@Gallophostrix
Copy link
Contributor Author

Mmmh I have to admit that I'm not sure... I tried to leave it as unchanged as possible as I'm not very familiar with Nix.
But it seems to me that we indeed have to change at least paths in anifetch.nix. I'm starting to work on a snap integration (btw, I didn't expect it to be so hard!), and some elements seem to look like a few lines of some of the Nix files (like bin/anifetch)

I don't know if you will really need to change something else, but feel free to modify anything if you think this structure isn't efficient/clear enough!

If I can, I'll try to somehow find a solution as well for Nix, even though I think you're way better, smarter and quicker than me on this topic 🫡

@Immelancholy
Copy link
Contributor

Mmmh I have to admit that I'm not sure... I tried to leave it as unchanged as possible as I'm not very familiar with Nix. But it seems to me that we indeed have to change at least paths in anifetch.nix. I'm starting to work on a snap integration (btw, I didn't expect it to be so hard!), and some elements seem to look like a few lines of some of the Nix files (like bin/anifetch)

I don't know if you will really need to change something else, but feel free to modify anything if you think this structure isn't efficient/clear enough!

If I can, I'll try to somehow find a solution as well for Nix, even though I think you're way better, smarter and quicker than me on this topic 🫡

Sounds good! Nw abt the Nix stuff I'll have it handled, I'll submit a pr for it on your branch?? (Idk my git knowledge is a bit scuffed lol).

@Gallophostrix
Copy link
Contributor Author

Gallophostrix commented Jun 6, 2025

Well, if this PR works fine for you and if @Notenlish agrees with the PR idea, I can add you as a contributor to my fork, so you can directly work on this branch, without needing to submit PRs on it (but yeah, I'm not familiar with git contributions too, so idk if it'll work correctly!)

Then, if this PR gets merged to this repo, we'll be able to directly work on it

@Notenlish
Copy link
Owner

I really like this, but I also would like to merge @Immelancholy's threading PR #17 and potentially my multi-cache PR #40 .
I dont really know what's the best way to move on with this, do we merge these PR's first, or yours first? Or do we just merge all of the changes into a single mega PR lol

@Gallophostrix
Copy link
Contributor Author

@Notenlish that may be a great idea, so still import the assets, but directly download them in ~/.local/share/anifetch for example after pip/snap download?

@Notenlish
Copy link
Owner

Notenlish commented Jun 21, 2025

I added a new dependency called platformdirs which handles all data paths for us, its cross-platform too so theoretically anifetch supports windows and macos now.
Also I added a warning message for missing fastfetch installation, as well as a help text for when video file could not be found and ffmpeg could not be found

@Notenlish
Copy link
Owner

but directly download them in ~/.local/share/anifetch for example after pip/snap download?

yeah
Maybe we could even ask the user to automatically copy a video/gif that they used with anifetch to the ~/.local/share/anifetch/assets folder so they can use it later

@Gallophostrix
Copy link
Contributor Author

but directly download them in ~/.local/share/anifetch for example after pip/snap download?

yeah Maybe we could even ask the user to automatically copy a video/gif that they used with anifetch to the ~/.local/share/anifetch/assets folder so they can use it later

Sounds great! It would make everything easier for non-tech users, and maybe we could use this layout to make multi-caching easier

@Gallophostrix
Copy link
Contributor Author

but directly download them in ~/.local/share/anifetch for example after pip/snap download?

yeah Maybe we could even ask the user to automatically copy a video/gif that they used with anifetch to the ~/.local/share/anifetch/assets folder so they can use it later

This new version should add this feature! Now, the first execution of anifetch creates the assets folder with example.mp4 inside. Then, users can add files inside, so they directly can use anifetch file.mp4

The original assets folder still is in src/anifetch for now, but as we have a new folder in ~/.local/share/anifetch, it should be alright

@Notenlish
Copy link
Owner

so, what do we have left to do?

@Gallophostrix
Copy link
Contributor Author

@Notenlish that looks great, I'm starting to make a branch merging the refactoring and your multi-caching from #40, but this version seems to work pretty well, at least for us!

The next "classical" step would be to integrate anifetch with snap and flatpack tho

@Notenlish
Copy link
Owner

The next "classical" step would be to integrate anifetch with snap and flatpack tho

yeah im working on that rn

@Notenlish
Copy link
Owner

@Gallophostrix are we sure we want a snap release? Maybe we could just do a flatpack release? Snap seems kinda sketchy https://linuxmint-user-guide.readthedocs.io/en/latest/snap.html

@Gallophostrix
Copy link
Contributor Author

@Gallophostrix are we sure we want a snap release? Maybe we could just do a flatpack release? Snap seems kinda sketchy https://linuxmint-user-guide.readthedocs.io/en/latest/snap.html

Wow didn't know about it, thanks for the info... I hope it won't impact other more famous apps like Spotify or whatever...
In this case, you're right, it would make everything easier for us as well!

@Gallophostrix
Copy link
Contributor Author

By the way @Notenlish , I tried to add the multi-caching, could you check this branch by any chance? Especially the .sh file, I'm not really sure how to update it!

@Notenlish
Copy link
Owner

I kinda got flatpak to work

@Notenlish
Copy link
Owner

Notenlish commented Jun 23, 2025

But you need to spesifically tell flatpak to use anifetch, which is kinda ugly

we could just make people use pipx to install it from pypi
but problem with pypi is that it cant install native libraries, only python dependencies

@Notenlish
Copy link
Owner

I think we could just do a pypi release + a bash script for installing the native libraries.

@Notenlish
Copy link
Owner

I tried to make a flatpak branch but cant commit to it for some reason. I'll just put the files in this comment in case we want to do a flatpak release.

org.anifetch.anifetch.yaml:

id: org.anifetch.anifetch
runtime: org.freedesktop.Platform
runtime-version: "23.08"
sdk: org.freedesktop.Sdk

command: anifetch

finish-args:
  - --share=ipc
  - --socket=pulseaudio
  - --filesystem=home # (use with caution)
  - --filesystem=host

modules:
  - name: python-dependencies
    buildsystem: simple
    build-commands:
      - pip3 install --no-index --find-links=. platformdirs setuptools # Installs platformdirs
    sources:
      - type: file
        url: https://files.pythonhosted.org/packages/fe/39/979e8e21520d4e47a0bbe349e2713c0aac6f3d853d0e5b34d76206c439aa/platformdirs-4.3.8-py3-none-any.whl
        sha256: ff7059bb7eb1179e2685604f4aaf157cfd9535242bd23742eadc3c13542139b4
        dest-filename: platformdirs-4.3.8-py3-none-any.whl
        x-checker-data: # Used by Flatpak's update checker to find new versions (Optional)
          type: pypi
          module-name: platformdirs
      - type: file  # setuptools
        url: https://files.pythonhosted.org/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl
        sha256: 062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922
    
  - name: anifetch-app
    buildsystem: simple
    build-commands:
      - pip3 install --no-index --prefix=/app --find-links=. --no-build-isolation .
    sources:  # maybe flatpack could just install from the git repo, not the pypi release?
      - type: dir  # use dir if the flatpak manifest is in the same directory as the pyproject.toml
        path: .
      - type: file
        url: https://files.pythonhosted.org/packages/fe/39/979e8e21520d4e47a0bbe349e2713c0aac6f3d853d0e5b34d76206c439aa/platformdirs-4.3.8-py3-none-any.whl
        sha256: ff7059bb7eb1179e2685604f4aaf157cfd9535242bd23742eadc3c13542139b4
        dest-filename: platformdirs-4.3.8-py3-none-any.whl
        x-checker-data: # Used by Flatpak's update checker to find new versions (Optional)
          type: pypi
          module-name: platformdirs
      - type: file  # setuptools
        url: https://files.pythonhosted.org/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl
        sha256: 062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922
  
  - name: lzip  # needed to unpack ed's .tar.lz
    buildsystem: autotools
    sources:
      - type: archive
        url: https://download.savannah.gnu.org/releases/lzip/lzip-1.25.tar.gz
        sha256: 09418a6d8fb83f5113f5bd856e09703df5d37bae0308c668d0f346e3d3f0a56f
    cleanup:
      - '*'
  
  - name: ed  # some dependency of bc
    buildsystem: autotools
    build-commands:
        - ./configure --prefix=/app
        - make -j$FLATPAK_BUILDER_N_JOBS
        - make install
    sources:
      - type: archive
        url: https://mirror.ihost.md/gnu/ed/ed-1.21.1.tar.lz
        sha256: d6d0c7192b02b0519c902a93719053e865ade5a784a3b327d93d888457b23c4b
    cleanup:
      - '*'
  
  - name: bc
    buildsystem: autotools
    sources:
      - type: archive
        sha256: 62adfca89b0a1c0164c2cdca59ca210c1d44c3ffc46daf9931cf4942664cb02a
        url: https://ftp.gnu.org/gnu/bc/bc-1.07.1.tar.gz
        x-checker-data:
          type: gnu
          module-name: bc
  
  - name: chafa
    buildsystem: autotools
    config-opts:
      - --prefix=/app
    cleanup:
      - '*'
    sources:
      - type: archive
        sha256: 4a25debb71530baf0a748b15cfee6b8da6b513f696d9484987eaf410ecce1129
        url: https://hpjansson.org/chafa/releases/chafa-1.16.1.tar.xz
    build-options:
      build-args:
        - --share=network


add-extensions:
  org.freedesktop.Platform.ffmpeg:
    version: '23.08'
    directory: lib/ffmpeg

commands:
flatpak install flathub org.freedesktop.Sdk//23.08
flatpak install flathub org.freedesktop.Platform//23.08
flatpak-builder --force-clean build-dir org.anifetch.anifetch.yaml
flatpak-builder --user --install --force-clean build-dir org.anifetch.anifetch.yaml

@Notenlish Notenlish merged commit 7bc3c90 into Notenlish:main Jun 23, 2025
@Notenlish
Copy link
Owner

I think I just merged this twice, lol

@Gallophostrix
Copy link
Contributor Author

I think we could just do a pypi release + a bash script for installing the native libraries.

@Notenlish yeah, that could be a nice solution if we can't do it in another way

I tried to make a flatpak branch but cant commit to it for some reason. I'll just put the files in this comment in case we want to do a flatpak release.

Anyway, now that the refactor is merged, I think we don't need it anymore, just tell me if you still want to work on it, otherwise I'll just delete it so we can work on the main repo!

By the way, I can still keep the multi-caching branch for now, so we can finish this part too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor the Code

3 participants