Commit Graph

381 Commits

Author SHA1 Message Date
Jack O'Connor 2387a18b88 add build deprecation warning
Summary: Doing this before we actually remove the build field is kinder to users.

Test Plan:
This dumps a bunch of junk into our test output, because we still use
the `build` field. I don't think it's worth putting in a bunch of extra
logic to catch that. This won't be around for very long, and this will
be an incentive to clean it up.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D165
2015-01-04 21:54:58 -08:00
Jack O'Connor 73cea6fd80 README update
Summary:
Replace use of `build` with the new `unpack` field, and clean up the
type section.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D155
2015-01-04 21:54:58 -08:00
Sean Olson 927d46d296 bump Debian changelog
Summary: Package for 0.1.2ubuntu~utopic1-1 is live on Launchpad. Bumping changelog.

Reviewers: jacko

Reviewed By: jacko

Differential Revision: https://phabricator.buildinspace.com/D164
2015-01-04 18:44:58 -08:00
Jack O'Connor 60d45be2e8 add the unpack field to the curl plugin
Summary:
Provides native support for tar and zip unpacking. Python documentation
on `tarfile` warns about using the `extractall` method on untrusted
archives, so we try to check for the evil paths that it mentions.

Test Plan: New tests.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D154
2015-01-04 17:14:27 -08:00
Jack O'Connor a58c1b6a19 add PERU_PLUGIN_TMP to the plugin interface
Summary:
Doing tar and zip unpacking looks like it's going to need temporary
files. We could expect plugins to use the global temp dir, but so far
we've been trying to avoid that. @sean let me know what you think.

Reviewers: sean

Reviewed By: sean

Subscribers: sean

Differential Revision: https://phabricator.buildinspace.com/D153
2015-01-04 17:12:06 -08:00
Jack O'Connor 8c64db06d8 refactor _plugin_job() with an ExitStack
Summary:
The number of context managers in that function is getting annoying,
because of all the nested with-statements. And we're about to add
another in the next diff for tmp dirs. Contextlib provides an ExitStack
class to help deal with lots of context managers.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D152
2015-01-04 17:11:45 -08:00
Jack O'Connor ee7b9fb406 get rid of a corny joke
Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D161
2015-01-04 17:10:54 -08:00
Sean Olson 2a315178f0 add packaging information to version
Summary:
Add a "source version" when generating source packages for Ubuntu. The source
version is a part of the software version, which is encoded in the original
tarball. This allows some flexibility when uploading to Launchpad, which will
reject changes for the same software version. For example, the source version
can be bumped to upload a fix for a broken package (without bumping the actual
software version). Note that the package version cannot be used to accomplish
this; it is not part of the source tarball, so bumping this version does not
pervent Launchpad from rejecting the changes.

Rename the script, since this is a bit specific for Ubuntu and Launchpad.

See: http://askubuntu.com/a/391751

Reviewers: jacko

Reviewed By: jacko

Differential Revision: https://phabricator.buildinspace.com/D163
2015-01-04 15:09:33 -08:00
Jack O'Connor 3fb8057ac5 deprecate `build` in the README
Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D156
2014-12-24 00:46:53 -06:00
Jack O'Connor 9fc4d82dd1 bump version to 0.1.2
Summary:
Important changes in this release:
- fix curl plugin's quote handling (D144)
- support user-defined plugins (D141)

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D147
2014-12-21 14:56:41 -08:00
Jack O'Connor b5a3bf112b have setup.py inspect the python version to determine dependencies
Summary:
Our Arch package is broken because it doesn't install asyncio and
pathlib. These shouldn't *need* to be installed, because Arch is running
Python 3.4, but the executable script that setup.py generates is getting
confused. It seems like the right thing to do is to make sure these
extra dependencies never make it into our `install_requires` list in
Python 3.4. I *think* the fact that our setup.py ends up in the source
distribution means that `pip install peru` will still do the right thing
for Python 3.3.

Test Plan: Tested `pip install .` in a python3.3 virtualenv.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D151
2014-12-21 14:56:41 -08:00
Jack O'Connor 3f78a3e467 add a description in setup.py
Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D148
2014-12-21 14:56:40 -08:00
Jack O'Connor dfd5da2dfa update README
Summary:
Get rid of the separate install instructions for python3.3, and add
links at the bottom.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D149
2014-12-21 14:56:40 -08:00
Sean Olson 63c2827f43 packaging for Debian and Ubuntu
Summary:
Add Debian packaging metadata and a script to generate a basic source package
that can be uploaded to a Launchpad PPA.

Reviewers: jacko

Reviewed By: jacko

Differential Revision: https://phabricator.buildinspace.com/D133
2014-12-21 02:24:08 -08:00
Sean Olson 2fbd7a77e3 remove third-party/
Summary:
Remove the third-party/ directory and no longer rely on copies of dependencies
in the repo. When needed, fetch dependencies normally. This can usually be
accomplished via `pip install -r requirements.txt` or `pip install -r
requirements-dev.txt`.

Even though `peru.yaml` is gone, `.peru/` is still in `.gitignore`, because the
tests check for untracked files and will detect `.peru/` as an error.

Test Plan: Successfully ran tests locally and via Travis CI.

Reviewers: jacko

Reviewed By: jacko

Differential Revision: https://phabricator.buildinspace.com/D145
2014-12-20 21:06:36 -08:00
Jack O'Connor b6f5ed90b7 stop LocalModule from creating a .peru dir by default
Summary:
Instead, only create the dir when we need to actually write a
`lastimports` file. This is a short term fix for our parser tests
inadvertently creating a `.peru` directory in our tests dir. With this
fix, D145 should be able to remove `.peru` from our `.gitignore` file.

In the long term, it's clear that we have an organization problem. The
parser should obviously not be calling code that writes to disk. I think
the best solution will be to tear up the LocalModule class. It's a
holdover from when we thought we would be doing much more complicated
things to override dirs, like applying imports and running build
commands. Going forward, override dirs are going to be a much simpler
concept, and we can probably separate the parser from the code that
deals with the local project dir in the process of simplifying it.

Tracking issue: https://github.com/buildinspace/peru/issues/72

Test Plan:
`arc patch D145`, remove `.peru` from `.gitignore`, clean the repo, and
run tests. Tests pass without any warning about dirty files.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D146
2014-12-20 17:57:13 -08:00
Jack O'Connor f438592800 reimplement shared bash scripts in python
Summary:
We have peru.sh and peru.bat, and also test.sh and test.bat. Rather than
maintaining both of those duplicates to support Windows, just
reimplement them in Python.

There's also validate-third-party.sh, but we never really use that on
Windows. We can port it in a later diff if we feel like it.

Test Plan:
Check that tests actually fail after introducing a bug. (To make sure
we're not actually testing the installed version instead of the repo
version.) Check that the linter fails after dirtying up some code. Check
that the untracked file test fails by creating a random file during
tests.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D143
2014-12-18 15:12:14 -08:00
Jack O'Connor a265b26e41 handle quotes in Content-Disposition filenames
Summary:
The HTTP standard specifies
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1) that
`Content-Disposition` filenames can be quoted. I forgot to handle that.

Closes https://github.com/buildinspace/peru/issues/70.

Test Plan: Add a couple extra cases to the existing test.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D144
2014-12-17 17:40:12 -08:00
Jack O'Connor f91dd4c936 support user-defined plugins
Summary:
Add search directories for plugins. On Linux/Mac we use:

1. `$XDG_CONFIG_HOME/peru/plugins`
2. `/usr/local/lib/peru/plugins`
3. `/usr/lib/peru/plugins`

And on Windows it's:

1. `%LOCALAPPDATA%\peru\plugins`
2. `%PROGRAMFILES%\peru\plugins`

Get rid of the old rule that says you can't override existing plugins --
that was from back when we allowed individual projects to provide their
own plugins, which we no longer do.

Test Plan:
We had some old testing logic for custom plugin paths, even though that
feature had been mostly removed. Repurpose that test to load plugins
from a fake home directory. Manually test on Windows.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D141
2014-12-17 14:19:14 -08:00
Jack O'Connor 20d368f17d clean up the summary text a little
Summary: Looking at them now, some of the help summaries are confusing.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D142
2014-12-17 12:54:11 -08:00
Jack O'Connor a4305d4518 create docs/architecture.md
Summary:
A first shot at documenting how peru works internally, particularly the
plugin interface.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D139
2014-12-08 10:50:59 -06:00
Jack O'Connor 90316ba268 fix the travis build
Summary: We forgot to point .travis.yml to the new test script name.

Test Plan: Pushed a branch to my fork.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D140
2014-12-06 20:49:32 -06:00
Jack O'Connor 733a123028 stop claiming that git submodules break bisect
Summary:
If a peru project doesn't put `peru sync` inside its build tools (or if
it has no other build tool), the user still needs to call it in every
step of a bisect, or after a checkout. In this way, it's no better than
`git submodule update`. There maybe be a point about it being more
appropriate for Make to call peru than for it to call git, but I'm not
really sure. Let's just take this part out of the readme.

See: https://www.reddit.com/r/vim/comments/2o6av8/peru_pathogen_a_new_alternative_to_plugin/cmlc4l0

Closes https://github.com/buildinspace/peru/issues/64.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D137
2014-12-06 20:47:45 -06:00
Sean Olson a970ce27b7 reorganize scripts/ directory
Summary:
This is a cosmetic change and moves some more "targeted" scripts to specific
directories. It also pairs Windows-specific scripts with their Posix
counterparts.

Reviewers: jacko

Reviewed By: jacko

Differential Revision: https://phabricator.buildinspace.com/D138
2014-12-06 17:47:12 -08:00
Sean Olson 6ee6911e97 Merge pull request #62 from mfussenegger/requirements
add requirements-dev.txt
2014-12-04 15:32:28 -08:00
Mathias Fussenegger 163be413d7 add requirements-dev.txt
lists all requirements that are necessary to run ./test.sh
so that someone can create a virtualenv and run `pip install
-r requirements-dev.txt`
2014-12-04 22:32:42 +01:00
Jack O'Connor c2e4caec0f move version number into a file, and bump to 0.1.1 2014-12-03 00:25:34 -05:00
Jack O'Connor 9a52d94d35 use square boxes, for better font support 2014-12-03 00:14:36 -05:00
Jack O'Connor d3d06a0b71 use entry_points instead of a pre-written script
Summary:
This was the recommendation of
https://packaging.python.org/en/latest/distributing.html, but I unwisely
ignored it back when I wrote our setup.py. It turns out that getting a
launcher script to work properly on Windows is tricky. The
`entry_points` field generates a platform-appropriate launcher script at
install time, so we get Windows for free.

Previously our launcher script checked the version of Python and printed
a helpful error if it was too low. Because our main.py has `yield from`
syntax in it, printing such an error message isn't possible; we'll crash
with a syntax error first. We could create another file within the
modile (or maybe an __init__.py) to support this, but for now I'm just
dropping the feature.

Test Plan:
Manually played with peru.sh to make sure it still works. Ran
`pip install .` to check that the generated script works. Also tested
that on my Windows VM, and it works great. (It generates an exe file, in
fact.)

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D135
2014-12-03 00:14:36 -05:00
Jack O'Connor 1c6d7c1a55 make sure merge prefixes for git are always forward-slash-separated
Summary:
Git doesn't expect backslashes in tree merge prefixes, but on Windows we
were incorrectly using those. That got things very confused when
anything had an import path with slashes in it. Use pathlib to make sure
we always get a posix path for this.

Fixes https://github.com/buildinspace/peru/issues/60.

Test Plan: New unit test that was previously failing on Windows.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D136
2014-12-02 21:58:36 -05:00
Jack O'Connor 0776864853 mention supported OSs in the README 2014-12-02 21:58:17 -05:00
Jack O'Connor 80c65118be proper python syntax highlighting in the README 2014-11-26 01:11:39 -05:00
Jack O'Connor 025bf55cfa add installation instructions to the README
Summary: Recommend pip, and include mentions of our AUR package and our PPA.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D134
2014-11-26 01:06:34 -05:00
Jack O'Connor 2d7e0dae67 stop defaulting to fancy output on Windows
Summary:
At some point we should do proper terminal capability detection, but
until then just disable the fancy stuff on Windows. I took a quick look
at Colorama, but that didn't seem to support the control codes we need.

Test Plan:
Ran a sync on Windows. Confirmed the default output is quiet and that
errors don't have junk around them.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D131
2014-11-25 20:09:39 -05:00
Jack O'Connor af3e693e75 make travis test runs more verbose
Summary:
That way if a test has weird output, it's easier to tell what it's
coming from. Also allow test.sh to take command line arguments and
forward them to the unittest command.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D129
2014-11-23 20:27:36 -05:00
Jack O'Connor a053a3a88a sync with -q in validate_third_party.sh
Summary:
Travis likes to pretend that its tests are running in a terminal, but it
doesn't support the ANSI control codes that our fancy display uses, so
we get a spew of crap in the build logs when peru runs inside of
validate_third_party.sh. Use `-q` to avoid the problem.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D127
2014-11-23 20:25:01 -05:00
Jack O'Connor b781a4c681 fix makelocal.sh
Summary:
The script was originally written at `./scripts/packaging/arch/`, but we
moved the packaging directory to the toplevel before we committed it. I
forgot to change a path in the script, so it broke.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D128
2014-11-23 20:24:03 -05:00
Jack O'Connor abb741e671 silence an autocrlf warning on Windows in the git submodules test
Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D124
2014-11-23 20:20:20 -05:00
Jack O'Connor 52f55a27f1 update asyncio to the Python 3.4.2 version
Summary:
This version does a better job of detecting unsafe operations across
loops/threads in `PYTHONASYNCIODEBUG` mode, which is nice.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D123
2014-11-23 20:20:09 -05:00
Jack O'Connor ddd008e880 skip testing the rsync plugin on Windows
Summary:
The rsync plugin is written in bash, so it won't work properly on Windows.
A couple field validation tests also depended on rsync, but those can use
the git plugin instead.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D122
2014-11-23 20:19:58 -05:00
Jack O'Connor 7ef0a8da18 skip tests with build commands on Windows
Summary:
Eventually we might want some mechanism to allow multiple versions of
build commands, so that a rule can work on both Windows and POSIX. For
now, we'll just skip the tests that rely on build commands when we're
running on Windows.

https://github.com/buildinspace/peru/issues/17

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D121
2014-11-23 20:19:48 -05:00
Jack O'Connor e1d1aab905 stop using TemporaryNamedFile
Summary:
It looks like Windows takes an exclusive write lock on
`TemporaryNamedFile`s when they're created. We want to be able to open
temp files in a context manager than cleans them up automatically, which
is causing errors when the file is opened again for actual writing. It's
simpler to just use the temporary directory context manager and create
an unmanaged file in it.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D120
2014-11-23 20:19:37 -05:00
Jack O'Connor ff7ef36c7b add __str__ for PrintableError
Summary: This makes it easier to read plugin errors that happen during tests.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D119
2014-11-23 20:19:26 -05:00
Jack O'Connor 78dd85c9cd use pathlib for building file:// URIs
Summary:
The rules for building file URIs on Windows are a little more
complicated than just sticking `file://` in front of a path. Luckily
pathlib has a method that does everything right.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D118
2014-11-23 20:19:16 -05:00
Jack O'Connor 9cbe400298 stop using shell commands in tests
Summary:
Lots of our test code dealing with repos was running commands as shell
strings for convenience. Even though we stuck to simple commands, we
still ran into issues with single-quoted parameters not working on
Windows. Skipping the shell entirely and using plain old exec solves
all these problems.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D117
2014-11-23 20:19:05 -05:00
Jack O'Connor 4cd33bfb5f stop hardcoding the temp root
Summary: The hardcoded value wasn't appropriate for Windows.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D116
2014-11-23 20:18:54 -05:00
Jack O'Connor 1d1f0c9a87 use pathlib when dealing with paths in tests, and add unit tests
Summary:
Before this change, tons of our tests failed on Windows because they
hardcoded paths of the form "a/b/c". Then `os.walk` spat out "a\b\c" and
everything would die. Pathlib solves this nicely.

I was tempted to make the whole shared test library (including e.g.
`create_dir`) return nothing but pathlib paths. Unfortunately, that
required callers to re-stringify paths before passing them to things
like subprocess `cwd` and `env` parameters. Getting rid of
`os.path.join` was nice, but it was more trouble than it was worth.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D115
2014-11-23 20:18:43 -05:00
Jack O'Connor d505aa138a unify newlines in subprocess output
Summary:
Because all asyncio subprocess output is read in binary mode, we don't
get universal newlines for free. But it's the right thing to do, because
we do all our printing with strings in text mode, which translates "\n"
back into the platform-appropriate line separator. So for example,
"\r\n" in a string on Windows will become "\r\r\n" when it gets printed.
This function ensures that all newlines are represented as "\n"
internally, which solves that problem and also helps our tests work on
Windows. Right now we only handle Windows, but we can expand this if
there's ever another newline style we have to support.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D114
2014-11-23 20:18:31 -05:00
Jack O'Connor 9f1a6ac397 peru.bat and test.bat
Summary:
Launcher scripts for Windows. These probably shouldn't live in the top
level, but I haven't done the work to make them run from other
directories yet. I should do that before this lands.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D113
2014-11-23 20:18:21 -05:00
Jack O'Connor 1ed0b85b51 add --catch to the unit tests
Summary:
This lets us hit Ctrl-C and still get results from tests that have run
so far.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D112
2014-11-23 20:18:10 -05:00