Giter Site home page Giter Site logo

jip's Introduction

jip

https://img.shields.io/pypi/v/jip.svg?maxAge=2592000:target:https://pypi.python.org/pypi/jip

https://img.shields.io/pypi/l/jip.svg?maxAge=2592000:target:

Jip is the jython equivalent of pip to python. It will resolve dependencies and download jars for your jython environment.

License

jip itself is distributed according to MIT License .

Install

jip is recommended to run within virtualenv, which is a best practice for python/jython developers to created a standalone, portable environment. From jip 0.7, you can use jip.embed in the global installation.

Install jip within virtualenv

Create virtualenv with jython:

virtualenv -p /usr/local/bin/jython jython-env

Activate the shell environment:

cd jython-dev
source bin/activate

Download and install jip with pip:

pip install jip

Install jip for global jython (since 0.7)

Download jip from pypi page . Then install it with setup.py

jython setup.py install

Usage

Install a Java package

jip will resolve dependencies and download jars from maven repositories. You can install a Java package just like what you do python with pip:

jip install <groupId>:<artifactId>:<version>

Take spring as example:

jip install org.springframework:spring-core:3.0.5.RELEASE

Resolve dependencies defined in a pom

jip allows you to define dependencies in a maven pom file, which is more maintainable than typing install command one by one:

jip resolve pom.xml

Resolve dependencies for an artifact

With jip, you can resolve and download all dependencies of an artifact, without grab the artifact itself (whenever the artifact is downloadable, for example, just a plain pom). This is especially useful when you are about to setup an environment for an artifact. Also, java dependencies for a jython package is defined in this way.

jip deps info.sunng.gefr:gefr:0.2-SNAPSHOT

Update snapshot artifact

You can use update command to find and download a new deployed snapshot:

jip update info.sunng.bason:bason-annotation:0.1-SNAPSHOT

Run jython with installed java packages in path

Another script jython-all is shipped with jip. To run jython with Java packages included in path, just use jython-all instead of jython

List

Use jip list to see artifacts you just installed

Remove a package

You are suggested to use jip remove to remove an artifact. This will keep library index consistent with file system.

jip remove org.springframework:spring-core:3.0.5.RELEASE

Currently, there is no dependency check in artifact removal. So you should be careful when use this command.

Clean

jip clean will remove everything you downloaded, be careful to use it.

Search

You can also search maven central repository with a jip search [keyword]. The search service is provided by Sonatype's official Maven search .

Persist current environment state

Before you distribute you environment, you can use freeze to persist current state into a pom file.

jip freeze > pom.xml

Configuration

You can configure custom maven repository with a dot file, jip will search configurations in the following order:

  1. $VIRTUAL_ENV/.jip_config, your virtual environment home
  2. $HOME/.jip_config, your home

Here is an example:

[repos:jboss]
uri=http://repository.jboss.org/maven2/
type=remote

[repos:local]
uri=~/.m2/repository/
type=local

[repos:central]
uri=https://repo1.maven.org/maven2/
type=remote

Be careful that the .jip_config file will overwrite default settings, so you must include default local and central repository explicitly. jip will skip repositories once it finds package matches the maven coordinator.

Artifacts will be cached at $HOME/.jip ($VIRTUAL_ENV/.jip if you are using a virtual environment).

From 0.4, you can also define repositories in pom.xml if you use the resolve command. jip will add these custom repositories with highest priority.

Distribution helpers

From 0.4, you can use jip in your setup.py to simplify jython source package distribution. Create pom.xml in the same directory with setup.py. Fill it with your Java dependencies in standard way. In this file, you can also define custom repositories. Here is an example:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    ...

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency>

        ...

    </dependencies>

    <repositories>
        <repository>
            <id>sonatype-oss-sonatype</id>
            <url>http://oss.sonatype.org/content/repositories/snapshots/</url>
        </repository>
    </repositories>
</project>

And in your setup.py, use the jip setup wrapper instead of the one provided by setuptools or distutils. You can add keyword argument pom to specify a custom name of the pom file.

from jip.dist import setup

Other than the traditional pom configuration, jip also allows you to describe dependencies in python. You can define a data structure in your setup.py like:

requires_java = {
    'dependencies':[
        ## (groupdId, artifactId, version)
        ('org.slf4j', 'slf4j-api', '1.6.1'),
        ('org.slf4j', 'slf4j-log4j12', '1.6.1'),
        ('info.sunng.soldat', 'soldat', '1.0-SNAPSHOT'),
        ('org.apache.mina', 'mina-core', '2.0.2')
    ],
    'repositories':[
        ('sonatype-oss-snapshot', 'http://oss.sonatype.org/content/repositories/snapshots/')
    ]
}

And pass it to jip setup as keyword argument requires_java. Once jip found this argument, it won't try to load a pom file.

from jip.dist import setup
setup(
    ...
    requires_java=requires_java,
    ...)

Another resolve command was added to setuptools, you can use this command to download all dependencies to library path

jython setup.py resolve

All dependencies will be installed when running

jython setup.py install

So with jip's setup() wrapper, pip will automatically install what your package needs. You can publish your package to python cheese shop, and there is just one command for everything

pip install [your-package-name]

Embedded dependency helper

jip.embed is available for both virtualenv and global installation. You can descirbe Java dependency in you code, then it will be resolved on the fly. jip.embed is inspired by Groovy's @Grab.

from jip.embed import require

require('commons-lang:commons-lang:2.6')
from org.apache.commons.lang import StringUtils

StringUtils.reverse('jip rocks')

Contact

If you have any problem using jip, or feature request for jip, please feel free to fire an issue on github issue tracker. You can also follow @Sunng on twitter.

Change Notes

  • Next version - unreleased
  • 0.9.16 - 2022-12-20
    • Fix deprecated api removal
  • 0.9.15 - 2020-06-04
    • Fix encoding errors of download from local repositories
  • 0.9.14 - 2020-05-25
    • Added Python 3.7 compatibility
    • Fail gracefully if unkown repository type
    • Maven central moved to HTTPS
  • 0.9.13 - 2017-07-23
    • Added option copy-pom for install command
  • 0.9.12 - 2017-03-20
    • Fix errors when downloading POMs containing umlauts
    • Remove jip.JIP_VERSION. Use jip.__version__ if you need it
  • 0.9.11 - 2017-03-11
    • Improve handling of download errors
  • 0.9.10 - 2017-03-09
    • Fix .jip/cache not being isolated in virtualenv
  • 0.9.9 - 2016-10-31
    • Fix possible crash
  • 0.9.8 - 2016-07-27
    • Minor fixes
  • 0.9 - 2015-04-23
    • Python 3 support
  • 0.8 - 2014-03-31
    • Windows support
  • 0.7 - 2011-06-11
    • All new jip.embed and global installation
    • enhanced search
    • dry-run option for install, deps and resolve
    • exclusion for install command and jip.dist
    • local maven repository is disabled by default
    • improved dependency resolving speed
    • jip now maintains a local cache of jars and poms in $HOME/.jip/cache/
    • use argparse for better command-line ui
    • add some test cases
  • 0.5.1 - 2011-05-14
    • Artifact jar package download in paralell
    • User-agent header included in http request
    • new command freeze to dump current state
    • bugfix
  • 0.4 - 2011-04-15
    • New commands available: search, deps, list, remove
    • New feature jip.dist for setuptools integration
    • Dependency exclusion support, thanks vvangelovski
    • Allow project-scoped repository defined in pom.xml and setup.py
    • Code refactoring, now programming friendly
    • README converted to reStructuredText
    • Migrate to MIT License
  • 0.2.1 - 2011-04-07
    • Improved console output format
    • Correct scope dependency management inheritance
    • Alpha release of snapshot management, you can update a snapshot artifact
    • Environment independent configuration. .jip for each environment
    • Bug fixes
  • 0.1 - 2011-01-04
    • Initial release

Links

jip's People

Contributors

alpo avatar baztian avatar cclauss avatar fergalmonaghanatgenesys avatar mvfranz avatar pombredanne avatar reckart avatar saamc avatar sunng87 avatar vvangelovski avatar wikier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jip's Issues

AttributeError: 'Artifact' object has no attribute 'group'

When running most commands like jip list and jip freeze > pom.xml I get this error:

mhsjlw@arch ~/D/jpython-test> jip freeze > pom.xml
Traceback (most recent call last):
  File "/usr/bin/jip", line 9, in <module>
    load_entry_point('jip==0.9.9.dev1', 'console_scripts', 'jip')()
  File "/usr/lib/python3.5/site-packages/jip-0.9.9.dev1-py3.5.egg/jip/main.py", line 62, in main
    commands[cmd](**args)
  File "/usr/lib/python3.5/site-packages/jip-0.9.9.dev1-py3.5.egg/jip/commands.py", line 45, in wrapper
    index_manager.initialize()
  File "/usr/lib/python3.5/site-packages/jip-0.9.9.dev1-py3.5.egg/jip/index.py", line 89, in initialize
    artifacts = pickle.loads(pickledata)
  File "/usr/lib/python3.5/site-packages/jip-0.9.9.dev1-py3.5.egg/jip/maven.py", line 71, in __hash__
    return self.group.__hash__()*13+self.artifact.__hash__()*7+self.version.__hash__()
AttributeError: 'Artifact' object has no attribute 'group'

I've installed jip by cloning the repository and running sudo setup.py install
Any ideas on what's wrong?

EDIT: It seems that virtualenv also fails with a similar error:

mhsjlw@arch ~/D/jpython-test> virtualenv -p /usr/local/bin/jython jython-env
Running virtualenv with interpreter /usr/local/bin/jython
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/virtualenv.py", line 25, in <module>
    import distutils.sysconfig
  File "/home/mhsjlw/jython2.7.0/Lib/distutils/sysconfig.py", line 28, in <module>
    project_base = os.path.dirname(os.path.realpath(sys.executable))
  File "/home/mhsjlw/jython2.7.0/Lib/posixpath.py", line 367, in realpath
    path, ok = _joinrealpath('', filename, {})
  File "/home/mhsjlw/jython2.7.0/Lib/posixpath.py", line 373, in _joinrealpath
    if isabs(rest):
  File "/home/mhsjlw/jython2.7.0/Lib/posixpath.py", line 61, in isabs
    return s.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'

Add automated PyPI deployment from travis

@sunng87, it would be nice if you could follow
https://docs.travis-ci.com/user/deployment/pypi/
to allow for PyPI deployment on tagged commits. This way @wikier and I could publish new releases. I don't think @wikier and I have write access to https://pypi.python.org/pypi/jip
Using travis PyPI deployment would ease the overall release process.

I think it should look something like this:

...
sudo: false

deploy:
  provider: pypi
  user: sunng
  password:
    secure: yourEncryptedPwd
  distributions: "sdist bdist_wheel"
  on:
    tags: true
    repo: jiptool/jip

python:

...

