Skip to content
Browse files

Fix #31420, #31736: Centralize the version information in the build s…

…ystem.

The version info will be stored in the build system and the appropriate
constants generated at build time so that the version only has to be changed
in one place.

The only file that needs to be edited to change the IronPython version is Build.proj. This will generate CurrentVersion.Generated.cs for IronPython.dll, and the other IronPython assemblies plus the PythonContext get their version information from it. Only private methods were changed, so the public API is unbroken.

The DLR assemblies are unaffected by these changes.

This also adds a set of custom tasks in
Solutions/CustomTasks/CustomTasks.cs, which is built by Bootstrap.proj. All
of the projects have been modified to ensure that this is built before
anything else. The code generation for the version information depends on
these custom tasks.
  • Loading branch information...
1 parent b7185f1 commit a093f706abd28e7b903d8760ded5e9c52a42a71a @jdhardy committed Dec 13, 2011
View
77 Build.proj
@@ -1,20 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<!--<Import Project="CustomBuild.proj" Condition="Exist('CustomBuild.proj')" />-->
+ <Import Project="Solutions/Versioning.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-
- <StageDir>$(MSBuildProjectDirectory)\Stage\IronPython</StageDir>
- <PackageDir>$(MSBuildProjectDirectory)\Packages\IronPython</PackageDir>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <StageDir>$(MSBuildProjectDirectory)\Stage\IronPython-$(DisplayVersion)</StageDir>
+ <PackageDir>$(MSBuildProjectDirectory)\Packages\IronPython-$(DisplayVersion)</PackageDir>
<UtilDir>$(MSBuildProjectDirectory)\Util</UtilDir>
</PropertyGroup>
<BaseBuildDir>$(MSBuildProjectDirectory)\Bin</BaseBuildDir>
<BuildDir>$(BaseBuildDir)\$(Configuration)</BuildDir>
<v2BuildDir>$(BaseBuildDir)\v2$(Configuration)</v2BuildDir>
<Silverlight4BuildDir>$(BaseBuildDir)\Silverlight4$(Configuration)</Silverlight4BuildDir>
-</PropertyGroup>
+ </PropertyGroup>
<ItemGroup>
<BuildProject Include="Solutions\IronPython.sln">
@@ -47,7 +50,7 @@
<IronPythonBins Include="ipy64.exe" />
<IronPythonBins Include="ipyw.exe" />
<IronPythonBins Include="ipyw64.exe" />
-
+
<SilverlightBins Include="Chiron.exe" />
<SilverlightBins Include="Chiron.exe.config" />
@@ -75,54 +78,64 @@
<Target Name="Clean">
<MSBuild Projects="@(BuildProject)" BuildInParallel="true" Targets="Clean" />
</Target>
-
+
<Target Name="StageClean">
<RemoveDir Directories="$(StageDir)" />
</Target>
+<<<<<<< HEAD
<Target Name="Stage" DependsOnTargets="StageClean">
<Copy SourceFiles="@(DlrLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)" UseHardLinksIfPossible="true" />
<Copy SourceFiles="@(ClrDlrLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)" UseHardLinksIfPossible="true" />
<Copy SourceFiles="@(IronPythonLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)" UseHardLinksIfPossible="true" />
<Copy SourceFiles="@(IronPythonBins->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)" UseHardLinksIfPossible="true" />
<Copy SourceFiles="@(MiscFiles)" DestinationFolder="$(StageDir)" UseHardLinksIfPossible="true" />
<Copy SourceFiles="External.LCA_RESTRICTED\Languages\IronPython\27\LICENSE.txt" DestinationFolder="$(StageDir)" />
+=======
+ <Target Name="Stage" DependsOnTargets="StageClean;Build">
+ <Copy SourceFiles="@(DlrLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)" />
+ <Copy SourceFiles="@(ClrDlrLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)" />
+ <Copy SourceFiles="@(IronPythonLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)" />
+ <Copy SourceFiles="@(IronPythonBins->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)" />
+ <Copy SourceFiles="@(MiscFiles)" DestinationFolder="$(StageDir)" />
+ <Copy SourceFiles="External.LCA_RESTRICTED\Languages\IronPython\27\LICENSE.txt" DestinationFiles="$(StageDir)\License.StdLib.txt" />
+>>>>>>> 3ad15c5... Pull version numbers from the build system.
<MSBuild Projects="Languages\IronPython\StdLib\StdLib.pyproj" Properties="OutputPath=$(StageDir)\Lib" Targets="CopyFilesForZip" />
-
- <Copy SourceFiles="@(DocFiles)" DestinationFiles="@(DocFiles->'$(StageDir)\Doc\%(RecursiveDir)%(Filename)%(Extension)')" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(ToolFiles)" DestinationFiles="@(ToolFiles->'$(StageDir)\Tools\%(RecursiveDir)%(Filename)%(Extension)')" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(TutorialFiles)" DestinationFiles="@(TutorialFiles->'$(StageDir)\Tutorial\%(RecursiveDir)%(Filename)%(Extension)')" UseHardLinksIfPossible="true" />
-
- <Copy SourceFiles="@(DlrLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Silverlight\bin" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(SilverlightDlrLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Silverlight\bin" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(IronPythonLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Silverlight\bin" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(SilverlightBins->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Silverlight\bin" UseHardLinksIfPossible="true" />
-
- <Copy SourceFiles="@(SilverlightScriptFiles)" DestinationFiles="@(SilverlightScriptFiles->'$(StageDir)\Silverlight\scripts\%(RecursiveDir)%(Filename)%(Extension)')" UseHardLinksIfPossible="true" />
-
- <Copy SourceFiles="@(DlrLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net40" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(ClrDlrLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net40" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(IronPythonLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net40" UseHardLinksIfPossible="true" />
-
- <Copy SourceFiles="@(DlrLibs->'$(v2BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net35" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(ClrDlrLibs->'$(v2BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net35" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(v2DlrLibs->'$(v2BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net35" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(IronPythonLibs->'$(v2BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net35" UseHardLinksIfPossible="true" />
-
- <Copy SourceFiles="@(DlrLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Sl4" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(SilverlightDlrLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Sl4" UseHardLinksIfPossible="true" />
- <Copy SourceFiles="@(IronPythonLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Sl4" UseHardLinksIfPossible="true" />
+
+ <Copy SourceFiles="@(DocFiles)" DestinationFiles="@(DocFiles->'$(StageDir)\Doc\%(RecursiveDir)%(Filename)%(Extension)')" />
+ <Copy SourceFiles="@(ToolFiles)" DestinationFiles="@(ToolFiles->'$(StageDir)\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
+ <Copy SourceFiles="@(TutorialFiles)" DestinationFiles="@(TutorialFiles->'$(StageDir)\Tutorial\%(RecursiveDir)%(Filename)%(Extension)')" />
+
+ <Copy SourceFiles="@(DlrLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Silverlight\bin" />
+ <Copy SourceFiles="@(SilverlightDlrLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Silverlight\bin" />
+ <Copy SourceFiles="@(IronPythonLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Silverlight\bin" />
+ <Copy SourceFiles="@(SilverlightBins->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Silverlight\bin" />
+
+ <Copy SourceFiles="@(SilverlightScriptFiles)" DestinationFiles="@(SilverlightScriptFiles->'$(StageDir)\Silverlight\scripts\%(RecursiveDir)%(Filename)%(Extension)')" />
+
+ <Copy SourceFiles="@(DlrLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net40" />
+ <Copy SourceFiles="@(ClrDlrLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net40" />
+ <Copy SourceFiles="@(IronPythonLibs->'$(BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net40" />
+
+ <Copy SourceFiles="@(DlrLibs->'$(v2BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net35" />
+ <Copy SourceFiles="@(ClrDlrLibs->'$(v2BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net35" />
+ <Copy SourceFiles="@(v2DlrLibs->'$(v2BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net35" />
+ <Copy SourceFiles="@(IronPythonLibs->'$(v2BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Net35" />
+
+ <Copy SourceFiles="@(DlrLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Sl4" />
+ <Copy SourceFiles="@(SilverlightDlrLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Sl4" />
+ <Copy SourceFiles="@(IronPythonLibs->'$(Silverlight4BuildDir)\%(Identity)')" DestinationFolder="$(StageDir)\Platforms\Sl4" />
</Target>
- <Target Name="NuGetPackage" DependsOnTargets="Stage">
+ <Target Name="NuGetPackage" DependsOnTargets="Stage" Condition="'$(ReleaseLevel)' == 'final'">
<MakeDir Directories="$(PackageDir)" Condition="!Exists('$(PackageDir)')" />
<Exec Command="$(UtilDir)\Misc\NuGet.exe pack &quot;$(MSBuildProjectDirectory)\Languages\IronPython\IronPython.nuspec&quot; -BasePath &quot;$(StageDir)&quot; -OutputDirectory &quot;$(PackageDir)&quot;" />
<Exec Command="$(UtilDir)\Misc\NuGet.exe pack &quot;$(MSBuildProjectDirectory)\Languages\IronPython\IronPython.StdLib.nuspec&quot; -BasePath &quot;$(StageDir)&quot; -OutputDirectory &quot;$(PackageDir)&quot;" />
</Target>
<Target Name="ZipPackage" DependsOnTargets="Stage">
<MakeDir Directories="$(PackageDir)" Condition="!Exists('$(PackageDir)')" />
- <Exec Command="$(UtilDir)\Misc\zip.exe -9 -r &quot;$(PackageDir)\IronPython.zip&quot; &quot;IronPython&quot;" WorkingDirectory="$(StageDir)\.." />
+ <Exec Command="$(UtilDir)\Misc\zip.exe -9 -r &quot;$(PackageDir)\IronPython-$(DisplayVersion).zip&quot; &quot;IronPython-$(DisplayVersion)&quot;" WorkingDirectory="$(StageDir)\.." />
</Target>
</Project>
View
12 CurrentVersion.props
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <MajorVersion>3</MajorVersion>
+ <MinorVersion>0</MinorVersion>
+ <MicroVersion>0</MicroVersion>
+ <ReleaseLevel>alpha</ReleaseLevel>
+ <ReleaseSerial>0</ReleaseSerial>
+
+ <AssemblyRevision>0</AssemblyRevision>
+ </PropertyGroup>
+</Project>
View
11 Languages/IronPython/AssemblyVersion.cs
@@ -15,14 +15,9 @@
using System.Reflection;
-#if !SILVERLIGHT
-[assembly: AssemblyVersion("3.0.0.0")]
-#else
-[assembly: AssemblyVersion("3.0.1300.0")]
-#endif
-
-[assembly: AssemblyInformationalVersion("3.0")]
-[assembly: AssemblyFileVersion("3.0.0.0")]
+[assembly: AssemblyVersion(IronPython.CurrentVersion.AssemblyVersion)]
+[assembly: AssemblyFileVersion(IronPython.CurrentVersion.AssemblyFileVersion)]
+[assembly: AssemblyInformationalVersion(IronPython.CurrentVersion.AssemblyInformationalVersion)]
[assembly: AssemblyCompany("IronPython Team")]
[assembly: AssemblyCopyright("© IronPython Contributors.")]
View
21 Languages/IronPython/IronPython.Modules/IronPython.Modules.csproj
@@ -113,9 +113,19 @@
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="mmap.cs" />
<Compile Include="signal.cs" />
- <Compile Include="zipimport.cs" />
<Compile Include="zlib\Compress.cs" />
<Compile Include="zlib\Decompress.cs" />
+ <Compile Include="zlib\zlib.net\Adler32.cs" />
+ <Compile Include="zlib\zlib.net\Deflate.cs" />
+ <Compile Include="zlib\zlib.net\InfBlocks.cs" />
+ <Compile Include="zlib\zlib.net\InfCodes.cs" />
+ <Compile Include="zlib\zlib.net\Inflate.cs" />
+ <Compile Include="zlib\zlib.net\InfTree.cs" />
+ <Compile Include="zlib\zlib.net\StaticTree.cs" />
+ <Compile Include="zlib\zlib.net\Tree.cs" />
+ <Compile Include="zlib\zlib.net\Zlib.cs" />
+ <Compile Include="zlib\zlib.net\ZStream.cs" />
+ <Compile Include="zlib\zlib.net\ZStreamException.cs" />
<Compile Include="zlib\ZlibModule.cs" />
<Compile Include="_codecs.cs" />
<Compile Include="ModuleOps.cs" />
@@ -236,10 +246,7 @@
<None Include="IronPython.Modules.ruleset" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" Condition=" '$(SilverlightTreeBuild)' != 'true' " />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>-->
+
+ <Import Project="$(SolutionDir)Versioning.targets" />
+ <Target Name="BeforeBuild" DependsOnTargets="GenerateBuildInfo" />
</Project>
View
2 Languages/IronPython/IronPython.Modules/Properties/AssemblyInfo.cs
@@ -22,7 +22,7 @@
// associated with an assembly.
[assembly: AssemblyTitle("IronPython.Modules")]
[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyConfiguration(BuildInfo.Configuration)]
[assembly: AssemblyProduct("IronPython.Modules")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
View
12 Languages/IronPython/IronPython.Wpf/IronPython.Wpf.csproj
@@ -121,6 +121,8 @@
<SilverlightPath Condition="'$(SilverlightPath)' == ''">$(Silverlight4Path)</SilverlightPath>
</PropertyGroup>
<ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Properties\BuildInfo.Generated.cs" />
<Compile Include="wpf.cs" />
<Compile Include="..\AssemblyVersion.cs">
<Link>Properties\AssemblyVersion.cs</Link>
@@ -181,11 +183,7 @@
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" Condition=" '$(SilverlightTreeBuild)' != 'true' " />
<Import Condition=" '$(Golden)' == 'True'" Project="..\..\..\External\Build\Microsoft.VersionNumber.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
+
+ <Import Project="$(SolutionDir)Versioning.targets" />
+ <Target Name="BeforeBuild" DependsOnTargets="GenerateBuildInfo" />
</Project>
View
56 Languages/IronPython/IronPython.Wpf/Properties/AssemblyInfo.cs
@@ -0,0 +1,56 @@
+/* ****************************************************************************
+ *
+ * Copyright (c) Microsoft Corporation.
+ *
+ * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
+ * copy of the license can be found in the License.html file at the root of this distribution. If
+ * you cannot locate the Apache License, Version 2.0, please send an email to
+ * ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
+ * by the terms of the Apache License, Version 2.0.
+ *
+ * You must not remove this notice, or any other, from this software.
+ *
+ *
+ * ***************************************************************************/
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Security;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("IronPython.Wpf")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration(BuildInfo.Configuration)]
+[assembly: AssemblyProduct("IronPython")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("505BA001-53E8-4148-AE1D-1425D0FF7948")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: SecurityTransparent]
+
+#if !SILVERLIGHT
+[assembly: AllowPartiallyTrustedCallers]
+#if !CLR2
+[assembly: SecurityRules(SecurityRuleSet.Level1)]
+#endif
+#endif
+
View
29 Languages/IronPython/IronPython/Hosting/PythonCommandLine.cs
@@ -56,30 +56,10 @@ public sealed class PythonCommandLine : CommandLine {
/// because it is intended to be outputted through the Python I/O system.
/// </summary>
public static string GetLogoDisplay() {
- return GetVersionString() +
+ return PythonContext.GetVersionString() +
"\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n";
}
- private static string/*!*/ VersionString {
- get {
- return GetVersionString();
- }
- }
-
- private static string GetVersionString() {
-
- return String.Format("{0}{3} ({1}) on .NET {2}",
- PythonContext.IronPythonDisplayName,
- PythonContext.GetPythonVersion().ToString(),
- Environment.Version,
-#if DEBUG
- " DEBUG"
-#else
- ""
-#endif
- );
- }
-
private int GetEffectiveExitCode(SystemExitException/*!*/ e) {
object nonIntegerCode;
int exitCode = e.GetExitCode(out nonIntegerCode);
@@ -245,9 +225,7 @@ public sealed class PythonCommandLine : CommandLine {
#endif
}
- private string InitializeModules() {
- string version = VersionString;
-
+ private void InitializeModules() {
string executable = "";
string prefix = "";
#if !SILVERLIGHT // paths
@@ -258,8 +236,7 @@ public sealed class PythonCommandLine : CommandLine {
prefix = Path.GetDirectoryName(executable);
}
#endif
- PythonContext.SetHostVariables(prefix, executable, version);
- return version;
+ PythonContext.SetHostVariables(prefix, executable, null);
}
/// <summary>
View
5 Languages/IronPython/IronPython/IronPython.csproj
@@ -129,6 +129,8 @@
<Compile Include="Compiler\RunnableScriptCode.cs" />
<Compile Include="Modules\unicodedata.cs" />
<Compile Include="Modules\_ast.cs" />
+ <Compile Include="Properties\BuildInfo.Generated.cs" />
+ <Compile Include="Properties\CurrentVersion.Generated.cs" />
<Compile Include="Runtime\Binding\IPythonExpandable.cs" />
<Compile Include="Runtime\Binding\PythonExtensionBinder.cs" />
<Compile Include="Runtime\BuiltinPythonModule.cs" />
@@ -614,4 +616,7 @@
<EmbeddedResource Include="Modules\unicodedata\IPyUnicodeData.txt.gz" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" Condition=" '$(SilverlightTreeBuild)' != 'true' " />
+
+ <Import Project="$(SolutionDir)Versioning.targets" />
+ <Target Name="BeforeBuild" DependsOnTargets="GenerateBuildInfo;GenerateCurrentVersion" />
</Project>
View
21 Languages/IronPython/IronPython/Modules/sys.cs
@@ -303,7 +303,7 @@ public static class SysModule {
// version and version_info are set by PythonContext
public static PythonTuple subversion = PythonTuple.MakeTuple("IronPython", "", "");
- public const string winver = "3.0";
+ public const string winver = CurrentVersion.Series;
#region Special types
@@ -1047,25 +1047,6 @@ public class floatinfo : IList, IList<object> {
dict["meta_path"] = new List(0);
dict["path_hooks"] = new List(0);
-
- // add zipimport to the path hooks for importing from zip files.
- try {
- PythonModule zipimport = Importer.ImportModule(
- context.SharedClsContext, context.SharedClsContext.GlobalDict,
- "zipimport", false, -1) as PythonModule;
- if (zipimport != null) {
- object zipimporter = PythonOps.GetBoundAttr(
- context.SharedClsContext, zipimport, "zipimporter");
- List path_hooks = dict["path_hooks"] as List;
- if (path_hooks != null && zipimporter != null) {
- path_hooks.Add(zipimporter);
- }
- }
- }
- catch {
- // this is not a fatal error, so we don't do anything.
- }
-
dict["path_importer_cache"] = new PythonDictionary();
}
View
4 Languages/IronPython/IronPython/Properties/AssemblyInfo.cs
@@ -23,7 +23,7 @@
// associated with an assembly.
[assembly: AssemblyTitle("IronPython")]
[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyConfiguration(BuildInfo.Configuration)]
[assembly: AssemblyProduct("IronPython")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -52,4 +52,4 @@
[assembly: CLSCompliant(false)]
#if !CLR2 && !SILVERLIGHT
[assembly: SecurityRules(SecurityRuleSet.Level1)]
-#endif
+#endif
View
35 Languages/IronPython/IronPython/Runtime/PythonContext.cs
@@ -56,7 +56,7 @@ namespace IronPython.Runtime {
public delegate int HashDelegate(object o, ref HashDelegate dlg);
public sealed partial class PythonContext : LanguageContext {
- internal const string/*!*/ IronPythonDisplayName = "IronPython 3.0";
+ internal const string/*!*/ IronPythonDisplayName = CurrentVersion.DisplayName;
internal const string/*!*/ IronPythonNames = "IronPython;Python;py";
internal const string/*!*/ IronPythonFileExtensions = ".py";
@@ -1924,7 +1924,7 @@ class AssemblyResolveHolder {
}
internal void SetHostVariables(string prefix, string executable, string versionString) {
- _initialVersionString = versionString;
+ _initialVersionString = !string.IsNullOrEmpty(versionString) ? versionString : GetVersionString();
_initialExecutable = executable ?? "";
_initialPrefix = prefix;
@@ -1945,7 +1945,7 @@ class AssemblyResolveHolder {
dict["executable"] = _initialExecutable;
SystemState.__dict__["prefix"] = _initialPrefix;
dict["exec_prefix"] = _initialPrefix;
- SetVersionVariables(dict, 3, 0, 0, "alpha", _initialVersionString);
+ SetVersionVariables(dict);
}
[PythonType("sys.version_info")]
@@ -1971,10 +1971,31 @@ internal VersionInfo(int major, int minor, int build, string releaselevel, int s
}
}
- private static void SetVersionVariables(PythonDictionary dict, byte major, byte minor, byte build, string level, string versionString) {
- dict["hexversion"] = ((int)major << 24) + ((int)minor << 16) + ((int)build << 8);
- dict["version_info"] = new VersionInfo((int)major, (int)minor, (int)build, level, 0);
- dict["version"] = String.Format("{0}.{1}.{2} ({3})", major, minor, build, versionString);
+ private void SetVersionVariables(PythonDictionary dict) {
+ dict["hexversion"] = (CurrentVersion.Major << 24) + (CurrentVersion.Minor << 16) + (CurrentVersion.Micro << 8);
+ dict["version_info"] = new VersionInfo(CurrentVersion.Major, CurrentVersion.Minor, CurrentVersion.Micro, CurrentVersion.ReleaseLevel, CurrentVersion.ReleaseSerial);
+ dict["version"] = String.Format("{0}.{1}.{2}{4}{5} ({3})",
+ CurrentVersion.Major,
+ CurrentVersion.Minor,
+ CurrentVersion.Micro,
+ _initialVersionString,
+ CurrentVersion.ReleaseLevel.ToString() != "final" ? CurrentVersion.ShortReleaseLevel : "",
+ CurrentVersion.ReleaseLevel.ToString() != "final" ? CurrentVersion.ReleaseSerial.ToString() : "");
+ }
+
+ internal static string GetVersionString() {
+ string configuration = BuildInfo.IsDebug ? " DEBUG" : "";
+ string platform = Type.GetType("Mono.Runtime") == null ? ".NET" : "Mono";
+ string bitness = (IntPtr.Size * 8).ToString();
+
+ return String.Format("{0}{3} ({1}) on {4} {2} ({5}-bit)",
+ PythonContext.IronPythonDisplayName,
+ PythonContext.GetPythonVersion().ToString(),
+ Environment.Version,
+ configuration,
+ platform,
+ bitness
+ );
}
private static string GetInitialPrefix() {
View
14 Languages/IronPython/IronPythonConsole/IronPythonConsole.csproj
@@ -92,13 +92,14 @@
<Name>IronPython %28Languages\IronPython\IronPython%29</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup />
<ItemGroup>
- <Folder Include="Properties\" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AssemblyInfo.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Console.cs" />
- <Compile Include="..\AssemblyVersion.cs" />
+ <Compile Include="..\AssemblyVersion.cs">
+ <Link>Properties\AssemblyVersion.cs</Link>
+ </Compile>
+ <Compile Include="Properties\BuildInfo.Generated.cs" />
<Content Include="ipy.ico" />
</ItemGroup>
<ItemGroup>
@@ -108,4 +109,7 @@
<None Include="IronPythonConsole.ruleset" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+
+ <Import Project="$(SolutionDir)Versioning.targets" />
+ <Target Name="BeforeBuild" DependsOnTargets="GenerateBuildInfo" />
</Project>
View
4 ...nPython/IronPythonConsole/AssemblyInfo.cs → ...nPythonConsole/Properties/AssemblyInfo.cs
@@ -25,8 +25,8 @@
//
[assembly: AssemblyTitle("IronPython Console")]
[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyProduct("IronPython Console")]
+[assembly: AssemblyConfiguration(BuildInfo.Configuration)]
+[assembly: AssemblyProduct("IronPython")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
View
16 Languages/IronPython/IronPythonConsoleAny/IronPythonConsoleAny.csproj
@@ -90,13 +90,16 @@
<Name>IronPython %28Languages\IronPython\IronPython%29</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup />
<ItemGroup>
- <Folder Include="Properties\" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="..\IronPythonConsole\AssemblyInfo.cs" />
+ <Compile Include="..\IronPythonConsole\Properties\AssemblyInfo.cs">
+ <Link>Properties\AssemblyInfo.cs</Link>
+ </Compile>
<Compile Include="..\IronPythonConsole\Console.cs" />
- <Compile Include="..\AssemblyVersion.cs" />
+ <Compile Include="..\AssemblyVersion.cs">
+ <Link>Properties\AssemblyVersion.cs</Link>
+ </Compile>
+ <Compile Include="Properties\BuildInfo.Generated.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\IronPythonConsole\ipy.ico" />
@@ -106,4 +109,7 @@
<None Include="IronPythonConsoleAny.ruleset" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+
+ <Import Project="$(SolutionDir)Versioning.targets" />
+ <Target Name="BeforeBuild" DependsOnTargets="GenerateBuildInfo" />
</Project>
View
14 Languages/IronPython/IronPythonWindow/IronPythonWindow.csproj
@@ -70,8 +70,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="IronPythonWindow.cs" />
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="..\AssemblyVersion.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="..\AssemblyVersion.cs">
+ <Link>Properties\AssemblyVersion.cs</Link>
+ </Compile>
+ <Compile Include="Properties\BuildInfo.Generated.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Runtime\Microsoft.Scripting.Core\Microsoft.Scripting.Core.csproj" Condition="'$(TargetFrameworkVersion)' != 'v4.0'">
@@ -94,11 +97,12 @@
<ItemGroup>
<Content Include="ipy.ico" />
</ItemGroup>
- <ItemGroup>
- <Folder Include="Properties\" />
- </ItemGroup>
+ <ItemGroup />
<ItemGroup>
<None Include="IronPythonWindow.ruleset" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+
+ <Import Project="$(SolutionDir)Versioning.targets" />
+ <Target Name="BeforeBuild" DependsOnTargets="GenerateBuildInfo" />
</Project>
View
4 ...onPython/IronPythonWindow/AssemblyInfo.cs → ...onPythonWindow/Properties/AssemblyInfo.cs
@@ -25,8 +25,8 @@
//
[assembly: AssemblyTitle("IronPython Windows Console")]
[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyProduct("IronPython Console")]
+[assembly: AssemblyConfiguration(BuildInfo.Configuration)]
+[assembly: AssemblyProduct("IronPython")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
View
16 Languages/IronPython/IronPythonWindowAny/IronPythonWindowAny.csproj
@@ -65,8 +65,13 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="..\IronPythonWindow\IronPythonWindow.cs" />
- <Compile Include="..\IronPythonWindow\AssemblyInfo.cs" />
- <Compile Include="..\AssemblyVersion.cs" />
+ <Compile Include="..\IronPythonWindow\Properties\AssemblyInfo.cs">
+ <Link>Properties\AssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="..\AssemblyVersion.cs">
+ <Link>Properties\AssemblyVersion.cs</Link>
+ </Compile>
+ <Compile Include="Properties\BuildInfo.Generated.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
@@ -94,11 +99,12 @@
<ItemGroup>
<Content Include="..\IronPythonWindow\ipy.ico" />
</ItemGroup>
- <ItemGroup>
- <Folder Include="Properties\" />
- </ItemGroup>
+ <ItemGroup />
<ItemGroup>
<None Include="IronPythonWindowAny.ruleset" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+
+ <Import Project="$(SolutionDir)Versioning.targets" />
+ <Target Name="BeforeBuild" DependsOnTargets="GenerateBuildInfo" />
</Project>
View
20 Solutions/Bootstrap.targets
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <PropertyGroup>
+ <CustomTasksSource>$(MSBuildThisFileDirectory)CustomTasks\CustomTasks.cs</CustomTasksSource>
+ <CustomTasksDll>$(MSBuildThisFileDirectory)CustomTasks\CustomTasks.dll</CustomTasksDll>
+ </PropertyGroup>
+ <Target Name="Bootstrap"
+ Inputs="$(CustomTasksSource)"
+ Outputs="$(CustomTasksDll)">
+
+ <Csc Sources="$(CustomTasksSource)"
+ OutputAssembly="$(CustomTasksDll)"
+ References="Microsoft.Build.Framework.dll;Microsoft.Build.Utilities.v4.0.dll"
+ TargetType="library" />
+ </Target>
+
+ <UsingTask AssemblyFile="$(CustomTasksDll)" TaskName="CustomTasks.FormatString" />
+ <UsingTask AssemblyFile="$(CustomTasksDll)" TaskName="CustomTasks.CurrentTime" />
+ <UsingTask AssemblyFile="$(CustomTasksDll)" TaskName="CustomTasks.FormatTemplate" />
+</Project>
View
66 Solutions/CustomTasks/CustomTasks.cs
@@ -0,0 +1,66 @@
+using System;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+
+namespace CustomTasks
+{
+ public class FormatString : Task
+ {
+ [Required]
+ public string Format { get; set; }
+
+ public string[] Args { get; set; }
+
+ [Output]
+ public string Result { get; private set; }
+
+ public override bool Execute()
+ {
+ Result = string.Format(Format, Args);
+ return true;
+ }
+ }
+
+ public class CurrentTime : Task {
+ public string Format { get; set; }
+
+ [Output]
+ public string Result { get; private set; }
+
+ public override bool Execute() {
+ var now = DateTime.Now;
+ Result = string.IsNullOrEmpty(Format) ? now.ToString() : now.ToString(Format);
+
+ return true;
+ }
+ }
+
+ public class FormatTemplate : Task {
+ const string Header = @"/*
+ * This code was generated by FormatTemplate as part of the build process. Do not edit it.
+ *
+ * Generated on {0:yyyy-MM-dd hh:mm:ss}.
+ *
+ */";
+
+ [Required]
+ public string Template { get; set; }
+
+ public string[] Parameters { get; set; }
+
+ [Output]
+ public string Result { get; private set; }
+
+ public override bool Execute() {
+ Result = string.Format(Header, DateTime.Now)
+ + Environment.NewLine
+ + Environment.NewLine
+ + string.Format(Template, Parameters);
+
+ return true;
+ }
+ }
+}
+
+
+
View
3 Solutions/IronPython.sln
@@ -38,7 +38,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Scripting.AspNet"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A14D070-628F-44EF-92DD-47C8BE5C33CD}"
ProjectSection(SolutionItems) = preProject
+ Bootstrap.targets = Bootstrap.targets
..\Build.proj = ..\Build.proj
+ ..\CurrentVersion.props = ..\CurrentVersion.props
+ Versioning.targets = Versioning.targets
EndProjectSection
EndProject
Global
View
108 Solutions/Versioning.targets
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildThisFileDirectory)..\CurrentVersion.props" />
+
+ <PropertyGroup>
+ <ShortReleaseLevel Condition="'$(ReleaseLevel)' == 'alpha'">a</ShortReleaseLevel>
+ <ShortReleaseLevel Condition="'$(ReleaseLevel)' == 'beta'">b</ShortReleaseLevel>
+ <ShortReleaseLevel Condition="'$(ReleaseLevel)' == 'candidate'">rc</ShortReleaseLevel>
+ <ShortReleaseLevel Condition="'$(ReleaseLevel)' == 'final'">f</ShortReleaseLevel>
+
+ <DisplayVersion Condition="'$(ReleaseLevel)' == 'final'">$(MajorVersion).$(MinorVersion).$(MicroVersion)</DisplayVersion>
+ <DisplayVersion Condition="'$(ReleaseLevel)' != 'final'">$(MajorVersion).$(MinorVersion).$(MicroVersion)$(ShortReleaseLevel)$(ReleaseSerial)</DisplayVersion>
+
+ <AssemblyFileRevision Condition="'$(ReleaseLevel)' == 'alpha'">$(ReleaseSerial)</AssemblyFileRevision>
+ <AssemblyFileRevision Condition="'$(ReleaseLevel)' == 'beta'">$(ReleaseSerial)0</AssemblyFileRevision>
+ <AssemblyFileRevision Condition="'$(ReleaseLevel)' == 'candidate'">$(ReleaseSerial)00</AssemblyFileRevision>
+ <AssemblyFileRevision Condition="'$(ReleaseLevel)' == 'final'">1000</AssemblyFileRevision>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <CurrentVersionTemplate>
+ <![CDATA[
+namespace IronPython {{
+ public static class CurrentVersion {{
+ public const int Major = {0};
+ public const int Minor = {1};
+ public const int Micro = {2};
+ public const string ReleaseLevel = "{3}";
+ public const int ReleaseSerial = {4};
+
+ public const string ShortReleaseLevel = "{5}";
+
+ public const string Series = "{0}.{1}";
+ public const string DisplayVersion = "{6}";
+ public const string DisplayName = "IronPython {6}";
+
+#if !SILVERLIGHT
+ public const string AssemblyVersion = "{0}.{1}.0.{7}";
+#else
+ public const string AssemblyVersion = "{0}.{1}.1300.{7}";
+#endif
+
+ public const string AssemblyFileVersion = "{0}.{1}.{2}.{8}";
+ public const string AssemblyInformationalVersion = "IronPython {0}.{1}.{2} {3} {4}";
+ }}
+}}
+ ]]>
+ </CurrentVersionTemplate>
+
+ <BuildInfoTemplate>
+ <![CDATA[
+internal static class BuildInfo {{
+ internal const string Configuration = "{0}";
+
+ internal const bool IsDebug =
+#if DEBUG
+ true;
+#else
+ false;
+#endif
+
+ internal const bool IsCLR2 =
+#if CLR2
+ true;
+#else
+ false;
+#endif
+
+ internal const bool IsCLR4 =
+#if CLR4
+ true;
+#else
+ false;
+#endif
+
+ internal const bool IsSilverlight =
+#if SILVERLIGHT
+ true;
+#else
+ false;
+#endif
+}}
+ ]]>
+ </BuildInfoTemplate>
+ </PropertyGroup>
+
+ <Import Project="$(MSBuildThisFileDirectory)Bootstrap.targets" />
+
+ <Target Name="GenerateCurrentVersion"
+ DependsOnTargets="Bootstrap"
+ Inputs="$(MSBuildThisFileDirectory)..\CurrentVersion.props;$(MSBuildThisFile)"
+ Outputs="Properties\CurrentVersion.Generated.cs">
+ <FormatTemplate Template="$(CurrentVersionTemplate)" Parameters="$(MajorVersion);$(MinorVersion);$(MicroVersion);$(ReleaseLevel);$(ReleaseSerial);$(ShortReleaseLevel);$(DisplayVersion);$(AssemblyRevision);$(AssemblyFileRevision)">
+ <Output TaskParameter="Result" PropertyName="CurrentVersionText" />
+ </FormatTemplate>
+ <WriteLinesToFile File="Properties\CurrentVersion.Generated.cs" Lines="$(CurrentVersionText)" Overwrite="true" />
+ </Target>
+
+ <Target Name="GenerateBuildInfo"
+ DependsOnTargets="Bootstrap"
+ Inputs="$(MSBuildThisFileDirectory)..\CurrentVersion.props;$(MSBuildThisFile)"
+ Outputs="Properties\BuildInfo.Generated.cs">
+ <FormatTemplate Template="$(BuildInfoTemplate)" Parameters="'$(Configuration)'">
+ <Output TaskParameter="Result" PropertyName="BuildInfoText" />
+ </FormatTemplate>
+ <WriteLinesToFile File="Properties\BuildInfo.Generated.cs" Lines="$(BuildInfoText)" Overwrite="true" />
+ </Target>
+</Project>

0 comments on commit a093f70

Please sign in to comment.
Something went wrong with that request. Please try again.