Commit Graph

284 Commits

Author SHA1 Message Date
Sean Farley
e18a90ab08 merge with stable 2017-08-21 21:35:06 -07:00
Mike Hommey
634713aa96 setup: fix installing in a mingw environment
The addition, in 851d08ff7a58, of a hack for the MSVC compiler class was
overwriting the original class for the Mingw32CCompiler class, leading to an
error when the HackedMingw32CCompiler is instantiated.

Differential Revision: https://phab.mercurial-scm.org/D329
2017-08-11 10:16:00 +09:00
Yuya Nishihara
4b047b0633 setup: silence warning of unknown option python_requires on distutils
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution
  option: 'python_requires'
2017-07-27 23:15:14 +09:00
Yuya Nishihara
33738d760a setup: forcibly include cext/pure packages in py2exe (issue5625)
Since these modules are implicitly imported by policy.importmod(), py2exe
can't track them statically. cffi modules are excluded for now because they
wouldn't be useful in frozen (i.e. CPython) environment.
2017-07-20 22:47:40 +09:00
Yuya Nishihara
6a9bb7fcb6 setup: do not select hg executable that prints unexpected warnings
Otherwise the subsequent hg.run() would fail. This factors out the filtering
function so the same rule should apply.
2017-07-20 22:32:37 +09:00
Augie Fackler
ced1b0963a setup: fix mistake that prevented Python 3 from being excluded
My intent was to only allow Python 3 if the right environment variable
is set (for when people want to use `pip install .` on hg
locally). This fixes the bug in my previous change. I verified that
`python3.6 run-tests.py` still passes the tests that passed before,
and that all tests pass on 2.7 (including our virtualenv-using
installation test).

Differential Revision: https://phab.mercurial-scm.org/D185
2017-07-26 13:21:34 -04:00
Yuya Nishihara
c49455b105 setup: drop use of set literal so parsable on Python 2.6
Otherwise friendly error wouldn't be displayed.
2017-07-26 23:39:42 +09:00
Augie Fackler
527e838b00 setup: add extra logic to try and recommend a new pip on bad Python
Modern pip can detect supported Python versions (which we now
declare), and pull down a reasonable release. This trick was suggested
in http://bit.ly/pycon2017-build-bridges, and seems like a good
defensive maneuver so that when we want to move to Python 3 it's
less risky for existing users.

This moves the version-check logic after defining our printf function
so we can print more informative messages.
2017-07-21 10:46:31 -04:00
Augie Fackler
4b55d62a6d setup: explicitly declare supported Python versions
I think we should probably backport this to 4.2 as well, and do one
more release there that explicitly declares 2.6 support. That way
anyone stuck on Python 2.6 will end up getting the right hg if they
use a modern pip to install. Users can still use `python setup.py`
incantations to attempt installing Mercurial on unsupported Pythons,
including 3.5 and 3.6.

A followup change will switch to only doing our own
Python-version-check logic if we're not being installed by a
reasonable pip.
2017-07-21 10:39:52 -04:00
Yuya Nishihara
b32d207c09 cext: factor out header for charencode.c
This merges a part of util.h with the header which should exist for
charencode.c.
2017-05-21 14:23:22 +09:00
Yuya Nishihara
20afdd710d cext: split character encoding functions to new compilation unit
This extracts charencode.c from parsers.c, which seems big enough for me
to hesitate to add new JSON functions. Still charencode.o is linked to
parsers.so to avoid duplication of binary codes.
2017-07-31 22:28:27 +09:00
Adam Simpkins
f7ebee7cc9 setup: fix runcmd() usage on darwin
Fix one invocation of runcmd() that was missed in the recent change to
make runcmd() also return the process exit status.
2017-06-28 10:50:37 -07:00
Jun Wu
d6d4c8725e setup: fix localhgenv
It should return env as a dict instead of None.
2017-06-28 06:49:01 -07:00
Adam Simpkins
03e07a8e3b setup: prefer using the system hg to interact with the local repository
Add a findhg() function that tries to be smarter about figuring out how to run
hg for examining the local repository.  It first tries running "hg" from the
user's PATH, with the default HGRCPATH settings intact, but with HGPLAIN
enabled.  This will generally use the same version of mercurial and the same
settings used to originally clone the repository, and should have a higher
chance of working successfully than trying to run the hg script from the local
repository.  If that fails findhg() falls back to the existing behavior of
running the local hg script.
2017-06-27 16:15:32 -07:00
Adam Simpkins
6ae0f95e37 setup: replace runhg() with an hgcommand helper class
Replace the runhg() function with an hgcommand helper class.  hgcommand has as
run() function similar to runhg(), but no longer requires the caller to pass in
the exact path to python and the hg script, and the environment settings for
invoking hg.

For now this diff contains no behavior changes, but in the future this will
make it easier for the hgcommand helper class to more intelligently figure out
the proper way to invoke hg.
2017-06-27 16:15:32 -07:00
Adam Simpkins
5be8308b27 setup: move environment computation into a helper function
Add a helper function to compute the environment used for invoking mercurial,
rather than doing this computation entirely at global scope.  This will make it
easier to do some subsequent refactoring.
2017-06-26 11:31:30 -07:00
Adam Simpkins
f8d4797904 setup: update runcmd() to also return the exit status
Update the runcmd() helper function so it also returns the process exit status.
This allows callers to more definitively determine if a command failed, rather
than testing only for the presence of data on stderr.

I don't expect this to have any behavioral changes for now: the commands
invoked by setup generally should print data on stderr if and only if they
failed.
2017-06-26 11:31:30 -07:00
Adam Simpkins
1234fecf66 setup: fail if we cannot determine the version number
If running hg fails, exit the setup script unsuccessfully, rather than
proceeding to use a bogus version of "+0-".  Using an invalid version number
causes various tests to fail later.  Failing early makes it easier to identify
the source of the problem.

It is currently easy for setup.py to fail this way since it sets HGRCPTH to the
empty string before running "hg", which may often disable extensions necessary
to interact with the local repository.
2017-06-26 11:31:30 -07:00
Pulkit Goyal
bfb91c2ff5 py3: slice over bytes to prevent getting it's ascii value 2017-06-25 08:36:51 +05:30
Matt Harbison
6de437e52f setup: update a comment that blamed py26 for a Windows workaround 2017-06-16 21:57:22 -04:00
Matt Harbison
fcd2a4509b plan9: drop py26 hacks 2017-06-16 18:42:03 -04:00
Matt Harbison
34475a04af setup: avoid linker warnings on Windows about multiple export specifications
The PyMODINIT_FUNC macro contains __declspec(dllexport), and then the build
process adds an "/EXPORT func" to the command line.  The 64-bit linker flags
this [1].

Everything except zstd.c and bser.c are covered by redefining the macro in
util.h [2].  These modules aren't built with util.h in the #include path, so the
redefining hack would have to be open coded two more times.

After seeing that extra_linker_flags didn't work, I couldn't find anything
authoritative indicating why, though I did see an offhand comment on SO that
CFLAGS is also ignored on Windows.  I also don't fully understand the
interaction between msvccompiler and msvc9compiler- I first subclassed the
latter, but it isn't used when building with VS2008.

I know the camelcase naming isn't the standard, but the HackedMingw32CCompiler
class above it was introduced 5 years ago (and I think the current style was
in place by then), so I assume that there's some reason for it.

[1] https://support.microsoft.com/en-us/help/835326/you-receive-an-lnk4197-error-in-the-64-bit-version-of-the-visual-c-compiler
[2] https://bugs.python.org/issue9709#msg120859
2017-06-09 22:15:53 -04:00
Augie Fackler
f5d193d3cd setup: introduce dummy copies of setuptools flags
Since we're filtering out some egg gunk, we need to emulate these
flags which disable eggs so that pip still works.
2017-06-06 11:02:30 -04:00
Yuya Nishihara
4bbb13514b setup: do not overwrite local __modulepolicy__.py on out-of-source build
Since the default policy is selected depending on setup options, "make install"
shouldn't overwrite in-source __modulepolicy__.py generated by "make local".
2017-06-03 14:05:52 +09:00
Matt Harbison
db34f3fbb0 setup: prevent setuptools from laying an egg
Previously, test-hghave.t was failing on Windows (and on Linux if
$FORCE_SETUPTOOLS was set) with the following:

  --- c:/Users/Matt/Projects/hg/tests/test-hghave.t
  +++ c:/Users/Matt/Projects/hg/tests/test-hghave.t.err
  @@ -19,7 +19,11 @@
     >   foo
     > EOF
     $ run-tests.py $HGTEST_RUN_TESTS_PURE test-hghaveaddon.t
  +  warning: Testing with unexpected mercurial lib: c:\Users\Matt\Projects\hg\mercurial
  +           (expected ...\hgtests.mu9rou\install\lib\python\mercurial)
     .
  +  warning: Tested with unexpected mercurial lib: c:\Users\Matt\Projects\hg\mercurial
  +           (expected ...\hgtests.mu9rou\install\lib\python\mercurial)

Augie relayed concerns[1] about the first attempt at this, which also excluded
'install_egg_info'.  All that needs to be excluded to avoid the egg and make the
test work is to filter out 'bdist_egg'.  (Actually, the body of this class could
simply be 'pass', and 'bdist_egg' still isn't run.  But that seems to magical.)

Also note that prior to this (and still now), `make clean` doesn't delete the
'mercurial.egg-info' that is generated by `make install`.

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/097668.html

# no-check-commit
2017-05-07 23:29:03 -04:00
Yuya Nishihara
fa3c51ef73 cffi: put compiled modules into mercurial.cffi package
Don't pollute the top-level namespace.
2017-05-02 21:08:38 +09:00
Yuya Nishihara
5cccfd11fb cffi: rename build scripts
This frees up cffi package for modules to be split from pure.
2017-05-02 21:04:40 +09:00
Siddharth Agarwal
a41c665cd6 demandimport: move to separate package
In Python 3, demand loading is per-package. Keeping demandimport in the
mercurial package would disable demand loading for any modules in
mercurial.
2017-05-21 12:10:53 -07:00
Yuya Nishihara
79ebd14e1e cext: move util.h to cext tree
Since util.h isn't useful in plain C module, it should be placed in CPython
extension directory.
2017-05-21 13:35:19 +09:00
Gregory Szorc
9e19911eaa cext: extract revlog/index parsing code to own C file
parsers.c is ~3000 lines and ~2/3 of it is related to the revlog
index type.

We already have separate C source files for directory utilities
and manifest parsing. I think the quite unwieldy revlog/index
parsing code should be self-contained as well.

I performed the extraction as a file copy then removed content
from both sides in order to preserve file history and blame.

As part of this, I also had to move the hexdigit table and
function to a shared header since it is used by both parsers.c
and revlog.c

# no-check-commit
2017-05-20 14:01:05 -07:00
Yuya Nishihara
4563e16232 parsers: switch to policy importer
# no-check-commit
2016-08-13 12:23:56 +09:00
Yuya Nishihara
5fe7742660 mpatch: switch to policy importer 2016-08-13 12:18:58 +09:00
Yuya Nishihara
6130be9a6c diffhelpers: switch to policy importer
# no-check-commit
2016-08-13 12:15:49 +09:00
Yuya Nishihara
50b316b748 bdiff: switch to policy importer
# no-check-commit
2016-08-13 12:12:50 +09:00
Yuya Nishihara
a9b78ccb21 base85: switch to policy importer 2016-08-13 12:08:23 +09:00
Yuya Nishihara
70995f9aa9 osutil: switch to policy importer
"make clean" is recommended to test this change, though C API compatibility
should be preserved.
2016-08-12 11:35:17 +09:00
Yuya Nishihara
2fe12e4917 policy: relax the default for in-place build
We're going to make the 'c' policy more strict, where no missing attribute
will be allowed. Since we want to run 'hg bisect' without rebuilding the C
extension modules, we'll need a looser policy for development environment.

The default for system installation isn't changed.

Note that the current 'c' policy is practically 'allow'-ish as we have lots
of adhoc fallbacks to pure functions.
2017-04-26 23:02:43 +09:00
Gregory Szorc
c950654a68 setup: drop support for Python 2.6 (BC)
Per discussion on the mailing list and elsewhere, we've decided that
Python 2.6 is too old to continue supporting. We keep accumulating
hacks/fixes/workarounds for 2.6 and this is taking time away from
more important work.

So with this patch, we officially drop support for Python 2.6 and
require Python 2.7 to run Mercurial.
2017-05-02 16:19:04 -07:00
Yuya Nishihara
276d62703a policy: add "cext" package which will host CPython extension modules
I'm going to restructure cext/pure modules and get rid of our hgimporter
hack. C extension modules will be moved to cext/ directory so old and new
compiled modules can coexist in development tree. This is necessary to
run 'hg bisect' without recompiling.

New extension modules will be loaded by an importer function:

  base85 = policy.importmod('base85')  # select pure.base85 or cext.base85

This will also allow us to split cffi from pure modules, which is currently
difficult because pure modules can't be imported by name.
2016-08-12 11:06:14 +09:00
Alex Gaynor
7152638545 setup: sys.version_info always exists
It is documented as existing since Python 2.0, and empirically from
other OSS projects I maintain, there is no problem relying on its
existance.
2017-05-03 09:41:55 -04:00
Jun Wu
3633e80713 statfs: change Linux feature detection
Previously we check three things: "statfs" function, "linux/magic.h" and
"sys/vfs.h" headers. But we didn't check "struct statfs" or the "f_type"
field. That means if a system has "statfs" but "struct statfs" is not
defined in the two header files we check, or defined without the "f_type"
field, the compilation will fail.

This patch combines the checks (2 headers + 1 function + 1 field) together
and sets "HAVE_LINUX_STATFS". It makes setup.py faster (less checks), and
more reliable (immutable to the issue above).
2017-03-24 14:59:19 -07:00
Jun Wu
b78b032c28 setup: use a more strict way to test BSD or OSX's statfs
We want to use the `f_fstypename` field to get the filesystem type. Test it
directly. The new macro HAVE_BSD_STATFS implys the old HAVE_SYS_MOUNT_H and
HAVE_SYS_PARAM_H. So the latter ones are removed.
2017-03-23 22:15:36 -07:00
Jun Wu
f1184d5119 setup: test some header files
The next patch will use "statfs", which requires different header files on
different platforms.

Linux:

    sys/vfs.h or sys/statfs.h

FreeBSD or OSX:

    sys/param.h and sys/mount.h

Therefore test them so we can include the correct ones.
2017-03-20 15:43:27 -07:00
Jun Wu
416be40974 setup: detect statfs
statfs is not defined by POSIX but is available in various systems to help
decide filesystem type. Let's detect it and set the macro HAVE_STATFS.
2017-03-20 15:11:18 -07:00
Jun Wu
1aec4664c3 setup: add a function to test header files 2017-03-20 15:31:21 -07:00
Jun Wu
ca75eb2417 setup: split "hasfunction" to test arbitrary code
The next patch wants to test include files.
2017-03-20 15:28:08 -07:00
Gregory Szorc
ebff74a01c setup: convert setupversion to unicode
Something deep in the bowels of distutils expects "version" passed to
setup() to be a str/unicode. So, convert the type.

This still works on Python 2 because the string is ascii and an
implicit coercion back to str/bytes should work without issue. If
it does cause problems, we can always make the unicode conversion
dependent on running Python 3.

This change makes `python3.5 setup.py install` work.
2017-03-11 17:14:02 -08:00
Augie Fackler
f3d54c952b policy: try and always have a bytes for module policy
debuginstall now runs cleanly in Python 3.
2017-03-08 18:11:41 -05:00
Gregory Szorc
8df619ffe0 setup: use setuptools on Windows (issue5400)
We've had a long, complicated history with setuptools. We want to
make it the universal default. But when we do, it breaks things.

`python setup.py build` is broken on Windows today. Forcing
the use of setuptools via FORCE_SETUPTOOLS=1 unbreaks things.

Since the previous bustage with making setuptools the default
was on !Windows, it seems safe to move ahead with the setuptools
transition on Windows. So this patch does that.
2017-03-09 19:59:52 -08:00
FUJIWARA Katsunori
2afd920706 misc: update year in copyright lines
This patch also makes some expected output lines in tests glob-ed for
persistence of them.

BTW, files below aren't yet changed in 2017, but this patch also
updates copyright of them, because:

    - mercurial/help/hg.1.txt

      almost all of "man hg" output comes from online help of hg
      command, and is already changed in 2017

    - mercurial/help/hgignore.5.txt
    - mercurial/help/hgrc.5

      "copyright 2005-201X Matt Mackall" in them mentions about
      copyright of Mercurial itself
2017-02-12 02:23:33 +09:00