Fix 'sdist' for tensorflow-core-ops. (#113)

Use the same trick as for `proto-lens-protoc`: hack the package description
during the `sdist` step to include the autogen directory in hs-source-dirs.
This commit is contained in:
Judah Jacobson 2017-05-10 16:29:31 -07:00 committed by GitHub
parent 64971c876a
commit aa9efa3aa1
1 changed files with 24 additions and 0 deletions

View File

@ -15,6 +15,11 @@
-- | Generates the wrappers for Ops shipped with tensorflow.
module Main where
import Distribution.PackageDescription
( PackageDescription(..)
, libBuildInfo
, hsSourceDirs
)
import Distribution.Simple.BuildPaths (autogenModulesDir)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo)
import Distribution.Simple
@ -44,6 +49,11 @@ generatingOpsWrappers = hooks
, haddockHook = \p l h f -> generateSources l >> haddockHook hooks p l h f
, replHook = \p l h f args -> generateSources l
>> replHook hooks p l h f args
, sDistHook = \p maybe_l h f -> case maybe_l of
Nothing -> error "Can't run sdist; run 'cabal configure first."
Just l -> do
generateSources l
sDistHook hooks (fudgePackageDesc l p) maybe_l h f
}
where
flagsBuilder dir = OpGenFlags
@ -63,6 +73,20 @@ generatingOpsWrappers = hooks
Right x -> Text.writeFile (outputFile flags)
(prettyLazyText 80 $ docOpList flags x)
-- | Add the autogen directory to the hs-source-dirs of all the targets in the
-- .cabal file. Used to fool 'sdist' by pointing it to the generated source
-- files.
fudgePackageDesc
:: LocalBuildInfo -> PackageDescription -> PackageDescription
fudgePackageDesc lbi p = p
{ library =
(\lib -> lib { libBuildInfo = fudgeBuildInfo (libBuildInfo lib) })
<$> library p
}
where
fudgeBuildInfo bi =
bi { hsSourceDirs = autogenModulesDir lbi : hsSourceDirs bi }
blackList =
[ -- Requires the "func" type:
"SymbolicGradient"