Comments (3)
I solved this problem by creating my own task and plugin in gradle that imports this plugin.
Here's the code I used to fix this problem for anyone else that needs it (both are in groovy in our buildSrc project).
You'll have to add the imports yourself.
class PythonEggDistributionPlugin extends PythonBasePlugin {
public final static String TASK_PACKAGE_EGG_DIST = 'packageEggDist'
@Override
void applyTo(Project project) {
/**
* Create a Python source distribution.
*/
def eggDistPackageTask = project.tasks.create(TASK_PACKAGE_EGG_DIST, SourceEggTask) {
dependsOn(project.tasks.getByName(PythonPlugin.TASK_INSTALL_PROJECT))
}
def eggDistArtifactInfo = [
name: project.name,
type: 'egg',
extension: 'egg',
file: eggDistPackageTask.getEggDistOutput(),
builtBy: project.tasks.getByName(TASK_PACKAGE_EGG_DIST),
]
project.artifacts.add(PythonPlugin.CONFIGURATION_DEFAULT, eggDistArtifactInfo)
}
}
/**
* A task that allows us to create a python egg piggy backing on the linkedin python plugin
*/
class SourceEggTask extends DefaultTask implements FailureReasonProvider {
private final TeeOutputContainer container = new TeeOutputContainer();
@TaskAction
public void packageEggDist() {
// Fixes a groovy scoping problem
final TeeOutputContainer containerAlias = container
final PythonExtension settings = getProject().getExtensions().getByType(PythonExtension.class);
getProject().exec(new Action<ExecSpec>() {
@Override
public void execute(ExecSpec execSpec) {
containerAlias.setOutputs(execSpec);
execSpec.environment(settings.pythonEnvironmentDistgradle);
execSpec.commandLine(
VirtualEnvExecutableHelper.getPythonInterpreter(settings.getDetails()),
"setup.py",
"bdist_egg",
"--dist-dir",
getDistDir().getAbsolutePath());
}
});
}
@OutputFile
public File getEggDistOutput() {
Project project = getProject();
return new File(getDistDir(),
String.format(
"%s-%s-py2.7.egg",
project.getName(),
/*
* For some reason the build spits out a file with
* the `-` character replaced by the `_` character.
*/
project.getVersion().toString().replace("-", "_")));
}
private File getDistDir() {
return new File(getProject().getBuildDir(), "distributions");
}
@Override
public String getReason() {
return container.getCommandOutput();
}
}
from pygradle.
Note: I originally had the getEggDistOutput
method wrong. I have since fixed it as you can see above.
from pygradle.
Updated version for newest release of plugin:
class SourceEggTask extends AbstractPythonMainSourceDefaultTask {
public SourceEggTask() {
args("setup.py",
"bdist_egg",
"--dist-dir",
getDistDir().getAbsolutePath())
}
@Override
public void processResults(ExecResult execResult) {
}
@OutputFile
public File getEggDistOutput() {
Project project = getProject();
return new File(getDistDir(),
String.format(
"%s-%s-py2.7.egg",
project.getName(),
/*
* For some reason the build spits out a file with
* the `-` character replaced by the `_` character.
*/
project.getVersion().toString().replace("-", "_")));
}
private File getDistDir() {
return new File(getProject().getBuildDir(), "distributions");
}
}
from pygradle.
Related Issues (20)
- Can anyone explain this early problem? HOT 1
- 'term:skip-covered' should be used in preference to 'term' HOT 7
- Can we update the documentation to provide a full working example for 2020 onwards. HOT 2
- Build issue with pygradle HOT 1
- How do use Pygradle tasks with a custom virtualenv name.
- Set up a bounty system
- File not found error while executing gunicorn command
- Does PyGradle work with Python3.8 - re.py line 145 enum no attribute IntFlag HOT 2
- Why pygradle uses setuptools-git?
- "Unable to find or execute python" python details set version=3 only works for python3.7 HOT 1
- Resolve wheel based dependencies
- Spotless now integrates with black, but it could be better
- Issue with creating a virtualenv. HOT 3
- Struggling with virtualenv and sys.prefix
- functools32 dependency in installBuildRequirements
- build issue - createVirtualEnvironment -> pygradleBootstrap HOT 7
- pass pexOptions to plugin HOT 1
- Class org.gradle.api.internal.project.DefaultProject_Decorated does not implement the requested interface org.gradle.api.internal.file.FileOperations HOT 4
- Exclude transitive dependency from requirements.txt HOT 1
- Is this project still actively maintained? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygradle.