forked from Dav1dde/glad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
glad: add option to make glad builds reproducible.
gh: Dav1dde#162
- Loading branch information
Showing
19 changed files
with
67,010 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
recursive-include glad *.c *.h *.d *.volt *.rs *.toml | ||
recursive-include glad *.c *.h *.d *.volt *.rs *.toml *.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os.path | ||
import logging | ||
import shutil | ||
|
||
try: | ||
from urlparse import urlparse | ||
except ImportError: | ||
from urllib.parse import urlparse | ||
|
||
try: | ||
from pkg_resources import resource_exists, resource_stream | ||
except ImportError: | ||
def resource_exists(*args, **kwargs): | ||
return False | ||
|
||
def resource_stream(*args, **kwargs): | ||
return None | ||
|
||
|
||
BASE_PATH = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
logger = logging.getLogger('glad.files') | ||
|
||
|
||
class GladFileException(Exception): | ||
pass | ||
|
||
|
||
def open_local(name, *args, **kwargs): | ||
# use pkg_resources when available, makes it work in zipped modules | ||
# or other environments | ||
if resource_exists(__name__, name): | ||
logger.info('opening packaged resource: %r', name) | ||
return resource_stream(__name__, name) | ||
|
||
# fallback to filesystem | ||
logger.info('opening packaged path: %r', name) | ||
local_path = os.path.normpath(os.path.join(BASE_PATH, os.path.join(name))) | ||
if not local_path.startswith(BASE_PATH): | ||
raise GladFileException('unsafe file path, won\'t open {!r}'.format(local_path)) | ||
return open(local_path, *args, **kwargs) | ||
|
||
|
||
class StaticFileOpener(object): | ||
def urlopen(self, url, data=None, *args, **kwargs): | ||
logger.debug('intercepted attempt to retrieve remote resource %r', url) | ||
if data is not None: | ||
raise GladFileException('can not resolve requests with payload') | ||
|
||
filename = urlparse(url).path.rsplit('/', 1)[-1] | ||
return open_local(filename, 'rb') | ||
|
||
def urlretrieve(self, url, filename, *args, **kwargs): | ||
with self.urlopen(url) as src: | ||
with open(filename, 'wb') as dst: | ||
shutil.copyfileobj(src, dst) |
Oops, something went wrong.