The python script simply uses Artifactory's REST API to publish to my local
pypi repository, tacking on a few properties so that some of the REST API
functions work properly, like 'Artifact Latest Version Search Based on
Properties' which you can read here:

https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-ArtifactLatestVersionSearchBasedonProperties

I need to be able to use that call because we're using Chef in-house and we
use that method to get the latest version.  The 'pypi.version' property that
gets added when publishing via 'python setup.py sdist upload -r local'
doesn't work with the REST API so I have to manually add the 'version'
property.  Painful to be honest since we can't add properties when using the
upload option with setup.py.  Ideally I'd like to be able to do everything
using pip, but at the moment this isn't possible.

I'm using the requests package and the method in the documentation here:

https://www.jfrog.com/confluence/display/RTF/Using+Properties+in+Deployment+and+Resolution

Here is the function that publishes the package and adds a few properties
(you can add more):

def _publish_artifact(name, version, path, summary):
    base_url = 'http://server:8081/artifactory/{0}'.format(PYPI_REPOSITORY)
    properties =
';version={0};pypi.name={1};pypi.version={0};pypi.summary={2}'\
                 .format(version, name, summary)
    url_path = '/Company/{0}/{1}/{0}-{1}.zip'.format(name, version)
    url = '{0}{1}{2}'.format(base_url, properties, url_path)

    dist_file = r'{0}\dist\{1}-{2}.zip'.format(path, name, version)
    files = {'upload_file': open(dist_file, 'rb')}
    s = requests.Session()
    s.auth = ('username', 'password')
    reply = s.put(url, files=files)
    logger.info('HTTP reply: {0}'.format(reply))

Hope that helps and I hope jFrog is reading this. It's nice what they've
added so far, they just need a few more tweaks and this will be great.



--
View this message in context: 
http://forums.jfrog.org/PyPi-repo-layout-and-ci-releases-repos-with-promotion-tp7580245p7580285.html
Sent from the Artifactory - Users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Artifactory-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/artifactory-users

Reply via email to