-
Notifications
You must be signed in to change notification settings - Fork 207
BUG Copy Binder logo to avoid Window drive rel path error #745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I suspect you shouldn't need to manually copy any static file, just link to it properly. The question is how to do that. Usually / hopefully you can do it by doing a relpath between the example file and the |
The problem is that relative paths between 2 different drives on Windows doesn't exist. It may be possible with symbolic links but we might not want to mess with that. (I think I tried using a static path but it didn't work - though I didn't look into this too closely) No hurry, take a look on Tuesday. |
Codecov Report
@@ Coverage Diff @@
## master #745 +/- ##
=======================================
Coverage 97.50% 97.51%
=======================================
Files 32 32
Lines 3727 3741 +14
=======================================
+ Hits 3634 3648 +14
Misses 93 93
Continue to review full report at Codecov.
|
@lucyleeow pushed a commit. The critical point is that, regardless of what |
I think I've just missed something important. So all files in the package Can you show me where this is done in the code? |
It's done by |
Thanks, I had no idea Sphinx did this but it makes sense. |
Feel free to fix the path error in CIs, or I can push a fix in a couple of hours. Have meetings now |
Actually I think that all of those build warnings are bogus, they say files don't exist but it renders fine: I'm not sure how to avoid this warning. Maybe worth asking on the Sphinx listserv or GitHub. But we do need to make these warnings go away somehow because this will cause |
This might also be relevant And maybe |
I'll do this tomorrow |
Actually I wonder if the correct fix is to give the path to the |
Okay @lucyleeow I ended up giving up on the static idea and ended up with something that I think is pretty close to what you had. Can you take a look and merge if you're happy? |
os.path.dirname(fpath), 'images', 'binder_badge_logo.svg') | ||
os.makedirs(os.path.dirname(physical_path), exist_ok=True) | ||
if not os.path.isfile(physical_path): | ||
shutil.copyfile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for the test test_gen_binder_rst
we shouldn't copy the file over
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, isfile
is better than os.path.exists
that I used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try some tmpdir
gymnastics...
Sorry can you clarify what |
sphinx_gallery/tests/test_binder.py
Outdated
@@ -115,9 +116,10 @@ def apptmp(): | |||
assert url == expected | |||
|
|||
|
|||
def test_gen_binder_rst(): | |||
def test_gen_binder_rst(tmpdir): | |||
"""Check binder rst generated correctly.""" | |||
gallery_conf_base = {'gallery_dirs': None, 'src_dir': 'blahblah'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set 'gallery_dirs': None
to avoid copying files over when testing (with my poor implementation), but we can change this back to what it was before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a commit to be more like how it should in actually building
|
Okay thanks. But in Windows, if the path has to be relative to the build root, and the build root is in a different drive to |
|
@@ -445,7 +444,8 @@ def test_rebuild(tmpdir_factory, sphinx_app): | |||
new_app.build(False, []) | |||
status = new_app._status.getvalue() | |||
lines = [line for line in status.split('\n') if '0 removed' in line] | |||
assert re.match('.*[0|1] added, [1-9] changed, 0 removed$.*', | |||
# XXX on AppVeyor this can be 13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What can be 13?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of changed files in the regex below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay. DI]id this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did in previous runs because I added binder
to the tinybuild conf. Not sure if it's still there or not but I'm okay living with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I forgot binder changed. Can we change to:
assert re.match('.*[0|1] added, [1-9][0-3]? changed, 0 removed$.*',
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, feel free to push. You could even make the [1-9][0-3]?
only if on windows and use [1-9]
otherwise
Fixes #744
Copy Binder logo from package
_static
folder totarget_dir
/images.@larsoner happy to explore another solution.
Test: would changing appveyor setup such that
_static
is in a different drive be a good test? I am not so familiar with appveyor but if I add acd D:
here:sphinx-gallery/appveyor.yml
Lines 28 to 29 in 839c02b
would that work?