Kozea / Kozea/pygal

support cx_freeze

Open
#108 1 comment 0 reactions 0 assignees View on GitHub
Feature request (AKA Feel free to make a pull request)
Dominant language
Python
Stars
2.8k
Forks
419
PR merge metrics
No merged PRs in 30d

Description

Hi I had a problem when use pygal with cx_freeze. I noticed in svg.py or utils.py, there are many codes related to access resource files like css or worldmap.svg like:

css = os.path.join(os.path.dirname(**file**), 'css', css)

the problem is when cx_freeze freeze the whole app, all dependencies will be packed into a single library.zip. os.path.join(os.path.dirname(**file**)) will give sth like xxx/library.zip/pygal/css/base.css which is an invalid path (library.zip is not a directory).
My work around is to use os.getcwd() instead and copy resource files.

Is it possible to provide a method to configure the path in Config class or sth like that? Thanks.

BTW: I just realized I could use zipfile.ZipFile to read files in a zip file and it worked; however We still need to modify the code quite a bit.

Contributor guide

Open the contributing guide

Research direction

Start by reading svg.py and utils.py, especially the resource paths for CSS and worldmap.svg. Reproduce the issue with cx_Freeze and inspect the suggested zipfile.ZipFile approach. Done means pygal can access its packaged resources from library.zip without requiring substantial user-side code changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.