(After you've set this up I might implement a .bumpversion.cfg to use bumpversion to do the tagging, changelog manipulation and the like to further ease the deployment process.)

jython exit if artifact not found

command._resolve_artifacts exits with sys.exit if artifact cannot be downloaded. This is bad in server applications because the whole server dies. There should be a "return []" instead and an importerror in the application.

Too strict against some pom files

Running

jip install org.apache.hadoop:hadoop-project:3.1.0

I get

jip [Checking] pom file /tmp/jip/.m2/repository/org/apache/hadoop/hadoop-project/3.1.0/hadoop-project-3.1.0.pom
jip [Skipped] pom file not found at /tmp/jip/.m2/repository/org/apache/hadoop/hadoop-project/3.1.0/hadoop-project-3.1.0.pom
jip [Checking] pom file https://repo1.maven.org/maven2/org/apache/hadoop/hadoop-project/3.1.0/hadoop-project-3.1.0.pom
Traceback (most recent call last):
File "/tmp/jip/bin/jip", line 11, in <module>
    load_entry_point('jip', 'console_scripts', 'jip')()
File "/home/me/Sources/jip/jip/main.py", line 62, in main
    commands[cmd](**args)
File "/home/me/Sources/jip/jip/commands.py", line 46, in wrapper
    func(*args, **kwargs)
File "/home/me/Sources/jip/jip/commands.py", line 175, in install
    _install([artifact], options=options)
File "/home/me/Sources/jip/jip/commands.py", line 145, in _install
    download_list = _resolve_artifacts(artifacts, exclusions)
File "/home/me/Sources/jip/jip/commands.py", line 126, in _resolve_artifacts
    for r in pom_obj.get_repositories():
File "/home/me/Sources/jip/jip/maven.py", line 294, in get_repositories
    eletree = self.get_element_tree()
File "/home/me/Sources/jip/jip/maven.py", line 113, in get_element_tree
    parser.feed(pom_string.encode('utf-8'))
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1784, column 11

The line that's causing the error is the Xlint:-unchecked one.

          <compilerArguments>
            <Xlint/>
			<Xlint:-unchecked/>
            <Xmaxwarns>9999</Xmaxwarns>
          </compilerArguments>

It seems to be the same error as in ben-manes/gradle-versions-plugin#238

AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren'

The long-deprecated getchildren function has been removed since python 3.9:
https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getchildren

When I upgrade from python 3.7 to python 3.10 and change nothing else, and then run this command:

jip install org.apache.spark:spark-avro_2.12:3.3.1

I now hit this new issue:

(venv) fmonagha@GWY-FMONAGHAN-M journey-event-deserializer-static-assets % jip install org.apache.spark:spark-avro_2.12:3.1.1
jip [Checking] pom file https://repo1.maven.org/maven2/org/apache/spark/spark-avro_2.12/3.1.1/spark-avro_2.12-3.1.1.pom
jip [Checking] pom file https://repo1.maven.org/maven2/org/apache/spark/spark-parent_2.12/3.1.1/spark-parent_2.12-3.1.1.pom
Traceback (most recent call last):
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/bin/jip", line 8, in <module>
    sys.exit(main())
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/main.py", line 62, in main
    commands[cmd](**args)
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/commands.py", line 46, in wrapper
    func(*args, **kwargs)
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/commands.py", line 175, in install
    _install([artifact], options=options)
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/commands.py", line 145, in _install
    download_list = _resolve_artifacts(artifacts, exclusions)
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/commands.py", line 129, in _resolve_artifacts
    more_dependencies = pom_obj.get_dependencies()
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 197, in get_dependencies
    dep_mgmt = self.get_dependency_management()
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 155, in get_dependency_management
    dependency_management_version_dict.update(parent.get_dependency_management())
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 155, in get_dependency_management
    dependency_management_version_dict.update(parent.get_dependency_management())
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 157, in get_dependency_management
    properties = self.get_properties()
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 249, in get_properties
    prop_eles = properties_ele.getchildren()
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren'

Running this find+replace command first to upgrade line 249 of jip/maven.py before rerunning jip install resolves the issue:

sed -i '' -e 's/properties_ele.getchildren()/list(properties_ele)/g' venv/lib/python*/site-packages/jip/maven.py

Doesn't work with Python 3.7

Hi. I'm using jip 0.9.13 with Python 3.7.1.
When I attempt to import jip.repository, python throws a syntax error.

koalanlp/Util.py:4: in <module>
    from jip import commands, logger
../../../virtualenv/python3.7.1/lib/python3.7/site-packages/jip/__init__.py:33: in <module>
    from jip.repository import repos_manager
../../../virtualenv/python3.7.1/lib/python3.7/site-packages/jip/repository.py:43: in <module>
    from jip.util import DownloadException, download, download_string, get_virtual_home
E     File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/jip/util.py", line 45
E       def download(url, target, async=False, close_target=False, quiet=True):
E                                     ^
E   SyntaxError: invalid syntax

It seems that the argument name "async" is the problem, since that is newly introduced reserved keywords in Python 3.7.
So, could we change and update jip package to eliminate keyword names like "async", "await"?

xml.etree.ElementTree.ParseError: Premature end of file.

When I try to resolve dependency with the following code:

from jip.embed import require

require("net.imagej:imagej:2.0.0-rc-42")
from net.imagej import ImageJ
ij = ImageJ()

It returns error and terminates (see below). If you could fix here in maven.py, it wil be veryhelpful!

... ...
jip [Checking] pom file /Users/miura/.m2/repository/org/jhotdraw/jhotdraw/7.6.0/jhotdraw-7.6.0.pom
jip [Checking] pom file /Users/miura/.m2/repository/net/imagej/imagej-ui-awt/0.3.0/imagej-ui-awt-0.3.0.pom
Traceback (most recent call last):
  File "testij2.py", line 3, in <module>
    require("net.imagej:imagej:2.0.0-rc-42")
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/site-packages/jip-0.9.9-py2.7.egg/jip/embed.py", line 38, in require
    artifact_set = _resolve_artifacts([artifact])
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/site-packages/jip-0.9.9-py2.7.egg/jip/commands.py", line 129, in _resolve_artifacts
    more_dependencies = pom_obj.get_dependencies()
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/site-packages/jip-0.9.9-py2.7.egg/jip/maven.py", line 197, in get_dependencies
    dep_mgmt = self.get_dependency_management()
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/site-packages/jip-0.9.9-py2.7.egg/jip/maven.py", line 155, in get_dependency_management
    dependency_management_version_dict.update(parent.get_dependency_management())
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/site-packages/jip-0.9.9-py2.7.egg/jip/maven.py", line 153, in get_dependency_management
    parent = self.get_parent_pom()
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/site-packages/jip-0.9.9-py2.7.egg/jip/maven.py", line 121, in get_parent_pom
    eletree = self.get_element_tree()
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/site-packages/jip-0.9.9-py2.7.egg/jip/maven.py", line 114, in get_element_tree
    self.eletree = parser.close()
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/xml/etree/ElementTree.py", line 1656, in close
    self._raiseerror(v)
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/xml/etree/ElementTree.py", line 1508, in _raiseerror
    raise err
  File "<string>", line None
xml.etree.ElementTree.ParseError: Premature end of file.

snapshot versioning

There is no SNAPSHOT version in a deployed repository, so to download a artifact jip has to read maven-metadata.xml to get the newest snapshot build.

KeyError while downloading runtime dependencies with jip install

When there are runtime dependencies for a jar jip seems to fail with a KeyError, see log:

(jython-default)Vasil-Vangelovskis-MacBook-Pro:jip vasilvangelovski$ jip install commons-beanutils:commons-beanutils
Traceback (most recent call last):
  File "/Users/vasilvangelovski/.virtualenvs/jython-default/bin/jip", line 7, in <module>
    execfile(__file__)
  File "/Users/vasilvangelovski/Projects/jip/scripts/jip", line 20, in <module>
    main()
  File "/Users/vasilvangelovski/Projects/jip/jip.py", line 595, in main
    commands[cmd](*values)
  File "/Users/vasilvangelovski/Projects/jip/jip.py", line 510, in install
    group, artifact, version = artifact_identifier.split(":")
ValueError: need more than 2 values to unpack
(jython-default)Vasil-Vangelovskis-MacBook-Pro:jip vasilvangelovski$ jip install commons-beanutils:commons-beanutils:1.8.3
jip  [Checking] pom file http://repo2.maven.org/maven2/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.pom
jip  [Downloading] jar from http://repo2.maven.org/maven2/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar
jip  [Finished] http://repo2.maven.org/maven2/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar downloaded 
jip  [Checking] pom file http://repo2.maven.org/maven2/org/apache/commons/commons-parent/14/commons-parent-14.pom
jip  [Checking] pom file http://repo2.maven.org/maven2/org/apache/apache/7/apache-7.pom
Traceback (most recent call last):
  File "/Users/vasilvangelovski/.virtualenvs/jython-default/bin/jip", line 7, in <module>
    execfile(__file__)
  File "/Users/vasilvangelovski/Projects/jip/scripts/jip", line 20, in <module>
    main()
  File "/Users/vasilvangelovski/Projects/jip/jip.py", line 595, in main
    commands[cmd](*values)
  File "/Users/vasilvangelovski/Projects/jip/jip.py", line 513, in install
    _install(artifact_to_install)
  File "/Users/vasilvangelovski/Projects/jip/jip.py", line 500, in _install
    more_dependencies = pom_obj.get_dependencies()
  File "/Users/vasilvangelovski/Projects/jip/jip.py", line 411, in get_dependencies
    scope = dep_mgmt[(group_id, artifact_id)][1]
KeyError: ('commons-logging', 'commons-logging')

I debugged jip.py and can see the dep_mgmt dict is empty, hence the key error.

jip executable not found

Hi,

I am trying to use jython with cucumber-jvm as it is shown in the following site

http://supersabrams.com/blog/?p=386

I need jip for that. I have installed jip as explained there, but I am not able to find the jip executable.

Where should it be?

I need to run this and I really don't know how.

jip install info.cukes:cucumber-jython:1.0.1

Any ideas?

Thanks

M

Maven artifacts corrupted on Windows

When jip is used on Windows, all Maven artifacts become corrupted. The reason is that the "open" method on Windows opens files in text mode per default, not in binary mode. To fix this, all open methods must be called with "rb" or "wb".

MacOS permission error

When I do a deps on my Mac, i get this

jip [Finished] dependencies resolved
Traceback (most recent call last):
  File "/usr/local/bin/jip", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/site-packages/jip/main.py", line 62, in main
    commands[cmd](**args)
  File "/usr/local/lib/python3.5/site-packages/jip/commands.py", line 47, in wrapper
    index_manager.finalize()
  File "/usr/local/lib/python3.5/site-packages/jip/index.py", line 104, in finalize
    self.persist()
  File "/usr/local/lib/python3.5/site-packages/jip/index.py", line 72, in persist
    picklefile = open(self.filepath, 'wb')
PermissionError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/.jip_index'

Its trying to write the .jip_index to a Mac system folder that even admins don't have access too. It should be writing it to ~/.jip or something like that.

Classes not found on the first try

Class loading is not always working on the first try, but on the second.

Example:

Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_03
Type "help", "copyright", "credits" or "license" for more information.

from jip import embed
embed.require('com.itextpdf:itextpdf:5.3.2')
import com
com.itextpdf.text.Document
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'javapackage' object has no attribute 'itextpdf'
com.itextpdf.text.Document
<type 'com.itextpdf.text.Document'>

zip archive for Windows users

jip comes in a tar.gz archive. Windows users cannot extract that without first installing additional software like 7zip. It would be very convenient to offer a zip archive in addition.

setup.py install fails on Ubuntu vivid: SyntaxError: mismatched input 'as' expecting COLON

After installing jython 2.5.3-3 on Ubuntu 15.04:

jip-0.9.4$ jython setup.py install
"my" variable $jythonHome masks earlier declaration in same scope at /usr/bin/jython line 15.
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
Traceback (most recent call last):
  File "setup.py", line 29, in <module>
    from jip import JIP_VERSION as version
  File ".../jip-0.9.4/jip/__init__.py", line 33, in <module>
    from jip.repository import repos_manager
  File ".../jip/repository.py", line 43, in <module>
    from jip.util import DownloadException, download, download_string, get_virtual_home
  File ".../jip-0.9.4/jip/util.py", line 65
    except requests.exceptions.RequestException as e:
                                               ^
SyntaxError: mismatched input 'as' expecting COLON

This feels like it might be an upstream problem with jython, but I am very green at jython.
Also as I am following the typical newbie approach of install jython and then jip, this might be useful to add a helpful error message.

Additional non-binary file access

There appear to be other non-binary file accesses that I did not hit before, e.g.

repository.py :: checksum : file(filepath, 'r')

This is just one instance, not an exhaustive list. There may be other locations like this that should be change to 'rb' or 'wb'.

Use os.path.join for platform-independent paths

jip tends to mix slash and backslash in paths on Windows. It would be cleaner to use e.g. os.path.join('', '.jip', 'cache') instead of '/.jip/cache'. Such paths with hardcoded slashes appear in various locations in the sourcecode.

unicode issue: cannot install de.l3s.boilerpipe

Steps to reproduce

jip install de.l3s.boilerpipe:boilerpipe:1.1.0

Expected behaviour

The library installed

Actual behaviour

  File "[SKIPPED]/jip/cache.py", line 67, in put_pom
    f.write(data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1165-1166: ordinal not in range(128)

System Configuration

Python 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_121
virtualenv

Notes

German symbols in the POM.

Provide search command as Sonatype launched search for central repo

jip will have a new search command as Sonatype launched the official search engine. Currently only central repository is available for search.

Send request to

GET http://search.maven.org/solrsearch/select?q=pivot&rows=20&wt=json

Then parse the response response/docs array:

{"id":"org.apache.pivot:pivot-charts","g":"org.apache.pivot","a":"pivot-charts","latestVersion":"2.0","repositoryId":"central","p":"jar","timestamp":1293472565000,"versionCount":4,"text":["org.apache.pivot","pivot-charts"],"ec":["jar","javadoc.jar","pom","sources.jar"]}

Currently I didn't find any terms about usage of this interface, so I consider it hackable :)

Doesn't seem to work with version ranges

I'm seeing the following error when trying to install a JAR with jip:

...
jip [Skipped] Pom file not found at http://repo1.maven.org/maven2/junit/junit-dep/[4.9,)/junit-dep-[4.9,).pom
jip [Error] Artifact not found: junit:junit-dep:[4.9,)

If you visit http://repo1.maven.org/maven2/junit/junit-dep/, version 4.9 as well as 4.10 and 4.11 should be found.

Are version ranges (https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html) supported? If not, is there a hack to overcome this?

setup.py install fails on Fedora 20: ImportError: no module named distutils

After installing jython-2.2.1-14.fc20.noarch.rpm on Fedora release 20 (Heisenbug)

$ tar -xzf jip-0.9.4.tar.gz 
$ cd jip-0.9.4/
$ jython setup.py install
*sys-package-mgr*: processing new jar, '/usr/share/java/jython.jar'
*sys-package-mgr*: processing new jar, '/usr/share/java/jakarta-oro.jar'
*sys-package-mgr*: processing new jar, '/usr/share/java/tomcat-servlet-3.0-api.jar'
*sys-package-mgr*: processing new jar, '/usr/share/java/mysql-connector-java.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/resources.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/rt.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/jsse.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/jce.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/charsets.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/rhino.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/ext/sunpkcs11.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/ext/dnsns.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/ext/localedata.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/ext/zipfs.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/ext/sunjce_provider.jar'
*sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/ext/pulse-java.jar'
Traceback (innermost last):
  File "setup.py", line 27, in ?
ImportError: no module named distutils

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.