Coder Social home page Coder Social logo

Comments (3)

realill avatar realill commented on June 10, 2024

I have the same problem on Ubuntu 20.04, looks like this code does not completely write file:

        InputStream wheelApiResource = ProbeVenvInfoAction.class.getClassLoader()
            .getResourceAsStream("templates/wheel-api.py");

        byte[] buffer = new byte[wheelApiResource.available()];
        wheelApiResource.read(buffer);

        File probeDir = new File(project.getBuildDir(), PROBE_DIR_NAME);
        probeDir.mkdirs();

        OutputStream outStream = new FileOutputStream(getPythonFileForSupportedWheels(probeDir));
        outStream.write(buffer);

from pygradle.

realill avatar realill commented on June 10, 2024

Ok, I think I found two solutions to this problem:
First is to use JDK8, problem does not occur there.

Another one patching ./pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/tasks/action/ProbeVenvInfoAction.java with following code:

    private static void doProbe(Project project, PythonDetails pythonDetails,
                          EditablePythonAbiContainer editablePythonAbiContainer) throws IOException {
        
        File probeDir = new File(project.getBuildDir(), PROBE_DIR_NAME);
        probeDir.mkdirs();

        byte[] buffer = new byte[1024];
        try(InputStream wheelApiResource = ProbeVenvInfoAction.class.getClassLoader()
            .getResourceAsStream("templates/wheel-api.py");
            OutputStream outStream = new FileOutputStream(getPythonFileForSupportedWheels(probeDir))) {
          int size;
          while((size = wheelApiResource.read(buffer)) > 0) {
            outStream.write(buffer, 0, size);
          }
       }

        File supportedAbiFormatsFile = getSupportedAbiFormatsFile(probeDir, pythonDetails);
        project.exec(execSpec -> {
            execSpec.commandLine(pythonDetails.getVirtualEnvInterpreter());
            execSpec.args(getPythonFileForSupportedWheels(probeDir));
            execSpec.args(supportedAbiFormatsFile.getAbsolutePath());
        });

        /*
         * The code for this function was originally here.
         * Still making this call to benefit AbstractPythonInfrastructureDefaultTask,
         * although it's not necessary for InstallVirtualEnvironmentTask because
         * GetProbedTagsTask will get the tags.
         */
        getSavedTags(pythonDetails, editablePythonAbiContainer, supportedAbiFormatsFile);
    }

After recompiling and doing ./gradlew publishPluginMavenPublicationToMavenLocal plugin seem to work fine locally.

from pygradle.

alexogar avatar alexogar commented on June 10, 2024

First is to use JDK8, problem does not occur there.

Tried with jdk8 - same issue

from pygradle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.