Skip to content

Commit

Permalink
Merge pull request #70 from astrofrog/deprecate-absolute
Browse files Browse the repository at this point in the history
Add back support for absolute source paths but deprecate it
  • Loading branch information
astrofrog authored Dec 7, 2023
2 parents 2e72417 + 1b2b0f7 commit 9f9cf7a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions extension_helpers/_setup_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,37 @@ def get_extensions(srcdir="."):
)
ext_modules.append(ext)

# Since https://github.com/astropy/extension-helpers/pull/67,
# extensions that used absolute paths in source names stopped working.
# Absolute paths in source paths are undesirable but we need to
# preserve backward-compatibility until we bump the major release,
# so we check for the case of absolute paths and emit a deprecation
# warning for now.
for extension in ext_modules:
sources = []
fixed = []
for source in extension.sources:
if os.path.isabs(source):
try:
source = os.path.relpath(source)
except ValueError:
# In some cases it's impossible to use a relative path, for
# instance if the source files are on a different drive. In
# this case there's not much we can do so we just proceed.
pass
fixed.append(source)
sources.append(source)
if fixed:
log.warning(
"Extension {} contains source files "
"({}) that are specified using an absolute "
"path, which will not be supported in future.".format(
extension.name, ", ".join(fixed)
)
)

extension.sources = sources

return ext_modules


Expand Down

0 comments on commit 9f9cf7a

Please sign in to comment.