Skip to content
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

Packaging excludes .pyc files if there is no corresponding .py file #1191

Closed
mwiebe opened this issue Nov 13, 2024 · 2 comments
Closed

Packaging excludes .pyc files if there is no corresponding .py file #1191

mwiebe opened this issue Nov 13, 2024 · 2 comments

Comments

@mwiebe
Copy link

mwiebe commented Nov 13, 2024

We've got a case where we are building packages that incorporate third party .pyc files that are not shipped with the .py files they came from. Rattler-build is excluding these files from the package due to the code in

pub fn filter_pyc(path: &Path, new_files: &HashSet<PathBuf>) -> bool {

/// We check that each `pyc` file in the package is also present as a `py` file.
/// This is a temporary measure to avoid packaging `pyc` files that are not
/// generated by the build process.
pub fn filter_pyc(path: &Path, new_files: &HashSet<PathBuf>) -> bool {
...

In this case the .pyc files that lack their .py file are intentional, so we do not want them excluded. Is it reasonable to switch this logic?

For a workaround, we've implemented our recipes to rename all .pyc files to .pyc2, something like:

for PYC in "$PREFIX/.../*.pyc; do
    mv "$PYC" "${PYC}2"
done

and then in an environment activation script, rename those back to .pyc:

if [ -f \$CONDA_PREFIX/.../known_module.pyc2 ]; then
    for PYC2 in "\$CONDA_PREFIX/.../*.pyc2; do
        mv "\$PYC2" "\${PYC2%2}"
    done
fi
@wolfv
Copy link
Member

wolfv commented Nov 16, 2024

Hi @mwiebe - thanks for the detailed bug report! I think we can adjust the logic to ignore only .pyc files where a previously installed package had a .py file.

@wolfv
Copy link
Member

wolfv commented Dec 9, 2024

Fixed in #1246 and added a test. Going to be released tomorrow if things go right! :)

@wolfv wolfv closed this as completed Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants