Skip to content

Dereference directory symlink in src/main/python/ #768

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

Closed
hoxu opened this issue Feb 10, 2021 · 1 comment · Fixed by #786
Closed

Dereference directory symlink in src/main/python/ #768

hoxu opened this issue Feb 10, 2021 · 1 comment · Fixed by #786

Comments

@hoxu
Copy link
Contributor

hoxu commented Feb 10, 2021

Adding symlinks to files under src/main/python dereferences the files.

How to add a directory symlink in src/main/python and deference it so that the directory it points to gets included? It seems by default directory symlinks under src/main/python are simply ignored.

@hoxu
Copy link
Contributor Author

hoxu commented Feb 11, 2021

Further digging revealed that symlinked directories are dereferenced properly, and copied to target/dist/$name/.

However, setup.py -v clean --all bdist_wheel does not include the copied files in the tarball, because they are not included in packages or py_modules.

This appears to be a bug in pybuilder: it seems to dereference directory symlinks when copying the files, but not when generating packages/py_modules.

Relevant source code is probably pybuilder.plugins.python.core_plugin.{list_packages,list_modules}:

def list_packages(project):
source_path = project.expand_path("$" + PYTHON_SOURCES_PROPERTY)
result = []
for root, dirs, files in walk(source_path):
if "__init__.py" in files:
result.append(relpath(root, source_path).replace(sep, "."))
return sorted(result)
def list_modules(project):
source_path = project.expand_path("$" + PYTHON_SOURCES_PROPERTY)
result = []
for potential_module_file in listdir(source_path):
potential_module_path = np(jp(source_path, potential_module_file))
if isfile(potential_module_path) and potential_module_file.endswith(".py"):
result.append(potential_module_file[:-3])
return sorted(result)

os.walk defaults to followlinks=False.

arcivanov added a commit to arcivanov/pybuilder that referenced this issue Sep 12, 2021
Modules are all modules that are not in packages, recursively
Packages are all packages that contain __init__.py
Process symlinks
Add integration tests

fixes pybuilder#768
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Sep 12, 2021
Modules are all modules that are not in packages, recursively
Packages are all packages that contain __init__.py
Process symlinks
Add integration tests

fixes pybuilder#768
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Sep 12, 2021
Modules are all modules that are not in packages, recursively
Packages are all packages that contain __init__.py
Process symlinks
Add integration tests

fixes pybuilder#768
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Sep 12, 2021
Modules are all modules that are not in packages, recursively
Packages are all packages that contain __init__.py
Process symlinks
Add integration tests

fixes pybuilder#768
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Sep 12, 2021
Modules are all modules that are not in packages, recursively
Packages are all packages that contain __init__.py
Process symlinks
Add integration tests

fixes pybuilder#768
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Sep 12, 2021
Modules are all modules that are not in packages, recursively
Packages are all packages that contain __init__.py
Process symlinks
Add integration tests

fixes pybuilder#768
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Sep 12, 2021
Modules are all modules that are not in packages, recursively
Packages are all packages that contain __init__.py
Process symlinks
Add integration tests

fixes pybuilder#768
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant