Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit 3c74b45

Browse files
committed
More changes in preparation for beta.
1 parent a70368a commit 3c74b45

10 files changed

+145
-55
lines changed

CONTRIBUTING.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Contributing to PyReact
2+
3+
## Development Process
4+
5+
The majority of development on PyReact will occur through GitHub. Accordingly, the process for contributing will follow standard GitHub protocol.
6+
7+
### Bugs
8+
9+
We will be using GitHub Issues for our public bugs. Before filing a new task, try to make sure your problem doesn't already exist. Then, provide clear repro steps, with examples if possible.
10+
11+
### Pull Requests
12+
13+
Please submit your patches to PyReact via pull requests. *Before* submitting a pull request, please make sure the following is done:
14+
15+
1. Fork the repo and create your branch from `master`.
16+
2. If you've added code that should be tested, add tests!
17+
3. If you've changed APIs, update the documentation.
18+
4. Make sure your code follows PEP8 style guidelines.
19+
5. If you haven't already, complete the CLA.
20+
21+
### Contributor License Agreement ("CLA")
22+
23+
In order to accept your pull request, we need you to submit a CLA. You only need to do this once, so if you've done this for another Facebook open source project, you're good to go. If you are submitting a pull request for the first time, just let us know that you have completed the CLA and we can cross-check with your GitHub username.
24+
25+
Complete your CLA here: <https://developers.facebook.com/opensource/cla>
26+
27+
## How to Get in Touch
28+
29+
* IRC - [#reactjs on freenode](http://webchat.freenode.net/?channels=reactjs)
30+
* Mailing list - [reactjs on Google Groups](http://groups.google.com/group/reactjs)
31+
32+
## License
33+
34+
By contributing to PyReact, you agree that your contributions will be licensed under the [Apache License Version 2.0 (APLv2)](LICENSE).

DESCRIPTION

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PyReact
2+
=======
3+
4+
PyReact is a Python wrapper around the `React <https://facebook.github.io/react/>`_ JavaScript library and `JSX <https://facebook.github.io/react/docs/jsx-in-depth.html>`_.
5+
6+
Specifically, it provides an API to transform JSX files into JavaScript from within your Python application, as well as providing access to the latest React build.
7+
8+
For more information, please visit the `PyReact project on GitHub <https://github.com/facebook/react-python/>`_.

MANIFEST.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
include README.rst VERSIONS.rst
2-
include LICENSE
1+
include *.md
2+
include LICENSE DESCRIPTION
33
recursive-include react js *.js

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# PyReact
2+
3+
PyReact is a Python wrapper around the [React](http://facebook.github.io/react/) JavaScript library and [JSX](http://facebook.github.io/react/docs/jsx-in-depth.html).
4+
5+
Specifically, it provides an API to transform JSX files into JavaScript from within your Python application, as well as providing access to the latest React build.
6+
7+
8+
## Installation
9+
10+
**PyPI**: PyReact is hosted on PyPI, and can be installed with `pip`:
11+
12+
$ pip install PyReact
13+
14+
Alternatively, add it into your `requirements` file:
15+
16+
PyReact==0.1.0
17+
18+
19+
**Dependencies**: PyReact uses [PyExecJS](https://github.com/doloopwhile/PyExecJS) to execute the bundled React code, which requires that a JS runtime environment is installed on your machine. We don't explicitly set a dependency on a runtime environment; Mac OS X comes bundled with one. If you're on a different platform, we recommend [PyV8](https://code.google.com/p/pyv8/).
20+
21+
## Usage
22+
23+
Transform your JSX files via the provided `jsx` module::
24+
25+
```python
26+
from react import jsx
27+
28+
# For multiple paths, use the JSXTransformer class.
29+
transformer = jsx.JSXTransformer()
30+
for jsx_path, js_path in my_paths:
31+
transformer.transform(jsx_path, js_path)
32+
33+
# For a single file, you can use a shortcut method.
34+
jsx.transform('path/to/input/file.jsx', 'path/to/output/file.js')
35+
```
36+
37+
**Django**: PyReact includes a JSX compiler for [django-pipeline](https://github.com/cyberdelia/django-pipeline). Add it to your project's pipeline settings like this:
38+
39+
```python
40+
PIPELINE_COMPILERS = (
41+
'react.utils.pipeline.JSXCompiler',
42+
)
43+
```
44+
45+
46+
## License
47+
48+
Copyright (c) 2013 Facebook, Inc.
49+
Released under the [Apache License, Version 2.0](LICENSE).

README.rst

-41
This file was deleted.

VERSIONS.rst VERSIONS.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
Bundled Versions
2-
================
1+
## Bundled Versions
2+
33
This file lists the version(s) of React that are bundled with each version of PyReact.
44

5-
+---------+-------+
65
| PyReact | React |
7-
+=========+=======+
6+
|---------|-------|
87
| 0.1.0 | 0.4.1 |
9-
+---------+-------+

react/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import jsx, source
1615

17-
18-
VERSION = '0.1.0'
16+
VERSION = '0.1.1'
1917
REACT_VERSION = '0.4.1'

react/utils/__init__.py

Whitespace-only changes.

react/utils/pipeline.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2013 Facebook, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from pipeline.compilers import CompilerBase
16+
from pipeline.exceptions import CompilerError
17+
from react.jsx import JSXTransformer, TransformError
18+
19+
class JSXCompiler(CompilerBase):
20+
output_extension = '.js'
21+
22+
def __init__(self):
23+
CompilerBase.__init__(self)
24+
self.transformer = JSXTransformer()
25+
26+
def match_file(self, filename):
27+
return path.endswith('.jsx')
28+
29+
def compile(self, infile, outfile, outdated=False, force=False):
30+
if not outdated and not force:
31+
return
32+
try:
33+
return self.transformer.transform(infile, outfile)
34+
except TransformError as e:
35+
raise CompilerError(e.message)

setup.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,25 @@
77
version=VERSION,
88
author='Kunal Mehta',
99
author_email='[email protected]',
10+
url='https://github.com/facebook/PyReact',
11+
license='Apache-2.0',
12+
description='Python bridge to JSX & the React JavaScript library.',
13+
long_description=open('DESCRIPTION').read(),
14+
classifiers =[
15+
'Development Status :: 4 - Beta',
16+
'Intended Audience :: Developers',
17+
'License :: OSI Approved :: Apache Software License',
18+
'Programming Language :: Python',
19+
'Programming Language :: Python :: 2.7',
20+
'Topic :: Software Development :: Code Generators',
21+
'Topic :: Software Development :: Libraries :: Python Modules',
22+
],
1023
packages=find_packages(),
1124
package_data={'js': [
1225
'js/react.js',
1326
'js/react.min.js',
1427
'js/JSXTransformer.js',
1528
]},
16-
url='https://github.com/facebook/PyReact',
17-
license='Apache-2.0',
18-
description='Python bridge to JSX & the React JavaScript library.',
19-
long_description=open('README.rst').read(),
2029
install_requires=[
2130
'PyExecJS >= 1.0.4',
2231
]

0 commit comments

Comments
 (0)