1
0
Fork 0
mirror of https://github.com/tensorflow/haskell.git synced 2024-11-23 03:19:44 +01:00

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

View file

@ -15,6 +15,11 @@
-- | Generates the wrappers for Ops shipped with tensorflow. -- | Generates the wrappers for Ops shipped with tensorflow.
module Main where module Main where
import Distribution.PackageDescription
( PackageDescription(..)
, libBuildInfo
, hsSourceDirs
)
import Distribution.Simple.BuildPaths (autogenModulesDir) import Distribution.Simple.BuildPaths (autogenModulesDir)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo) import Distribution.Simple.LocalBuildInfo (LocalBuildInfo)
import Distribution.Simple import Distribution.Simple
@ -44,6 +49,11 @@ generatingOpsWrappers = hooks
, haddockHook = \p l h f -> generateSources l >> haddockHook hooks p l h f , haddockHook = \p l h f -> generateSources l >> haddockHook hooks p l h f
, replHook = \p l h f args -> generateSources l , replHook = \p l h f args -> generateSources l
>> replHook hooks p l h f args >> 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 where
flagsBuilder dir = OpGenFlags flagsBuilder dir = OpGenFlags
@ -63,6 +73,20 @@ generatingOpsWrappers = hooks
Right x -> Text.writeFile (outputFile flags) Right x -> Text.writeFile (outputFile flags)
(prettyLazyText 80 $ docOpList flags x) (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 = blackList =
[ -- Requires the "func" type: [ -- Requires the "func" type:
"SymbolicGradient" "SymbolicGradient"