Skip to content

Commit

Permalink
extend python package features
Browse files Browse the repository at this point in the history
  • Loading branch information
g-arjones committed Nov 18, 2021
1 parent 5535bdd commit bb1974b
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions lib/autobuild/packages/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.python(opts, &proc)

# Handler class to build python-based packages
class Python < Configurable
attr_accessor :buildflags, :installflags
attr_accessor :buildflags, :installflags, :build_egg_info

def configurestamp
"#{builddir}/configure-autobuild-stamp"
Expand All @@ -18,6 +18,7 @@ def configurestamp
def initialize(options)
@buildflags = []
@installflags = []
@build_egg_info = true
super
end

Expand All @@ -27,21 +28,41 @@ def install_mode?

def prepare_for_forced_build
super
FileUtils.rm_f configurestamp
@forced = true
end

def generate_build_command
command = ['python', 'setup.py', 'build']
command = %w[python setup.py]
command << "egg_info" if build_egg_info
command << "--egg-base=#{builddir}" if build_egg_info
command << "build"
command << "--build-base=#{builddir}"
command += buildflags.flatten
command
end

def with_tests
test_utility.task do
progress_start "running tests for %s",
done_message: "tests passed for %s" do
FileUtils.mkdir_p test_utility.source_dir
run "test",
Autobuild.tool_in_path("python"), "-m", "pytest",
"--tb=short",
"--junit-xml=#{File.join(test_utility.source_dir, "pytest.xml")}",
"--junit-prefix=#{name}",
"-o", "cache_dir=#{File.join(builddir, ".pytest_cache")}",
working_directory: srcdir
end
end
end

def generate_install_command
command = generate_build_command
command << 'install'
command << "--prefix=#{prefix}"
command << "--record=#{builddir}/install.log"
command << "--single-version-externally-managed"
command += installflags.flatten
command
end
Expand Down

0 comments on commit bb1974b

Please sign in to comment.